Number Ticker
A number that moves to its new value — counting, or each digit rolling — written in the reader’s language. No animation library: it runs frame by frame, and works on an SVG text too (a chart’s total).
Usage
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScButton, ScFrame } from '@semantic-components/ui';import { ScNumberTicker } from '@semantic-components/ui';
/** The number counts to its new value, easing out. Screen readers get only the value; with reduced motion, it is there at once. */@Component({ selector: 'app-number-ticker-usage-demo', imports: [ScFrame, ScNumberTicker, ScButton], template: ` <div scFrame class="bg-muted/30 grid h-32 w-64 place-items-center"> <span scNumberTicker [value]="count()" class="text-5xl font-bold"></span> </div> <div class="flex gap-2"> <button scButton (click)="count.set(count() + 100)">+100</button> <button scButton variant="secondary" (click)="count.set(0)">Reset</button> </div> `, host: { class: 'flex w-full flex-col items-center gap-4' }, encapsulation: ViewEncapsulation.None,})export class NumberTickerUsageDemo { private readonly count = signal(0);}Anatomy
One part, on the element that holds the number — a span, a heading, an SVG text. It writes the number; you style it.
import { ScNumberTicker } from '@semantic-components/ui';<span scNumberTicker [value]="…"></span>Accessibility
- Screen readers get the value, never the numbers on the way: a hidden text with it, the moving digits hidden from them — on an SVG text, an image named by it.
- A change isn't announced: put the ticker in a live region (an aria-live parent) if its new value must be heard.
- With reduced motion (prefers-reduced-motion), the new value is there at once; the digits don't roll.
Examples
Roll
effect="roll": each digit rolls to its new place, like an odometer — the separators and the currency stay still.
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScButton, ScFrame } from '@semantic-components/ui';import { ScNumberTicker } from '@semantic-components/ui';
/** effect="roll": each digit rolls to its new place, like an odometer — the separators and the currency stay still. */@Component({ selector: 'app-roll-number-ticker-demo', imports: [ScFrame, ScNumberTicker, ScButton], template: ` <div scFrame class="bg-muted/30 grid h-32 w-72 place-items-center">Formats
Any Intl.NumberFormat options, in LOCALE_ID — provided here as German: euros, a percent, compact.
Umsatz
Anteil
Aufrufe
import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import { ScButton, ScFrame } from '@semantic-components/ui';import { ScNumberTicker } from '@semantic-components/ui';
/** Any Intl.NumberFormat options, in LOCALE_ID — provided here as German: euros, a percent, compact. */@Component({ selector: 'app-formats-number-ticker-demo', imports: [ScFrame, ScNumberTicker, ScButton], template: ` <div class="grid w-full max-w-lg grid-cols-3 gap-3 text-center">When seen
start="visible": landing-page figures that count up from zero when they are first scrolled into view.
Scroll down: the figures count up when they come into view.
- Customers
- 12,500
- Countries
- 48
- Uptime
- 99.95%
import { Component, ViewEncapsulation } from '@angular/core';import { ScFrame, ScNumberTicker } from '@semantic-components/ui';
/** start="visible": landing-page figures that count up from zero when they are first scrolled into view. */@Component({ selector: 'app-visible-number-ticker-demo', imports: [ScFrame, ScNumberTicker], template: ` <div scFrameIn a stat card
In the stat card’s value: the figure moves to its new value as the data comes in.
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScButton, ScCard, ScCardBody, ScNumberTicker,} from '@semantic-components/ui';
/** In a stat card (the recipe): the figure moves to its new value as the data comes in. */@Component({In a chart’s center
On an SVG text — a donut’s total counting up as the donut sweeps in: start, delay, duration and easing as the chart’s series.
import { Component, ViewEncapsulation } from '@angular/core';import { ScNumberTicker } from '@semantic-components/ui';import { ScChart, ScChartCenter, type ScChartConfig, ScChartPie, ScChartPlot,} from '@semantic-components/ui/charts';RTL
In a right-to-left page: Arabic digits (ar-EG), each rolling to its place.
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import { ScButton, ScNumberTicker } from '@semantic-components/ui';
/** In a right-to-left page: Arabic digits (ar-EG), rolling. */@Component({ selector: 'app-rtl-number-ticker-demo', imports: [Dir, ScButton, ScNumberTicker], template: ` <div dir="rtl" lang="ar" class="flex flex-col items-center gap-4">API reference
| Input | Type | Default | Description |
|---|---|---|---|
value | number | — | The number (required): a new one is moved to. |
effect | 'count' | 'roll' | 'count' | Counting to it, or each digit rolling (an odometer; on HTML only). |
format | Intl.NumberFormatOptions | {} | How it is written — currency, percent, compact, a unit, decimals — in LOCALE_ID. |
duration | number | 1000 | How long a change takes, in ms. |
delay | number | 0 | The wait before it moves, in ms (a chart’s: its series’). |
easing | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' | 'ease-out' | How it moves: CSS’s timing names. |
from | number | 0 | Where the first move starts from. |
start | 'now' | 'visible' | 'now' | When the first move starts: at once, or when it is first seen. |
class | string | '' | Merged over its own classes. |