jbmui

Counter

  • Motion
  • replayable
  • video player

Number that counts up to a target.

Loading preview…

Install

npx shadcn@latest add @jbm/counter

Needs 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

Count to a key number
import { Counter } from "@/jbm/motion/counter"<Counter n={1024} at={0.2} dur={1.5} />
Smaller, in ink, beside other text
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.

PropTypeDefaultDescription
nnumberrequiredTarget value; the count ends here and holds.
atnumberrequiredStart time in seconds from the start of the sequence.
durnumber0.8Seconds the count takes to reach n.
sizenumber140Font size in stage pixels, passed to Big.
colorstringcolor.accentText 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 exactly n at rest.
  • In a host composition, check the widest value of n stays 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.