Animated Number
dashboardblocks/animated-numberFreeComponent
An animated number component.
Live preview
live · rendered by the registry
Rendered by dashboardblocks on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://dashboardblocks.com/r/animated-number.jsonSource
1'use client'23import { useAnimatedNumber } from '@/registry/hooks/use-animated-number'4import { ReactNode } from 'react'56interface AnimatedNumberProps {7 /**8 * The target value to animate to9 */10 value: number11 /**12 * Duration of the animation in milliseconds13 * @default 100014 */15 duration?: number16 /**17 * Easing function for the animation18 * @default 'easeOut'19 */20 easing?: 'linear' | 'easeOut' | 'easeIn' | 'easeInOut' | 'spring'21 /**22 * Starting value for the animation23 * @default 024 */25 from?: number26 /**27 * Delay before starting animation in milliseconds28 * @default 029 */30 delay?: number31 /**32 * Custom formatter function33 */34 formatter?: (value: number) => ReactNode35 /**36 * Additional className for the wrapper span37 */38 className?: string39}4041/**42 * A component that animates a number from a start value to an end value,43 * with viewport detection to only animate when visible.44 */45export function AnimatedNumber({46 className,47 delay = 0,48 duration = 1000,49 easing = 'easeOut',50 formatter,51 from = 0,52 value: targetValue,53}: AnimatedNumberProps) {54 const { ref, value } = useAnimatedNumber(targetValue, {55 delay,56 duration,57 easing,58 from,59 })6061 const displayValue = formatter ? formatter(value) : value.toLocaleString()6263 return (64 <span ref={ref as React.RefObject<HTMLSpanElement>} className={className}>65 {displayValue}66 </span>67 )68}
What it pulls in
Other registry items
Files it writes
More from dashboardblocks
All 36 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Activity Feedactivity-feed | dashboardblocks | Components | Free | 1 dep | |
| activity-feed-01activity-feed-01 | dashboardblocks | Components | Free | 1 dep | |
| activity-feed-02activity-feed-02 | dashboardblocks | Components | Free | 1 dep | |
| activity-feed-03activity-feed-03 | dashboardblocks | Components | Free | 1 dep | |
| activity-feed-04activity-feed-04 | dashboardblocks | Components | Free | 1 dep | |
| activity-feed-05activity-feed-05 | dashboardblocks | Components | Free | 1 dep | |
| Animated Waveanimated-wave | dashboardblocks | Components | Free | no deps | |
| area-chart-kpi-01area-chart-kpi-01 | dashboardblocks | Components | Free | no deps |
