BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/vengenceui/animated-number

animated-number

vengenceui/animated-number
FreeComponent

vengenceui publishes no description for this item.

Live preview

live · rendered by the registry
Rendered by vengenceui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://www.vengenceui.com/r/animated-number.json

Source

components/ui/animated-number.tsxwww.vengenceui.com/r/animated-number.json · first 6 KB
1"use client"
2
3import React, { useEffect, useRef, useState } from 'react'
4import { motion, AnimatePresence } from "framer-motion"
5import { cn } from "@/lib/utils"
6
7function AnimatedNumber({ value, className }: { value: number, className?: string }) {
8 return (
9 <div className={cn("flex items-center", className)}>
10 <div className="flex relative items-center">
11 {value.toString().split("").map((digit, index) => (
12 <SingleNumberHolder key={index} value={digit} index={index} />
13 ))}
14 </div>
15 </div>
16 )
17}
18
19function SingleNumberHolder({ value, index }: { value: string, index: number }) {
20 const [height, setHeight] = useState<string | null>(null)
21 const containerRef = useRef<HTMLDivElement>(null)
22 let notANumber = false
23
24 useEffect(() => {
25 if (containerRef.current) {
26 setHeight(getComputedStyle(containerRef.current).height)
27 }
28 }, [])
29
30 if (index === 0) {
31 notANumber = isNaN(Number.parseInt(value))
32 }
33
34 const vars = {
35 init: { opacity: 0 },
36 animate: { opacity: 1 },
37 exit: { opacity: 0 },
38 }
39
40 return (
41 <div
42 className="relative"
43 style={{ height: height || "auto", overflowY: "hidden", overflowX: "clip" }}
44 ref={containerRef}
45 >
46 {notANumber && (
47 <motion.span
48 initial="init"
49 animate="animate"
50 exit="exit"
51 variants={vars}
52 key={value}
53 layout="size"
54 >
55 {value}
56 </motion.span>
57 )}
58 {!notANumber && <RenderStrip value={value} eleHeight={height} />}
59 </div>
60 )
61}
62
63const zeroToNine = Array.from({ length: 10 }, (_, k) => k)
64
65function RenderStrip({ eleHeight, value }: { eleHeight: string | null, value: string }) {
66 const heightInNumber = Number.parseInt(eleHeight?.replace("px", "") || "48")
67 const negative = heightInNumber * -1
68 const pos = heightInNumber
69 const prev = useRef(value)
70
71 // Convert string values to numbers for comparison
72 const currentVal = parseInt(value)
73 const prevVal = parseInt(prev.current)
74
75 // Calculate direction based on value change
76 const diff = prevVal - currentVal
77 const dir = currentVal > prevVal ? pos * diff * -1 : negative * diff
78
79 // Update ref after calculation
80// … truncated

What it pulls in

npm packages

  • framer-motion

Files it writes

  • public/r/animated-number.json

Facts

Registry
vengenceui
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

Docs on vengenceui www.vengenceui.com Raw registry item This item as JSON

More from vengenceui

All 128 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
accordionaccordionvengenceuiComponentsFree2 deps
agent-bento-gridagent-bento-gridvengenceuiComponentsFree1 dep
alertalertvengenceuiComponentsFreeno deps
animated-buttonanimated-buttonvengenceuiComponentsFree1 dep
animated-footeranimated-footervengenceuiComponentsFree2 deps
animated-raysanimated-raysvengenceuiComponentsFreeno deps
animated-tooltipanimated-tooltipvengenceuiComponentsFree1 dep
ascii-glitch-rippleascii-glitch-ripplevengenceuiComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex