Photos floating at different depths in 3D. The pointer steers the camera; a click brings one forward while the rest fade back.
pnpm dlx shadcn@latest add @latheui/depth-fieldPart of Lathe Pro. Set up your project once with your license key: npx latheui init --key <key>. See Lathe Pro.
Depth Field is part of Lathe Pro
The preview is live and free to try. The source, the install and every assembly come with Pro: $79 once, with lifetime updates.
Depends on
Also accepts native div attributes. Size it with className; it is 460px tall by default.
| Prop | Type | Default | Description |
|---|---|---|---|
| items* (required) | { src: string; alt: string; title?: string }[] | — | The photos. |
| label* (required) | string | — | Accessible name for the field. |
| itemWidth | number | 150 | Width of a photo at the front of the field, in px. |
| aspect | number | 4 / 5 | Width divided by height. |
| depth | number | 900 | How far back the field goes, in px. |
| spread | number | 1 | How far photos spread toward the edges. |
| parallax | number | 1 | How much the camera turns with the pointer, from 0 to 2. |
| drift | boolean | true | A slow drift, so the field moves when nobody is pointing. |
| perspective | number | 900 | Camera distance in px. |
| seed | number | 3 | Changes the layout. The same seed always lays out the same way. |
| curve | Curve | smooth spring | How a chosen photo comes forward. Any curve from the Animation Lab. |
| duration | number | — | Milliseconds, for curves that are not springs. |
<DepthField label="Archive" items={photos} depth={1400} spread={1.2} drift={false} className="h-[600px]" />