Please use Desktop to view and interact with components
Data Animations2000mseaseOut
Animated Progress Bar
Progress bar with smooth animation
progressloadingbarshadcn
Useto navigate between components
Preview
Upload Progress
0%
This component requires shadcn/ui
This component uses shadcn/ui components. Make sure you have shadcn/ui set up in your project.
- Install shadcn/ui:
npx shadcn-ui@latest init - Install required components based on the imports in the code (e.g.,
npx shadcn-ui@latest add button) - Ensure your
tailwind.config.tsandglobals.cssare configured as per shadcn/ui documentation
Code
TypeScript + React
'use client'
import { motion, useMotionValue, useTransform, animate } from 'framer-motion'
import { useEffect } from 'react'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
export function AnimatedProgress() {
const progress = useMotionValue(0)
const width = useTransform(progress, [0, 100], ['0%', '100%'])
const displayProgress = useTransform(progress, (v) => `${Math.round(v)}%`)
useEffect(() => {
const animation = animate(progress, 75, {
duration: 2,
ease: 'easeOut',
})
return animation.stop
}, [progress])
return (
<Card className="w-80">
<CardHeader>
<CardTitle className="text-lg">Upload Progress</CardTitle>
</CardHeader>
<CardContent>
<div className="h-2 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-800">
<motion.div
style={{ width }}
className="h-full bg-gradient-to-r from-accent to-slate-500"
/>
</div>
<motion.p className="mt-2 text-right text-sm text-[var(--foreground)]/70">
{displayProgress}
</motion.p>
</CardContent>
</Card>
)
}
How to Use
- 1Install Framer Motion:
npm install framer-motion - 2Set up shadcn/ui: Install shadcn/ui components used in this code. Check the imports in the code above and install the required components (e.g.,
npx shadcn-ui@latest add button card) - 3Copy the code from above
- 4Paste it into your project and customize as needed
- 5Colors are customizable via Tailwind CSS classes. The default theme uses dark mode colors defined in your globals.css file