Default
Counts from 0 to the target over two seconds.
<CountUp endVal={5234} />Solid component
A Solid component that animates a number from one value to another. It renders a span, follows your props reactively, and formats through Intl.NumberFormat.
Started with autoAnimate — the count begins once it scrolls into view.
pnpm add solid-countupEach counter animates as it scrolls into view, using autoAnimate. Formatting is delegated to Intl.NumberFormat, so currency, percent, compact, signing, non-Latin digits and RTL all come for free.
Counts from 0 to the target over two seconds.
<CountUp endVal={5234} />Wrap the number in literal text.
<CountUp endVal={5234} prefix="$" suffix=" USD" />startVal is where the animation begins.
<CountUp startVal={5234} endVal={0} />duration={0} writes the target with no animation.
<CountUp endVal={5234} duration={0} />Round to a fixed number of digits.
<CountUp endVal={1234.567} decimalPlaces={2} />Format through Intl with a currency style.
<CountUp
endVal={1234.5}
decimalPlaces={2}
locale="en-US"
intlNumberFormatConfig={{ style: 'currency', currency: 'USD' }}
/>Percent formatting multiplies the value by 100.
<CountUp
endVal={0.856}
decimalPlaces={2}
intlNumberFormatConfig={{ style: 'percent' }}
/>Abbreviate large numbers.
<CountUp
endVal={1_200_000}
decimalPlaces={1}
intlNumberFormatConfig={{ notation: 'compact' }}
/>intlNumberFormatConfig.signDisplay forces the sign.
<CountUp
endVal={1234}
intlNumberFormatConfig={{ signDisplay: 'always' }}
/>Use a locale's numbering system.
<CountUp endVal={1234567} locale="hi-IN-u-nu-deva" />Arabic-Indic digits and separators, straight from Intl.
<CountUp endVal={1234} locale="ar-EG" />Override the grouping and decimal glyphs.
<CountUp
endVal={1234567.89}
decimalPlaces={2}
separator=" "
decimal=","
/>Disable easing for a constant rate.
<CountUp endVal={5234} useEasing={false} />formattingFn returns your own markup, one node per glyph.
<CountUp
endVal={5234}
formattingFn={value => (
<span class="digits">
{new Intl.NumberFormat().format(value).split('').map(d => (
<span>{d}</span>
))}
</span>
)}
/>class, id, role and aria-* land on the span.
<CountUp endVal={5234} class="stat" role="status" aria-live="off" />Share defaults across counters with CountUpDefaults.
<CountUpDefaults value={{ duration: 1.2, suffix: '%' }}>
<CountUp endVal={42} />
<CountUp endVal={87} />
</CountUpDefaults>onStart, onFrame and onComplete report progress as it happens. onFrame is the one CountUp.js has no equivalent for.
Press Start to fire the callbacks.
onFrame(value, progress) fires every frame — here it feeds the bar.
Respecting prefers-reduced-motion is the default. A skipped animation jumps straight to the target and still fires onComplete.
Your system prefers … motion. “always” jumps straight to the target, “never” always animates, and “user” follows that setting.
Change the props, then drive the animation with the control handle.
On the server the component renders the final value — no flash of 0, no hydration mismatch, no layout shift. The count-up begins on the client.
import { renderToString } from 'solid-js/web'
renderToString(() => <CountUp endVal={5234} />)
// '<span aria-live="off">5,234</span>'