Skip to content
Cloaked Design SystemPrimitives

AnimatedNumber

A numeric readout that moves from its previous value to a new target while keeping the settled value accessible.

Implementation preview
COMPLETE STORYBOOK REFERENCE

Every example. In one place.

Explore every named example, including states, compositions, and theme variants.

4 stories
SELECTED EXAMPLE

Playground

Open controls
Playground selectedOpen canvas
Example sourcepackages/design-system/src/components/primitives/AnimatedNumber/AnimatedNumber.stories.tsxExport Playground

Implementation preview Local Storybook build 0.2.0-preview.1. Source specification status does not approve this runtime.

Stories + source JSON ↗

Local specification source status: preview. Implementation preview pending sign-off.

A numeric readout that moves from its previous value to a new target while keeping the settled value accessible.

Design-owned component contract ↗Version 0.2.0-preview.1 · Implementation preview pending sign-off
Implementation API 1 entry point · source-derived preview

Read the actual callable API and preserve its composition constraints. Each union branch is a complete alternative; props marked forbidden cannot be supplied.

import { AnimatedNumber } from '@cloakedinc/design-system';
AnimatedNumberAnimatedNumberProps

packages/design-system/src/components/primitives/AnimatedNumber/AnimatedNumber.tsx:51

PropTypePresenceNotes
valuenumberRequiredTarget value to display; a change from the current value animates toward it.
followboolean | undefinedOptionalContinuously ease toward `value` every frame instead of running a fixed tween per change. Use this while a chart is being scrubbed: `value` changes on every pointer move, and a per-change tween would restart faster than it can advance (the number would freeze). Follow mode glides smoothly toward the finger and settles when scrubbing stops.Source default: false
durationnumber | undefinedOptionalFixed tween duration in milliseconds for discrete changes. Omit to let the duration scale with how large the jump is, so small changes settle quickly and big ones feel weightier. Ignored while `follow` is true.
format((value: number) => string) | undefinedOptionalFormats the numeric value for display; defaults to locale digit grouping.Source default: formatNumber
testIdstring | undefinedOptionalSelector on the `<span>`. Its text is a mid-animation frame; `aria-label` holds the settled value.

Only explicit destructured parameter initializers are extracted. Other runtime defaults remain in implementation source.

Overview

A number that counts from its previous value to its new one whenever value changes, with a physical ease-in-out ramp. It owns only the animation and formatting — wrap it in a Text (or Card.Metric) for typography and color.

When to use

Reach for AnimatedNumber when a numeric readout changes and the motion carries meaning — a stat that ticks up as work completes, a counter reacting to user action, or a value scrubbed along a chart. In-app it backs the Home stat widgets (ActionsTakenWidget, BlockedSpamCallsWidget, SsnMonitoringWidget) and the automations StatsRow.

  • Rendering a static number that never animates? Just put it in Text — the tween is wasted (and AnimatedNumber deliberately does not animate on mount, so a value that never changes looks identical to plain text anyway).
  • Value updates every frame while a chart is scrubbed? Set follow so it glides toward the moving target instead of restarting a discrete tween on each change.

It animates in either direction and snaps instead of animating under prefers-reduced-motion.

Component specification

$schema../../../specs/component-spec.schema.json
Parts
Id
readout
Label
Readout
Description
Displays each formatted frame and carries the settled target as its accessible name.
Allowed Design Choices
Variants
Base
Label
Base
Description
The component owns number motion and formatting; its parent owns typography and color.
Sizes
Variants
Id
base
Label
Base
Description
A typography-neutral animated numeric readout.
Platforms
  • ios
  • android
  • web
SizesNone specified
Measurements
Id
display-example-type-size
Label
Display example type size
Kind
exact
Token
--cds-type-display-1-size
Value
72
Unit
px
Applies To
  • readout
  • display-example
Notes
The primary Storybook example composes AnimatedNumber inside Text display-1; consumers may choose another Text variant.
Id
intrinsic-width
Label
Readout width
Kind
automatic
Applies To
  • readout
Notes
Width follows the formatted frame and is not reserved to the target string.
Layout
Alignment
The inline readout follows its parent text baseline.
Flow
One formatted number occupies the parent typography run.
Notes
  • Compose the readout inside Text or Card.Metric; AnimatedNumber does not establish a text hierarchy.
Typography And Color
Typography
Label
Example metric
Description
The documented metric example uses the largest display ramp.
Token
--cds-type-display-1-size
Colors
Label
Example foreground
Description
The documented metric example uses the primary text role.
Token
--cds-text-primary
States
Id
resting
Label
Resting
Description
Shows the target immediately on mount and after motion settles.
Id
animating
Label
Animating
Description
Runs one eased tween from the current display to a discrete target.
Id
following
Label
Following
Description
Continuously glides toward rapidly changing targets during chart scrubbing.
Id
reduced-motion
Label
Reduced motion
Description
Snaps directly to each target without intermediate frames.
Behavior
Label
Discrete changes
Description
Scale duration with the magnitude of the change unless an explicit duration is supplied.
Label
Rapid changes
Description
Use follow mode for pointer-driven values so repeated updates do not restart a fixed tween.
Label
Formatting
Description
Apply the formatter to both the visible frame and the settled accessible value.
Accessibility
Label
Settled value
Description
Expose the target as the accessible name so assistive technology never announces intermediate frames.
Label
No live-region churn
Description
Do not announce every animation frame; a surrounding live region may announce a meaningful completed update.
Content Adaptation
Label
Number formats
Description
Accept locale grouping, currency, percentages, and other deterministic numeric formatters.
Label
Changing width
Description
Allow enough parent space for the longest expected formatted value to avoid adjacent layout jumps.
Motion Haptics
Motion
Label
Counter motion
Description
Accelerate from rest and coast into the target for discrete changes; follow mode stays responsive to scrubbing.
Label
Reduced motion
Description
Honor the platform reduced-motion preference by removing the tween.
Haptics
Label
No feedback
Description
The readout is not interactive and does not request haptic feedback.
Platform DifferencesNone specified
Implementation preview

This design-owned implementation is ready to try and review. It does not establish product approval. Imported specifications retain their original review status.

Inspect version 0.2.0-preview.1