Counter Number

PreviousNext

An animated numeric display component with smooth counting, formatting, sizes, and semantic color variants.

counter-number-default

counter-number-percentage

counter-number-currency

counter-number-decimal

counter-number-prefix

counter-number-seperator

counter-number-custom

Installation

pnpm dlx shadcn@latest add https://ui.dalim.in/r/styles/default/counter-number.json

Usage

import { CounterNumber } from "@/components/ui/counter-number"
<div className="flex flex-wrap gap-8 items-end">
  {/* Default */}
  <CounterNumber value={12345} />
 
  {/* With prefix/suffix */}
  <CounterNumber value={86} suffix="%" size="xl" color="success" />
 
  {/* Decimals */}
  <CounterNumber value={3.14159} decimalPlaces={3} size="lg" />
 
  {/* Currency */}
  <CounterNumber value={1299.99} currency="USD" decimalPlaces={2} size="xl" color="primary" />
 
  {/* Locale + separator */}
  <CounterNumber value={1000000} locale="de-DE" separator="." size="lg" />
 
  {/* Mono spacing for layout stability */}
  <CounterNumber value={2025} preserveAspectRatio className="font-medium" />
</div>

API Reference

CounterNumber

Animated number display with formatting options.

PropTypeDefaultDescription
valuenumberRequired. Final value to animate to.
startValuenumber0Starting value before animation begins.
durationnumber1000Animation duration in milliseconds.
decimalPlacesnumber0Number of fractional digits to display.
prefixstring""String shown before the number.
suffixstring""String shown after the number.
separatorstring","Thousands separator override (applied after locale formatting).
currencystring (ISO 4217)Formats number as currency (e.g., "USD", "INR").
localestring"en-US"Locale code (BCP 47) for Intl.NumberFormat.
size"sm" | "md" | "lg" | "xl" | "2xl""md"Visual size variant.
color"default" | "primary" | "secondary" | "success" | "warning" | "error""default"Color/text variant.
preserveAspectRatiobooleanfalseUses monospaced digits (font-mono) to reduce layout shift.
classNamestring""Additional Tailwind/CSS classes applied to the <span>.