solid-countup

Solid component

Count up to a number, declaratively.

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.

3,847,291

Started with autoAnimate — the count begins once it scrolls into view.

$pnpm add solid-countup

Formatting and locales

Each 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.

5,234

Default

Counts from 0 to the target over two seconds.

<CountUp endVal={5234} />
$5,234 USD

Prefix and suffix

Wrap the number in literal text.

<CountUp endVal={5234} prefix="$" suffix=" USD" />
0

Count down

startVal is where the animation begins.

<CountUp startVal={5234} endVal={0} />
5,234

Instant

duration={0} writes the target with no animation.

<CountUp endVal={5234} duration={0} />
1,234.57

Decimal places

Round to a fixed number of digits.

<CountUp endVal={1234.567} decimalPlaces={2} />
$1,234.50

Currency

Format through Intl with a currency style.

<CountUp
  endVal={1234.5}
  decimalPlaces={2}
  locale="en-US"
  intlNumberFormatConfig={{ style: 'currency', currency: 'USD' }}
/>
85.60%

Percent

Percent formatting multiplies the value by 100.

<CountUp
  endVal={0.856}
  decimalPlaces={2}
  intlNumberFormatConfig={{ style: 'percent' }}
/>
1.2M

Compact notation

Abbreviate large numbers.

<CountUp
  endVal={1_200_000}
  decimalPlaces={1}
  intlNumberFormatConfig={{ notation: 'compact' }}
/>
+1,234

Signed

intlNumberFormatConfig.signDisplay forces the sign.

<CountUp
  endVal={1234}
  intlNumberFormatConfig={{ signDisplay: 'always' }}
/>
१२,३४,५६७

Localised digits

Use a locale's numbering system.

<CountUp endVal={1234567} locale="hi-IN-u-nu-deva" />
١٬٢٣٤

Right-to-left numerals

Arabic-Indic digits and separators, straight from Intl.

<CountUp endVal={1234} locale="ar-EG" />
1 234 567,89

Custom separators

Override the grouping and decimal glyphs.

<CountUp
  endVal={1234567.89}
  decimalPlaces={2}
  separator=" "
  decimal=","
/>
5,234

Linear

Disable easing for a constant rate.

<CountUp endVal={5234} useEasing={false} />
5,234

Custom rendering

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>
  )}
/>
5,234

Attribute passthrough

class, id, role and aria-* land on the span.

<CountUp endVal={5234} class="stat" role="status" aria-live="off" />
42%87%

App-wide defaults

Share defaults across counters with CountUpDefaults.

<CountUpDefaults value={{ duration: 1.2, suffix: '%' }}>
  <CountUp endVal={42} />
  <CountUp endVal={87} />
</CountUpDefaults>

Callbacks

onStart, onFrame and onComplete report progress as it happens. onFrame is the one CountUp.js has no equivalent for.

98,420

Callbacks

Press Start to fire the callbacks.

onFrame(value, progress) fires every frame — here it feeds the bar.

Reduced motion

Respecting prefers-reduced-motion is the default. A skipped animation jumps straight to the target and still fires onComplete.

reducedMotion="never"5,234
reducedMotion="always"5,234
reducedMotion="user"5,234

Your system prefers … motion. “always” jumps straight to the target, “never” always animates, and “user” follows that setting.

Playground

Change the props, then drive the animation with the control handle.

1,234.00

Server rendering

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>'