UIPin
ComponentsIconsIllustrationsMotionTemplatesApps
Boards
UIPin

Free, open-source UI components, icons, illustrations, motion, templates and apps, in one search. Every item links to its source and licence.

UIPin is free. If it saved you time, you can keep it running:

Buy me a coffee
ComponentsIconsIllustrationsMotionTemplatesAppsLibrariesCompareNew this weekMCP for agentsBoardsPrivacy

Components, icons and artwork belong to their authors and are shown under their open-source licences.

Motion Primitives/Animated Number

Text effects
1 of 5
Compiling

Theme it

Every preview, live

Brand colour

Corner radius

Font

Recolours shadcn’s tokens, Tailwind’s accent colours and colours set in the code. Red, amber and green classes stay, since they usually mean error, warning or success.

5 versions·4 librariesCompare all number animations →

  • Animated Number
  • Cult UI
  • HextaUI
  • Magic UI
  • Sliding Number

Animated Number

A component that animates number changes with smooth transitions.

npx shadcn@latest add https://motion-primitives.com/c/animated-number.json
Open in v0 Docs Repo
Library
Motion Primitives
License
MIT
Stack
React · Tailwind CSS · animated
Packages
motion
Size
36 lines
Demo
Written by UIPin: the library doesn’t ship a usage example, so the preview uses one of ours (in the code below).

Code

animated-number.tsx

'use client';
import { cn } from '@/lib/utils';
import { motion, SpringOptions, useSpring, useTransform } from 'motion/react';
import { useEffect } from 'react';

export type AnimatedNumberProps = {
  value: number;
  className?: string;
  springOptions?: SpringOptions;
  as?: React.ElementType;
};

export function AnimatedNumber({
  value,
  className,
  springOptions,
  as = 'span',
}: AnimatedNumberProps) {
  const MotionComponent = motion.create(as as keyof JSX.IntrinsicElements);

  const spring = useSpring(value, springOptions);
  const display = useTransform(spring, (current) =>
    Math.round(current).toLocaleString()
  );

  useEffect(() => {
    spring.set(value);
  }, [spring, value]);

  return (
    <MotionComponent className={cn('tabular-nums', className)}>
      {display}
    </MotionComponent>
  );
}

More like this

Count Up

React Bits·Text effectsMIT+

Chart

HextaUI·Data display

Bento Grid

Kokonut UI·Cards

Scroll Area

shadcn/ui·Data display

Smooth Tab

Kokonut UI·Navigation

Stats 2

SmoothUI·Data display

GitHub Stars Button

Animate UI·BackgroundsMIT+

Stats 1

SmoothUI·Data display

Input

shadcn/ui·Inputs & forms

Features 2

SmoothUI·Cards

Pagination

HextaUI·Navigation

Ai Prompt Input

SmoothUI·Inputs & forms

Textarea

shadcn/ui·Text effects

Carousel

HextaUI·Media & 3D

Magic Card

Magic UI·Cards