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.

Cult UI/Rolling 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 →

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

Rolling Number

Number component with smooth counting animations and customizable formatting

npx shadcn@latest add https://cult-ui.com/r/rolling-number.json
Open in v0 Docs Repo
Library
Cult UI
License
MIT
Stack
React · Tailwind CSS · animated · radix
Packages
@radix-ui/react-slotclass-variance-authoritycnmotionradix-ui
Also adds
button, slider, gradient-heading, texture-card
Size
43 lines
Demo
From Cult UI

Code

registry/default/ui/rolling-number.tsx

"use client"

import { useEffect } from "react"
import { motion, MotionValue, useSpring, useTransform } from "motion/react"

interface RollingNumberProps {
  value: number
  mass?: number
  stiffness?: number
  damping?: number
  precision?: number
  format?: (value: number) => string
  onAnimationStart?: () => void
  onAnimationComplete?: () => void
}

export function RollingNumber({
  value,
  mass = 0.8,
  stiffness = 75,
  damping = 15,
  precision = 0,
  format = (num) => num.toLocaleString(),
  onAnimationStart,
  onAnimationComplete,
}: RollingNumberProps) {
  const spring = useSpring(value, { mass, stiffness, damping })
  const display: MotionValue<string> = useTransform(spring, (current) =>
    format(parseFloat(current.toFixed(precision)))
  )

  useEffect(() => {
    spring.set(value)
    if (onAnimationStart) onAnimationStart()
    const unsubscribe = spring.on("change", () => {
      if (spring.get() === value && onAnimationComplete) onAnimationComplete()
    })
    return () => unsubscribe()
  }, [spring, value, onAnimationStart, onAnimationComplete])

  return <motion.span>{display}</motion.span>
}

More like this

Spending Ring

Kokonut UI·Inputs & forms

Glare Hover

Magic UI·Other

Smooth Tab

Kokonut UI·Navigation

Metric Card

Kokonut UI·Cards

Spinner

shadcn/ui·Feedback & loaders

Navigation menu

HextaUI·Overlays

Stats 2

SmoothUI·Data display

Sliding Number

Motion Primitives·Text effects

Animated List

Magic UI·Data display

Field

shadcn/ui·Backgrounds

Neumorph Eyebrow

Cult UI·Text effects

Liquid Gauge

Kokonut UI·Backgrounds

Bento Grid

Kokonut UI·Cards

Text Gif

Cult UI·Text effects

Animated List

React Bits·Data displayMIT+