Components
Bead counter
A counter that works like an abacus wire. The count is how many beads have been slid to the right. Press a bead to slide it and every bead before it, and they clack across one after another, nearest first.
pnpm dlx shadcn@latest add @caliper/bead-counterWhen to use
Use it for
- Small counts: guests, seats, quantity, rating.
- Settings where the count should feel physical.
Skip it when
- Counts past twenty; use `NumberField`.
- Values that are not whole numbers.
Decisions
Why it is built this way, so you know what to keep when you change your copy.
Behaviour
- Nearest bead first
- Beads start in order from the boundary, 28 ms apart, so the move reads as a row of beads knocking.
Usage
- A slider with keys
- The wire is a slider: arrow keys change the count, Home and End go to the ends; pressing beads is an extra.
Installation
pnpm dlx shadcn@latest add @caliper/bead-counter
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
This is the code behind the preview above.
import { useState, type ReactNode } from "react" import { BeadCounter } from "@/components/ui/bead-counter" function Panel({ title, context, className = "max-w-md", children }: { title: string; context: string; className?: string; children: ReactNode }) { return ( <section className={`grid w-full gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting max-sm:p-4 ${className}`}> <div className="grid gap-1"> <p className="font-medium">{title}</p> <p className="text-sm text-muted-foreground">{context}</p> </div> {children} </section> ); } export function BeadCounterDemo() { const [guests, setGuests] = useState(3); return ( <Panel title="Table for" context="Slide the beads, or use the arrow keys."> <div className="grid justify-items-start gap-3"> <BeadCounter value={guests} onValueChange={setGuests} max={8} label="Guests" /> </div> <div className="flex items-center justify-between border-t border-border pt-4 text-sm"> <span className="text-muted-foreground">Reserving for</span> <span className="font-medium tabular-nums">{guests === 0 ? "no one yet" : guests === 1 ? "1 guest" : `${guests} guests`}</span> </div> </Panel> ); }
API reference
BeadCounter
component
Also accepts the native props of its root element and a ref.
Accessibility
It exposes slider semantics, with aria-label, aria-valuemin, aria-valuemax, aria-valuenow and aria-hidden kept in step with state.
No custom key handling; Tab and the native activation keys do the work.
Motion
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.