import { Forms3D } from "@/components/3d/forms";
export default function Example() {
return (
<div style={{ height: 340 }}>
<Forms3D
variant="slider"
theme="light"
/>
</div>
);
}
Deps: framer-motion, zod, lucide-react
Installation
Install the runtime dependencies, then copy the component module (and the shared 3D core when the component uses WebGL).
npm install framer-motion zod lucide-react
# Copy the component module
cp -r src/components/3d/forms <your-project>/src/components/3d/formsDependencies: framer-motion, zod, lucide-react
Usage
Every category module exposes one typed component. Pick an implementation with variant and pass props grouped by concern.
import { Forms3D } from "@/components/3d/forms";
export default function Example() {
return (
<div style={{ height: 340 }}>
<Forms3D
variant="slider"
theme="light"
/>
</div>
);
}
React implementation
With every prop set explicitly. The complete, copyable source of src/components/3d/forms/index.tsx is available in the playground’s Source tab.
import { Forms3D } from "@/components/3d/forms";
export default function Example() {
return (
<div style={{ height: 340 }}>
<Forms3D
variant="slider"
theme="amoled"
label="Intensity"
accent="#5255ff"
depth={8}
disabled={false}
reducedMotion={false}
/>
</div>
);
}
Next.js implementation
This component is DOM based, but it is still code-split with next/dynamic so interaction code ships only where it's used.
// app/3d-range-slider/page.tsx (Next.js App Router)
"use client";
import dynamic from "next/dynamic";
// Heavy interactive code is split into its own chunk.
const Forms3D = dynamic(
() => import("@/components/3d/forms").then((m) => m.Forms3D),
{ ssr: false, loading: () => <div aria-busy="true" style={{ height: 340 }} /> },
);
export default function Page() {
return (
<main>
<div style={{ height: 340 }}>
<Forms3D
variant="slider"
theme="light"
/>
</div>
</main>
);
}
TypeScript interfaces
export type Theme = "light" | "amoled";
export interface 3DRangeSliderProps {
/** Which Interactive 3D Forms implementation to render */
variant: "slider";
theme: Theme;
/* Content */
label?: string; // default "Intensity"
/* Visual */
accent?: string; // default "#5255ff"
depth?: number; // 0–20, default 8
/* Interaction */
disabled?: boolean; // default false
/* Accessibility */
reducedMotion?: boolean; // default false
}
Props reference
| Prop | Type | Default | Group | Description |
|---|---|---|---|---|
| variant | "slider" | — | Core | Selects the implementation. |
| theme | "light" | "amoled" | — | Core | Themes surfaces, materials and lighting. |
| label | string | "Intensity" | Content | Label |
| accent | string (hex) | "#5255ff" | Visual | Accent |
| depth | number | 8 | Visual | Depth (px) (0 – 20) |
| disabled | boolean | false | Interaction | Disabled |
| reducedMotion | boolean | false | Accessibility | Force reduced motion |
Customization
Colour props accept any hex string. Content props accept plain strings. Every value shown in the playground maps 1:1 to a prop, so you can design visually and copy the generated code. Use Share to send a pre-configured link or Export to download the configuration JSON.
import { Forms3D } from "@/components/3d/forms";
export default function Example() {
return (
<div style={{ height: 340 }}>
<Forms3D
variant="slider"
theme="light"
accent="#ff5a36"
/>
</div>
);
}
Animation settings
- disabledDisabled
All motion is suspended when prefers-reduced-motion is on.
Theme support
Pass theme="light" or theme="amoled". Surfaces, borders, shadows and text switch via CSS variables (--bg, --card, --fg, --border, --accent). AMOLED uses true #000000. Use the theme switch in the playground toolbar to preview both.
Responsive behavior
The component fills its parent, so size it with the container. Use the playground’s desktop / tablet / mobile selector to test. Layouts use fluid widths and container-relative sizing.
Accessibility notes
- — Visible labels are always associated through htmlFor/id.
- — Errors use role=alert and aria-invalid; hints use aria-describedby.
- — Custom checkboxes, radios and switches wrap native inputs, preserving keyboard and screen-reader behaviour.
Performance notes
- — Validation is schema-based (Zod) and runs on submit/step only.
- — Animations use transforms only.
- — No layout thrash — focus effects don't change box size.