Skip to content
caliper ui docs

Components

Animated counter

A number that counts to its value, with prefix, suffix and locale.

Free
pnpm dlx shadcn@latest add @caliper/animated-counter

Customers

Paying workspaces across every plan

Customers12,840+

Installs components/ui/animated-counter.tsxDepends on none beyond ReactMotion honours reduced motion

When to use

Use it for

  • Hero figures that should feel alive when they appear.
  • Values that update in place.

Skip it when

  • Numbers that change often; the motion becomes noise.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/animated-counter

Adds its 3 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

This is the code behind the preview above.

example.tsx
import { useState, type ReactNode } from "react"
import { AnimatedCounter } from "@/components/ui/animated-counter"
import { SegmentedControl } from "@/components/ui/segmented-control"
import { cn } from "@/components/ui/lib/cn"

function Panel({ title, context, action, className, children }: { title: string; context: string; action?: ReactNode; className?: string; children: ReactNode }) {
  return (
    <section className={cn("grid w-full max-w-md min-w-0 gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting", className)}>
      <div className="flex flex-wrap items-start justify-between gap-3">
        <div className="grid min-w-0 gap-1">
          <p className="font-medium">{title}</p>
          <p className="text-sm text-muted-foreground">{context}</p>
        </div>
        {action}
      </div>
      {children}
    </section>
  );
}

const customerRanges = [
  { value: "month", label: "This month" },
  { value: "year", label: "This year" },
  { value: "all", label: "All time" },
];

const customerCounts: Record<string, { value: number; context: string }> = {
  month: { value: 412, context: "New paying workspaces since 1 October" },
  year: { value: 3960, context: "New paying workspaces in 2026" },
  all: { value: 12840, context: "Paying workspaces across every plan" },
};

export function CustomerCount() {
  const [range, setRange] = useState("all");
  return (
    <Panel title="Customers" context={customerCounts[range]!.context} className="max-w-sm">
      <p className="text-4xl font-semibold tracking-tight">
        <AnimatedCounter value={customerCounts[range]!.value} label="Customers" suffix={range === "all" ? "+" : ""} />
      </p>
      <SegmentedControl label="Range" value={range} onValueChange={setRange} options={customerRanges} />
    </Panel>
  );
}

API reference

AnimatedCounter

component
PropTypeDefault
value *number—
labelstring—
prefixstring""
suffixstring""
decimalsnumber0
localestring"en-US"
animateOnViewbooleanfalse
classNamestring—

Accessibility

It is built on native elements and keeps aria-hidden in step with state.

No custom key handling; Tab and the native activation keys do the work.

Motion

It checks prefers-reduced-motion itself and settles immediately instead of travelling. Every state is still reachable.

All Core charts examples