NK

Search

Search pages, posts, and components

All components

Animated Counter

Data Display

Number that counts up to its value on mount.

0

Installation

Add it with the shadcn CLI:

$pnpm dlx shadcn@latest add https://nawalkattel.com.np/r/animated-counter.json
Or install manually
  1. 1. Install dependencies

    pnpm add motion clsx tailwind-merge
  2. 2. Copy the component source into components/library/animated-counter.tsx

Props

PropTypeDefaultDescription
valuenumber - Number to count up to.
durationnumber1.4Seconds to reach the value.

Accessibility

  • Renders the final value immediately under prefers-reduced-motion.
  • Uses tabular numerals so the width doesn't jitter while counting.

Dependencies

motionclsxtailwind-merge