Skip to content

CountUp

Open .md
Live preview

Loading example…

A number that counts to value over 1.5 --motion-durations with --motion-ease, on a client mount and on every change. Server HTML, hydration and reduced motion show the final value at once. While it counts, assistive tech reads only the final value and the final text reserves its width, so the line does not grow digit by digit. Works as the value of a Kpi.

import { CountUp } from "@jcsoftdev/ui/motion";
export const RevealOnMount: Story = {
render: () => (
<Replay>
{() => (
<Reveal>
<Card className="max-w-sm p-card">Welcome back. Three tasks are waiting for you.</Card>
</Reveal>
)}
</Replay>
),
};

Source of the Storybook story.

Prop Type Default Description
value * number
formatter NumberFormatter Formats every shown value. Defaults to Intl.NumberFormat in the UI strings locale.
from number 0 Where a client-side mount starts counting from. Default 0.
ref Ref<HTMLSpanElement>

* marks a required prop.

It also accepts the native props of the element or primitive it renders (for example className, id, aria-* and event handlers).

packages/ui/src/motion/count-up.tsx