GodUI

Number Ticker

Animates a number to its target value with spring physics when scrolled into view.

0

Installation

pnpm dlx shadcn@latest add "https://godui.design/r/number-ticker.json"

NumberTicker animates only once, when it scrolls into view. It renders tabular-nums so the width stays stable while the digits change.

Usage

tsx
 
import { NumberTicker } from "@/components/godui/number-ticker";

NumberTicker is an inline <span> that inherits the surrounding font size, weight, and color. Style the element directly:

tsx
 
<NumberTicker value={100} className="text-6xl font-bold tracking-tight" />

Decimal places

tsx
 
<NumberTicker value={1984.42} decimalPlaces={2} />

Count down

Set direction="down" to count from value to startValue.

tsx
 
<NumberTicker value={100} direction="down" />

Delay

delay is in seconds and starts once the element is in view.

tsx
 
<NumberTicker value={5000} delay={0.5} />

Props

PropTypeDefaultDescription
valuenumberTarget value the ticker animates to (or from, when counting down).
startValuenumber0Value the counter starts at.
direction"up" | "down""up""up" counts toward value; "down" counts from value.
delaynumber0Delay in seconds before the animation begins once in view.
decimalPlacesnumber0Number of decimal places to render.
dampingnumber60Spring damping — higher is less bouncy.
stiffnessnumber100Spring stiffness — higher is faster.

NumberTicker also forwards every standard <span> attribute (className, style, id, …) to the root element.

On this page

Built with GodUI

Beautifully crafted motion components for modern interfaces.

Star on GitHub