# M animated number 2

> Upload progress — percentage label animates alongside a CSS progress bar

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/m-animated-number-2).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/m-animated-number-2
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/cnippet/m-animated-number-2-light-6a5442b5e080c822.png
- Registry item: https://ui.cnippet.dev/r/m-animated-number-2.json
- Categories: animated number
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ui.cnippet.dev/r/m-animated-number-2.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@cnippet/animated-number`

## Files

### `registry/default/motion-variants/m-animated-number-2.tsx`

```tsx
"use client";

import { useState } from "react";
import { AnimatedNumber } from "@/registry/default/motion/animated-number";

const snapValues = [0, 25, 50, 75, 100];

export default function AnimatedNumberProgress() {
  const [progress, setProgress] = useState(0);

  return (
    <div className="flex min-h-50 flex-col items-center justify-center gap-6 px-6">
      <div className="w-full max-w-xs">
        <div className="mb-2 flex items-end justify-between">
          <p className="text-muted-foreground text-sm">Upload progress</p>
          <p className="font-bold text-foreground text-xl tabular-nums">
            <AnimatedNumber
              springOptions={{ damping: 25, stiffness: 150 }}
              value={progress}
            />
            %
          </p>
        </div>
        <div className="h-2 w-full overflow-hidden rounded-full bg-accent">
          <div
            className="h-full rounded-full bg-primary transition-all duration-500"
            style={{ width: `${progress}%` }}
          />
        </div>
      </div>
      <div className="flex gap-2">
        {snapValues.map((v) => (
          <button
            className={`rounded-md px-3 py-1.5 font-medium text-xs transition-colors ${
              v === progress
                ? "bg-foreground text-background"
                : "bg-accent text-muted-foreground hover:text-foreground"
            }`}
            key={v}
            onClick={() => setProgress(v)}
            type="button"
          >
            {v}%
          </button>
        ))}
      </div>
    </div>
  );
}
```
