Counter
Number that counts up to a target.
Loading preview…
Install
npx shadcn@latest add @jbm/counterNeeds the @jbm entry in components.json; see Install once.
Also installs @jbm/big, @jbm/motion-hooks.
Needs Remotion: render inside a Remotion <Composition> or <Player>, not a plain React tree. Timing values are in seconds.
Usage
import { Counter } from "@/jbm/motion/counter"<Counter n={1024} at={0.2} dur={1.5} />import { Counter } from "@/jbm/motion/counter"import { color } from "@/jbm/lib/tokens"<Counter n={42} at={1} size={96} color={color.ink} />// Render inside a Remotion <Composition> or <Player>.Props
- Stage px
- Declared at the documented defaults
- Landscape
auto by 147- Vertical
auto by 147- Basis
One line of Big at size 140 with line-height 1.05. Height is size × 1.05; width follows the digit count of
n(about 0.6 × size per digit).
Renders a Big numeral that eases from 0 to n, rounded to whole numbers, on the Remotion timeline.
| Prop | Type | Default | Description |
|---|---|---|---|
n | number | required | Target value; the count ends here and holds. |
at | number | required | Start time in seconds from the start of the sequence. |
dur | number | 0.8 | Seconds the count takes to reach n. |
size | number | 140 | Font size in stage pixels, passed to Big. |
color | string | color.accent | Text color; keep the one vermilion accent per composition. |
QA checks
- Step to the first, middle, and last frames: 0 before
at, an intermediate whole number mid-count, and exactlynat rest. - In a host composition, check the widest value of
nstays inside the safe area at the chosen size in both orientations (the gallery bench previews landscape only). - Confirm only one element on the stage uses the accent color.