Time Scrubber, animated React component
A time picker card where you drag, flick or scroll a ruler of minute ticks under a fixed needle, with momentum, snapping and a rolling clock readout.
- Free
- Inputs & Controls
- Spring
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
AM
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| value | number | — | Controlled time in minutes since midnight (0–1439). |
| defaultValue | number | 570 | Starting time when uncontrolled (570 = 9:30 AM). |
| onChange | (minutes: number) => void | — | Called with the snapped time whenever it changes. |
| onCommit | (minutes: number) => void | — | Called once the ruler comes to rest. |
| interval | number | 15 | Minutes the ruler snaps to (5, 10, 15 or 30 read best). |
| format | "12h" | "24h" | "12h" | Clock format for the readout and hour labels. |
| accent | string | "#ef4444" | Colour of the centre needle. |
| density | number | 1.6 | Pixels per minute on the ruler; larger spreads the hours out. |
| label | string | — | Caption above the time, e.g. "Pickup". |
| disabled | boolean | false | Disables dragging, wheel and keys. |
| className | string | — | Extra classes on the card. |
Add it to your project
- 1
Prepare your project
You need Tailwind CSS and the
@/import alias. If shadcn isn't set up yet, initialise it once:npx shadcn@latest init
Then add the Nexus registry to your
components.json(theregistrieskey is the part that matters):{ "$schema": "https://ui.shadcn.com/schema.json", "style": "default", "rsc": true, "tsx": true, "tailwind": { "css": "src/app/globals.css", "baseColor": "neutral", "cssVariables": true, "prefix": "" }, "aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", "hooks": "@/hooks" }, "registries": { "@nexus-labs": "https://www.nexus-ui.com/api/registry/{name}" } } - 2
Add the component
Run this from your project root. It adds the component, the utilities it uses and its packages.
npx shadcn@latest add @nexus-labs/time-scrubber
- 3
Check what was added
With the standard aliases, these files land in your project:
components/time-scrubber/index.tstime-scrubber.tsx - 4
Copying by hand? Install the packages
Skip this if you used the command above.
npm install framer-motion
- 5
Use it in a page
Import it and render it. The Code tab above has the full example.
// app/page.tsx import { TimeScrubber } from "@/components/time-scrubber"; export default function Page() { return ( <main> <TimeScrubber /> </main> ); }