Yes, you can create beautiful animations in a Next.js TypeScript project using shadcn/ui components and Tailwind CSS! There are several approaches you can take:
animate-spin
, animate-pulse
, etc.Let me create a lottery machine animation based on your image that demonstrates these techniques:
Framer Motion - I used Framer Motion for the smooth animations of the lottery drum and balls. It provides:
animate
propTailwind CSS Animation Utilities:
animate-pulse
for the button when spinningCSS Transitions:
Dynamic Positioning:
You can also add animations to your shadcn/ui components using:
Tailwind's animation classes 1:
<div className="animate-spin">Spinning element</div>
Custom animations in your tailwind.config.js 2:
// In tailwind.config.js
theme: {
extend: {
keyframes: {
wiggle: {
'0%, 100%': { transform: 'rotate(-3deg)' },
'50%': { transform: 'rotate(3deg)' },
}
},
animation: {
wiggle: 'wiggle 1s ease-in-out infinite',
}
},
}
CSS Variables for animation control:
<div className="animate-[fade-in_1s_ease-in-out]">Fades in</div>
Variants with shadcn/ui components:
<Button
variant="default"
className="transition-all hover:scale-105"
>
Hover me
</Button>
The lottery machine example demonstrates how you can combine these techniques to create complex, interactive animations in your Next.js project with shadcn/ui and Tailwind CSS.