Documentation
Build with NEXUS 3D
207 components across 13 categories, sharing one design system, one theme provider and one performance model.
Getting started
NEXUS 3D targets Next.js (App Router) with React 19 and Tailwind CSS. Install the shared dependencies once:
npm install three @react-three/fiber @react-three/drei framer-motion gsap zustand lucide-react zod
npm install -D @types/threeWrap your app in the theme provider and add the pre-hydration script to avoid a flash of the wrong theme:
import { ThemeProvider } from "@/providers/ThemeProvider";
import { themeInitScript } from "@/lib/theme-store";
export default function RootLayout({ children }) {
return (
<html lang="en" suppressHydrationWarning>
<head><script dangerouslySetInnerHTML={{ __html: themeInitScript }} /></head>
<body><ThemeProvider>{children}</ThemeProvider></body>
</html>
);
}Project structure
src/
app/ routes (/, /components, /playground, /docs, /[category] …)
components/
3d/
core/ SceneCanvas, materials, shaders, Globe (shared engine)
backgrounds/ buttons/ cards/ typography/ objects/ navigation/
charts/ loaders/ forms/ heroes/ animations/ gallery/ experiences/
playground/ Playground, Controls, ComponentGrid, LivePreview
ui/ Navbar, CodeBlock, SearchPalette, DocsNav
providers/ ThemeProvider
registry/ categories, components (metadata + controls), codegen
lib/ theme-store, art, color, stores, highlight
styles → app/globals.css design tokens (CSS variables)Each category folder is self-contained and depends only on core/, which makes it straightforward to publish as an independent npm package later.
Component API
Each category exports one strongly-typed component. variant picks the implementation; the remaining props are grouped by concern — visual, animation, interaction, rendering and accessibility.
<Objects3D
variant="sculpture"
theme="amoled"
color="#7777FF"
material="chrome" // visual
rotationSpeed={0.5} // animation
autoRotate drag mouse // interaction
quality="high" // rendering
/>Unknown props are ignored and defaults come from the registry, so a component renders correctly with only variant and theme.
Theming & tokens
Two independent palettes live in CSS variables and switch with data-theme on <html>. The selection persists in localStorage and follows the OS until you choose explicitly. Any element can scope a theme with its own data-theme attribute.
| Token | Light | AMOLED | Role |
|---|---|---|---|
| --bg | #FFFFFF | #000000 | Page background |
| --bg2 | #F7F7F5 | #050505 | Secondary background |
| --surface / --card | #FFFFFF | #0A0A0A / #101010 | Elevated surfaces |
| --fg | #111111 | #FFFFFF | Primary text |
| --fg2 | #686868 | #A1A1AA | Secondary text |
| --border | #E8E8E5 | #202020 | Hairlines |
| --accent | #5255FF | #7777FF | Interactive accent |
| --hover | #ECECFF | #171717 | Hover surface |
Beyond colour: spacing (--space-*), radius, shadows, motion durations (--dur-*), easing curves, and z-index layers are all tokenised. 3D scenes read the same theme: Light uses soft studio lighting, silver materials and contact shadows; AMOLED uses a pure black environment with chrome and restrained emissive accents.
Quality presets
LOW
Mobile-first and battery-conscious
DPR 1 · no antialiasing · ~35% density · low-power GPU hint
MEDIUM
Balanced
DPR ≤ 1.5 · antialiasing · ~70% density
HIGH
Desktop
DPR ≤ 2 · full density · highest segment counts
Performance
- Lazy by default. Every category is a separate chunk loaded with
next/dynamic. - One context at a time. Grids mount WebGL scenes on hover, focus or tap and unmount them afterwards.
- Off-screen suspension. An IntersectionObserver sets
frameloop="never"when a canvas leaves the viewport. - Instancing. Repeated geometry uses InstancedMesh with shared materials.
- Context loss handling. The canvas wrapper listens for webglcontextlost / restored and remounts safely.
- Cleanup. Geometries and textures created in useMemo are disposed on unmount.
Accessibility
- Semantic HTML first: native buttons, inputs, tabs and landmarks.
- Visible focus rings on every interactive element, touch-friendly targets, 4.5:1 text contrast in both themes.
- prefers-reduced-motion halts auto-motion in WebGL and CSS animations; each component also exposes a force-reduced-motion prop.
- If WebGL is unavailable the wrapper renders a readable fallback and the page stays fully usable.
- Charts include a hidden data table; canvas experiences ship DOM alternatives for their controls.
Playground & sharing
Open any component in the playground to adjust its properties live, preview it at desktop / tablet / mobile widths, switch between Light and AMOLED, enter fullscreen, reset the camera, and copy React, Next.js, TypeScript and install snippets. Share encodes your changes into the URL; Export downloads a JSON configuration.
Testing
Registry integrity, control defaults, code generation and share-link encoding are covered by Vitest (npx vitest run). Rendering paths are guarded by strict TypeScript across all 207 components and a full production build.
Contributing
- Add your implementation inside
src/components/3d/<category>. - Register it with one line in
src/registry/components.ts— name, variant, description, optional default overrides. - Declare any variant-specific controls in
controlsFor(). - Verify both themes, reduced motion and the three quality presets, then run the tests and a production build.