Number ticker
Count up to a number when it scrolls into view. Shows the final value at once for reduced motion.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- Built on native elements
- Screen readers get the final number from an sr-only copy; the animated frames are aria-hidden.
- With prefers-reduced-motion the final number shows immediately and nothing animates.
- Styles in one file:
number-ticker.css
Import
import '@monoline/css';
import {NumberTicker} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add number-ticker
Usage
import {NumberTicker} from '@monoline/react';
<p style={{fontFamily: 'var(--font-display)', fontSize: 'var(--display-sm)'}}>
<NumberTicker value={12840} />
</p>
Examples
Decimals and units
Props
NumberTickerProps
| Prop | Type | Default | Description |
|---|---|---|---|
value required | number | – | The number to count to. Screen readers get this, never the frames in between. |
from | number | 0 | Where the count starts. Default 0. |
duration | number | 1500 | Milliseconds for the count. Default 1500. |
decimals | number | 0 | Digits after the decimal point. Default 0. |
format | ((n: number) => string) | – | Custom formatting, for currency or units. Overrides `decimals`. |
Data Attributes
State is exposed through attributes. Style it with these selectors, not with class toggles.
This component sets no state attributes.
CSS classes
| Class | Stylesheet |
|---|---|
.number-ticker | number-ticker.css |
Customization
Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.
app.css
.number-ticker {
border-color: var(--accent);
}
Accessibility
- Screen readers get the final number from an sr-only copy; the animated frames are aria-hidden.
- With prefers-reduced-motion the final number shows immediately and nothing animates.