SwipeUI

Animated counter

UI-thread numeric interpolation with serializable locale formatting and final-value accessibility.

npx @swipeui/cli add animated-counter
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Dashboards where a number counts up when it appears or changes, such as revenue or followers.
  • Celebratory totals after finishing a workout or a level.
  • Numbers with decimals and grouping that should animate smoothly.

When not to use it

  • Exact money or IDs that must never show in-between values. Use Slot text.
  • Static numbers. Use Text.
  • Countdowns to a time. Use Countdown.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add animated-counter
  • Adds components/swipeui/ui/counter-format.ts, components/swipeui/ui/animated-counter.tsx and 2 shared helpers.
  • Installs react-native-reanimated, uniwind, react-native-worklets, clsx, tailwind-merge. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/balance.tsx
import { AnimatedCounter } from '@/components/swipeui/ui/animated-counter';

<AnimatedCounter value={1240.5} format="currency" currency="USD" precision={2} label="Balance" />;

Examples

integer counts steps, decimal logs a walk, and currency adds funds to a balance. The app and website share these named boards, with actions and Reset outside the card.

Settings

SettingDefaultBehavior
valuerequiredFinite target within the safe numeric range.
precision0Decimal places from 0 to 6; applies to every format.
format'decimal''decimal', 'compact', 'percent' or 'currency'. Compact counts within the same locale unit; a unit change holds the previous display and snaps at the end. Percent takes a fraction (0.25 is 25%).
currencyabsentISO code such as USD or EUR; required for currency format.
prefix''Text before the formatted number, also spoken.
suffix''Text after the formatted number, also spoken.
localedevice localeLocale for digits, separators, signs and affix positions.
useGroupingtrueLocale grouping.
labelabsentSpoken purpose: label, colon, prefix, formatted target and suffix.
motionapp feelShared number transition; Reduce Motion jumps to the target.
classNameabsentRoot classes.
textClassName'font-mono text-title-1'Number style classes. Native ink defaults to the scheme's foreground token; an explicit colour class overrides it.
styleabsentNative root layout escape hatch.
testIDabsentRoot ID; the read-only value appends -value.

Formatting

Locale parts are resolved on the JS thread once per target. Serializable digits, separators, scale and affixes format the intermediate values on the UI thread, without calling Intl per frame. The existing formatter fallback for engines without formatToParts remains supported.

For exact balances that must never show intermediate amounts, use Slot text. This counter shows an approximate animated journey to the exact formatted target.

Accessibility

One accessible element reports the final target with the prefix and suffix. The read-only animated text is hidden from assistive technology. Native screen-reader, Dynamic Type and performance checks remain pending at 7.9.

Behavior and gestures

  • Decimal, compact, percent and currency targets use locale parts resolved once on JS; frames format on UI.
  • prefix and suffix appear in both the text and spoken target.
  • Compact unit changes hold the previous display and snap at completion; counts within a unit remain continuous.

Accessibility

  • Screen readers hear only the final number, never the in-between frames.
  • Add label so the number has context, for example "Steps today: 8,240".
  • Formatting follows the device locale unless you set one.

Motion

  • Uses the number motion role, so it follows your app's feel. Pass motion to tune this one instance.
  • Counting uses the number role on the UI thread.
  • Reduce Motion jumps straight to the final value.

Performance

  • Text updates happen on the UI thread without React re-renders.

Notes for AI

  • Pass a number for value; set precision for decimals.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items