The heading's number sits in a marble in a notch: closing a task rolls it away and the new count rolls in, drops into the notch and squashes.
Press mePress me
Getting started · Workspace setup
You have 444 open tasks
Finish setting up to unlock shared projects and billing for your team.
Verify your email address1 min
Name your workspace1 min
Connect a custom domain10 min
Invite two teammates2 min
Import your contacts5 min
Set up billing3 min
count-marble · , lively
count-marble-demo.tsx
When to use
Use for a heading that counts open work the person closes right below it. Holding a checkbox lifts the marble and the new number rolls in; remote changes crossfade.
When not to use
Not for a figure inside a table or a dashboard metric: use Number Ticker. Not for counts nobody changes from the same screen.
Use Count Marble for a heading that counts open work the person is closing right below it: an onboarding checklist, an inbox to triage, a sprint's done count. The number rests in a marble sunk in a notch of the heading's rule. While the person holds a checkbox, the marble lifts out of the notch; when the count changes it rolls away and the new number rolls in, drops into the notch and squashes, so the heading confirms the work and its direction. A change the person did not make (a teammate, a sync) crossfades in place. For a figure in a table or a dashboard metric, use a number ticker instead.
import { CountMarble, CountMarbleGroup, CountMarbleTrigger, CountMarbleValue,} from "@/components/ui/count-marble"export function Checklist({ tasks, toggle }) { const open = tasks.filter((t) => !t.done).length return ( <CountMarbleGroup> <CountMarble count={open} className="text-3xl font-semibold"> You have <CountMarbleValue /> open tasks </CountMarble> {tasks.map((task) => ( <CountMarbleTrigger key={task.id} role="checkbox" aria-checked={task.done} onClick={() => toggle(task.id)} > {task.title} </CountMarbleTrigger> ))} </CountMarbleGroup> )}
CountMarble is the heading (as picks h1 to h4 or p); put one CountMarbleValue in its text where the number goes. count is your state: the marble rolls when it changes. Pass cause="remote" for a change the person did not cause (it crossfades). CountMarbleTrigger marks the controls that change the count, so holding one lifts the marble; with asChild it merges onto your own checkbox or Button and keeps their handlers. A heading outside a CountMarbleGroup still rolls, without the lift.
Presets: shelf (default, the rule runs under the whole heading), inline (a short shelf under the marble only, for card titles and toolbars) and tally (more rolls the old marble out to the left, for counts that grow as progress). rule and direction override the preset; marble replaces the ball with any shape. The words keep a thin edge in the page colour so a passing marble never covers them: on a card, set [--count-marble-surface:var(--card)] on the heading. intro rolls the marble in once when the heading first scrolls into view.
Set the character for the whole app with MotionKitProvider, or per instance with temperament (calm, lively, playful). It changes motion intensity only, never the drawing.
The heading reads as plain text ("You have 4 open tasks"): the marbles are aria-hidden and CountMarbleValue carries the current number as visually hidden text.
After each change a polite live region speaks the heading's new text; nothing is announced on load.
Triggers keep their own role and name (checkbox, button). Holding Space lifts the marble and releasing commits; Enter commits at once. A disabled trigger never lifts the marble.
The digit is primary-foreground on primary, the theme's own contrast pair; the words keep their colour at every frame.
No lift, roll or squash: the digit crossfades inside the still marble in the fade time, and the intro does not run (the marble is simply in its notch).