Animated Number Flip
ruixen-ui/animated-number-flipFreeComponent
A card component that displays numbers with smooth flip animations.
Live preview
live · rendered by the registry
Rendered by ruixen-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ruixen.com/r/animated-number-flip.jsonSource
1"use client";23import * as React from "react";4import { motion, AnimatePresence } from "motion/react";5import { cn } from "@/lib/utils";6import { Card, CardContent } from "@/components/ui/card";78interface AnimatedNumberFlipProps {9 value: number;10 className?: string;11}1213export default function AnimatedNumberFlip({14 value,15 className,16}: AnimatedNumberFlipProps) {17 const [displayValue, setDisplayValue] = React.useState(value);1819 React.useEffect(() => {20 if (value !== displayValue) {21 const timeout = setTimeout(() => setDisplayValue(value), 300);22 return () => clearTimeout(timeout);23 }24 }, [value, displayValue]);2526 return (27 <Card28 className={cn("w-24 h-24 flex items-center justify-center", className)}29 >30 <CardContent className="flex items-center justify-center p-0 text-4xl font-bold">31 <div className="relative overflow-hidden h-12 w-10">32 <AnimatePresence mode="popLayout" initial={false}>33 <motion.span34 key={value}35 initial={{ y: -40, opacity: 0, rotateX: -90 }}36 animate={{ y: 0, opacity: 1, rotateX: 0 }}37 exit={{ y: 40, opacity: 0, rotateX: 90 }}38 transition={{ duration: 0.3 }}39 className="absolute inset-0 flex items-center justify-center"40 >41 {value}42 </motion.span>43 </AnimatePresence>44 </div>45 </CardContent>46 </Card>47 );48}
What it pulls in
npm packages
Other registry items
Files it writes
More from ruixen-ui
All 417 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Editorial Accordionaccordion-editorial | ruixen-ui | Components | Free | no deps | |
| Indexed Accordionaccordion-indexed | ruixen-ui | Components | Free | 1 dep | |
| Account Menuaccount-menu | ruixen-ui | Components | Free | 1 dep | |
| Action Toolbaraction-toolbar | ruixen-ui | Components | Free | 1 dep | |
| Add Task Sheetadd-task-sheet | ruixen-ui | Components | Free | 1 dep | |
| Add To Cart Buttonadd-to-cart-button | ruixen-ui | Components | Free | 1 dep | |
| AI Chat Inputai-chat-input | ruixen-ui | Components | Free | 1 dep | |
| Animated Highlight Textanimated-highlight-text | ruixen-ui | Components | Free | 1 dep |
