Animation
Bring your UI to life with Vayu UI's comprehensive animation system, featuring entrance effects, attention seekers, and continuous cycles.
Animation
Animation adds personality and feedback to your UI. Vayu UI provides a comprehensive set of keyframe animations organized into three categories: Entrance, Attention, and Cycles.
Animation Categories
| Category | Purpose | When to Use |
|---|---|---|
| Entrance | Elements appearing on screen | Page loads, modal opens, items added |
| Attention | Drawing focus to elements | Notifications, highlights, errors |
| Cycles | Continuous motion | Loading states, decorative elements |
Entrance Animations
Entrance animations bring elements onto the screen. Use them when content first appears.
Fade In
The most subtle entrance. Great for content that should appear gently.
This content fades in smoothly
// Basic fade in
<div className="animate-fade-in">
Content appears with a fade
</div>
// Staggered fade in (using inline style)
<div className="animate-fade-in" style={{ animationDelay: '100ms' }}>
First item
</div>
<div className="animate-fade-in" style={{ animationDelay: '200ms' }}>
Second item
</div>
<div className="animate-fade-in" style={{ animationDelay: '300ms' }}>
Third item
</div>Slide Animations
Slide animations bring content in from a specific direction. Perfect for drawers, panels, and notifications.
| Animation | Direction | Use Case |
|---|---|---|
animate-slide-in-left | From left | Sidebar opening |
animate-slide-in-right | From right | Panel, offcanvas |
animate-slide-in-up | From bottom | Bottom sheet, snackbar |
animate-slide-in-down | From top | Dropdown, notification |
// Sidebar opening from left
<aside className="animate-slide-in-left fixed inset-y-0 left-0 w-64 bg-sidebar">
<nav>{/* Navigation */}</nav>
</aside>
// Bottom sheet sliding up
<div className="animate-slide-in-up fixed bottom-0 inset-x-0 bg-elevated rounded-t-overlay">
Bottom sheet content
</div>
// Notification sliding from top
<div className="animate-slide-in-down fixed top-4 right-4 bg-elevated rounded-surface p-4">
New notification!
</div>
// Panel sliding from right
<div className="animate-slide-in-right fixed inset-y-0 right-0 w-80 bg-surface">
Panel content
</div>Bounce In
A playful entrance with a slight overshoot. Great for success states and modals.
✓ Success!
// Success message
<div className="animate-bounce-in bg-success text-success-content rounded-surface p-4">
✓ Operation completed!
</div>
// Modal with bounce
<div className="animate-bounce-in bg-elevated rounded-overlay p-6">
<h2>Welcome!</h2>
</div>
// Icon appearing
<CheckCircle className="animate-bounce-in text-success w-8 h-8" />Flip Animations
3D flip effects for card reveals and badge pops.
| Animation | Axis | Use Case |
|---|---|---|
animate-flip-in-x | Horizontal | Card flip |
animate-flip-in-y | Vertical | Badge pop |
Flip X
Flip Y
// Card flip reveal
<div className="animate-flip-in-x bg-surface rounded-surface p-6">
<p>Hidden content revealed!</p>
</div>
// Badge pop
<span className="animate-flip-in-y bg-brand text-brand-content rounded-full px-2">
New!
</span>Zoom In
Scale up from small to full size. Perfect for modals and dialogs.
// Modal with zoom
<div className="animate-zoom-in bg-elevated rounded-overlay p-6">
<h2>Modal Title</h2>
<p>Modal content</p>
</div>
// Image preview
<img src="/preview.jpg" className="animate-zoom-in rounded-surface" />Rotate In
Spin into view. Great for icons and decorative elements.
🎉
// Icon entrance
<Icon className="animate-rotate-in" />
// Decorative element
<div className="animate-rotate-in">
Decorative content
</div>Roll Animations
Playful rolling entrance effects.
| Animation | Direction |
|---|---|
animate-roll-in | From left, rolling clockwise |
animate-roll-in-right | From right, rolling counter-clockwise |
animate-roll-in-up | From bottom, rolling |
animate-roll-in-down | From top, rolling |
Rolled in!
<div className="animate-roll-in">Fun content</div>Special Entrances
| Animation | Description | Use Case |
|---|---|---|
animate-jack-in-the-box | Scales and rotates into view | Playful pop, tooltips |
animate-hinge | Falls off the screen | Exit animation |
🎁 Jack in the Box!
// Playful tooltip
<div className="animate-jack-in-the-box">
Surprise!
</div>
// Exit animation (use with caution)
<div className="animate-hinge">
This will fall away
</div>Cycle Animations
Cycle animations run continuously. Use them for loading states and decorative elements.
Float
Gentle up-and-down motion. Great for decorative elements.
✨
// Floating decorative element
<div className="animate-float">
<Icon className="w-8 h-8" />
</div>
// Floating card
<div className="animate-float bg-surface rounded-surface p-6">
Floating content
</div>Float Particle
Particles that float upward and fade out. Perfect for background effects.
<div className="relative overflow-hidden">
{[...Array(10)].map((_, i) => (
<div
key={i}
className="animate-float-particle absolute bottom-0 w-2 h-2 bg-brand rounded-full"
style={{
left: `${Math.random() * 100}%`,
animationDelay: `${Math.random() * 5}s`,
}}
/>
))}
</div>Orbit
Continuous rotation around a center point.
<div className="relative w-24 h-24">
<div className="animate-orbit absolute top-0 left-1/2 -translate-x-1/2">
<div className="w-4 h-4 bg-brand rounded-full" />
</div>
</div>Morph Blob
Shape-shifting animation for organic, blob-like elements.
<div
className="animate-morph-blob bg-brand w-24 h-24"
style={{ borderRadius: '60% 40% 30% 70% / 60% 30% 70% 40%' }}
/>Spin Animations
Slow rotations for decorative purposes.
| Animation | Speed | Direction |
|---|---|---|
animate-spin-slow | 60s | Clockwise |
animate-reverse-spin | 40s | Counter-clockwise |
// Slow spinning decoration
<div className="animate-spin-slow">
<Icon className="w-12 h-12" />
</div>
// Counter-rotating element
<div className="animate-reverse-spin">
<Icon className="w-12 h-12" />
</div>Marquee
Infinite scrolling for tickers and carousels.
| Animation | Behavior |
|---|---|
animate-marquee-scroll | Continuous left scroll |
animate-marquee-ping-pong | Bounces back and forth |
<div className="overflow-hidden">
<div className="animate-marquee-scroll flex gap-8 whitespace-nowrap">
{/* Duplicate content for seamless loop */}
<span>Announcement 1</span>
<span>Announcement 2</span>
<span>Announcement 3</span>
<span>Announcement 1</span>
<span>Announcement 2</span>
<span>Announcement 3</span>
</div>
</div>Toast Animations
Special animations for toast notifications.
| Animation | Purpose |
|---|---|
animate-toast-enter | Toast appearing |
animate-toast-exit | Toast disappearing |
Toast notification
// Toast component
function Toast({ message, isVisible }) {
return (
<div className={isVisible ? 'animate-toast-enter' : 'animate-toast-exit'}>
{message}
</div>
);
}Accessibility
Reduced Motion
Vayu UI respects user preferences for reduced motion. All animations are automatically disabled when the user has prefers-reduced-motion: reduce enabled.
This is built into the CSS:
@media (prefers-reduced-motion: reduce) {
* {
animation: none !important;
}
}Best Practices
| Do ✅ | Don't ❌ |
|---|---|
| Use animations for feedback and hierarchy | Use animations just because they're cool |
| Keep animations subtle and quick | Create long, distracting animations |
| Test with reduced motion enabled | Forget about accessibility |
| Use entrance animations for new content | Animate everything at once |
| Respect user preferences | Override reduced motion settings |
Checking for Reduced Motion
If you need to check programmatically:
'use client';
import { useEffect, useState } from 'react';
export function usePrefersReducedMotion() {
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
useEffect(() => {
const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
setPrefersReducedMotion(mediaQuery.matches);
const handler = (event) => setPrefersReducedMotion(event.matches);
mediaQuery.addEventListener('change', handler);
return () => mediaQuery.removeEventListener('change', handler);
}, []);
return prefersReducedMotion;
}
// Usage
function MyComponent() {
const prefersReducedMotion = usePrefersReducedMotion();
return <div className={prefersReducedMotion ? '' : 'animate-fade-in'}>Content</div>;
}Quick Reference
All Animations
Entrance
| Class | Duration | Use |
|---|---|---|
animate-fade-in | 1s | Gentle appearance |
animate-slide-in-left | 1s | Sidebar, drawer |
animate-slide-in-right | 1s | Panel, offcanvas |
animate-slide-in-up | 1s | Bottom sheet |
animate-slide-in-down | 1s | Dropdown, notification |
animate-bounce-in | 1s | Success, modal |
animate-flip-in-x | 1s | Card reveal |
animate-flip-in-y | 1s | Badge pop |
animate-rotate-in | 1s | Icon entrance |
animate-zoom-in | 1s | Modal, dialog |
animate-roll-in | 1s | Playful entrance |
animate-roll-in-right | 1s | Playful entrance |
animate-roll-in-up | 1s | Playful entrance |
animate-roll-in-down | 1s | Playful entrance |
animate-jack-in-the-box | 1s | Playful pop |
animate-hinge | 2s | Exit animation |
Cycles
| Class | Duration | Use |
|---|---|---|
animate-float | 6s | Floating elements |
animate-float-particle | 15s | Particle effects |
animate-orbit | 20s | Orbiting elements |
animate-morph-blob | 20s | Shape morphing |
animate-spin-slow | 60s | Slow rotation |
animate-reverse-spin | 40s | Reverse rotation |
animate-marquee-scroll | ∞ | Infinite scroll |
animate-marquee-ping-pong | ∞ | Bouncing scroll |
Toast
| Class | Duration | Use |
|---|---|---|
animate-toast-enter | 300ms | Toast appear |
animate-toast-exit | 300ms | Toast disappear |
CSS Variables
--animate-fade-in: fade-in 1s ease-out;
--animate-float: float 6s ease-in-out infinite;
--animate-float-particle: float-particle 15s linear infinite;
--animate-morph-blob: morph-blob 20s ease-in-out infinite;
--animate-orbit: orbit 20s linear infinite;
--animate-slide-in-left: slide-in-left 1s both;
--animate-slide-in-right: slide-in-right 1s both;
--animate-slide-in-up: slide-in-up 1s both;
--animate-slide-in-down: slide-in-down 1s both;
--animate-bounce-in: bounce-in 1s ease;
--animate-flip-in-x: flip-in-x 1s ease-in;
--animate-flip-in-y: flip-in-y 1s ease-in;
--animate-rotate-in: rotate-in 1s ease-out;
--animate-zoom-in: zoom-in 1s ease-out;
--animate-roll-in: roll-in 1s ease-out;
--animate-roll-in-right: roll-in-right 1s ease-out;
--animate-roll-in-up: roll-in-up 1s ease-out;
--animate-roll-in-down: roll-in-down 1s ease-out;
--animate-jack-in-the-box: jack-in-the-box 1s ease-out;
--animate-hinge: hinge 2s ease-in-out;
--animate-spin-slow: spin-slow 60s linear infinite;
--animate-reverse-spin: reverse-spin 40s linear infinite;
--animate-toast-enter: toast-enter 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
--animate-toast-exit: toast-exit 300ms ease-in both;