Build a custom animation library using vanilla CSS and CSS variables for theme control.
- User
Build a custom animation library using vanilla CSS and CSS variables for theme control.
Assistant
The user wants me to build a custom animation library using vanilla CSS and CSS variables for theme control. This is a great project that showcases CSS-only animations with a powerful theming system.
Let me create something that:
- Has a comprehensive CSS animation library with various animation types
- Uses CSS variables for complete theme control
- Has an interactive demo/showcase page
- Shows the code for each animation
- Has multiple dynamic elements and looks polished
- Includes at least 3 dynamic elements as required
I'll create:
- A beautiful showcase page with dark theme
- Multiple animation categories: entrances, exits, attention seekers, text effects, background effects
- Theme customization panel
- Live preview of each animation
- Copy-to-clipboard for animation code
- Smooth transitions and interactions
Design approach:
- Dark, sophisticated theme with high contrast
- Clean typography with good hierarchy
- Grid layout for animation cards
- Interactive elements with hover effects
- Live animation previews
Color scheme: Dark with cyan/teal accent (avoiding purple!) Fonts: A display font like Space Grotesk + JetBrains Mono for code
Custom CSS Animation Library
I'll build a comprehensive animation library with full theme control using CSS variables, featuring multiple animation categories, live previews, and an interactive theme customizer.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Motion.css - Custom Animation Library</title> <!-- Google Fonts --> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet"> <!-- Tailwind CDN --> <script src="https://cdn.tailwindcss.com"></script> <!-- Motion.css - Custom Animation Library --> <style> /* ============================================ THEME VARIABLES ============================================ */ :root { /* Colors */ --color-bg: #0a0a0f; --color-bg-elevated: #12121a; --color-bg-card: #1a1a24; --color-border: #2a2a3a; --color-text: #f0f0f5; --color-text-muted: #8888aa; --color-accent: #00d4aa; --color-accent-dim: rgba(0, 212, 170, 0.15); --color-secondary: #ff6b35; --color-warning: #ffc107; --color-error: #ff4757; --color-success: #00d4aa; /* Animation Defaults */ --anim-duration-fast: 200ms; --anim-duration-normal: 400ms; --anim-duration-slow: 800ms; --anim-easing-default: cubic-bezier(0.4, 0, 0.2, 1); --anim-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55); --anim-easing-elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6); /* Spacing */ --space-xs: 0.25rem; --space-sm: 0.5rem; --space-md: 1rem; --space-lg: 1.5rem; --space-xl: 2rem; --space-2xl: 3rem; /* Border Radius */ --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px; --radius-xl: 16px; --radius-full: 9999px; /* Shadows */ --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4); --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5); --shadow-glow: 0 0 30px var(--color-accent-dim); } /* Light Theme */ [data-theme="light"] { --color-bg: #f5f5f7; --color-bg-elevated: #ffffff; --color-bg-card: #ffffff; --color-border: #e0e0e5; --color-text: #1a1a1f; --color-text-muted: #666680; --color-accent: #00a080; --color-accent-dim: rgba(0, 160, 128, 0.1); --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05); --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07); --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1); } /* Ocean Theme */ [data-theme="ocean"] { --color-bg: #0d1b2a; --color-bg-elevated: #1b263b; --color-bg-card: #1b263b; --color-border: #415a77; --color-text: #e0e1dd; --color-text-muted: #778da9; --color-accent: #00b4d8; --color-accent-dim: rgba(0, 180, 216, 0.15); --color-secondary: #90e0ef; } /* Sunset Theme */ [data-theme="sunset"] { --color-bg: #1a1423; --color-bg-elevated: #2d1f3d; --color-bg-card: #2d1f3d; --color-border: #4a3a5c; --color-text: #faf0e6; --color-text-muted: #b8a9c9; --color-accent: #ff7b54; --color-accent-dim: rgba(255, 123, 84, 0.15); --color-secondary: #ffd56b; } /* Forest Theme */ [data-theme="forest"] { --color-bg: #0f1a0f; --color-bg-elevated: #1a2e1a; --color-bg-card: #1a2e1a; --color-border: #2d4a2d; --color-text: #e8f5e8; --color-text-muted: #7cb37c; --color-accent: #4ade80; --color-accent-dim: rgba(74, 222, 128, 0.15); --color-secondary: #fbbf24; } /* ============================================ BASE STYLES ============================================ */ * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Space Grotesk', sans-serif; background: var(--color-bg); color: var(--color-text); min-height: 100vh; transition: background-color var(--anim-duration-normal) var(--anim-easing-default), color var(--anim-duration-normal) var(--anim-easing-default); } /* Code Font */ .font-mono { font-family: 'JetBrains Mono', monospace; } /* ============================================ KEYFRAME ANIMATIONS ============================================ */ /* === ENTRANCE ANIMATIONS === */ @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } } @keyframes fadeInDown { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: translateY(0); } } @keyframes fadeInLeft { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: translateX(0); } } @keyframes fadeInRight { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } } @keyframes scaleIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } } @keyframes scaleInBounce { 0% { opacity: 0; transform: scale(0.3); } 50% { transform: scale(1.1); } 70% { transform: scale(0.9); } 100% { opacity: 1; transform: scale(1); } } @keyframes slideInLeft { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } @keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } @keyframes slideInUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } } @keyframes slideInDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } } @keyframes rotateIn { from { opacity: 0; transform: rotate(-180deg) scale(0.5); } to { opacity: 1; transform: rotate(0) scale(1); } } @keyframes flipIn { from { opacity: 0; transform: perspective(400px) rotateY(90deg); } to { opacity: 1; transform: perspective(400px) rotateY(0); } } @keyframes zoomIn { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } } @keyframes rollIn { from { opacity: 0; transform: translateX(-100%) rotate(-120deg); } to { opacity: 1; transform: translateX(0) rotate(0); } } /* === EXIT ANIMATIONS === */ @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } } @keyframes fadeOutUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-30px); } } @keyframes fadeOutDown { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(30px); } } @keyframes scaleOut { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.8); } } @keyframes zoomOut { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0); } } @keyframes slideOutLeft { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-100%); opacity: 0; } } @keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } } /* === ATTENTION SEEKERS === */ @keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } } @keyframes bounce { 0%, 20%, 53%, 100% { transform: translateY(0); } 40% { transform: translateY(-20px); } 70% { transform: translateY(-10px); } 90% { transform: translateY(-4px); } } @keyframes shake { 0%, 100% { transform: translateX(0); } 10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); } 20%, 40%, 60%, 80% { transform: translateX(5px); } } @keyframes wobble { 0% { transform: translateX(0); } 15% { transform: translateX(-10px) rotate(-5deg); } 30% { transform: translateX(8px) rotate(3deg); } 45% { transform: translateX(-6px) rotate(-3deg); } 60% { transform: translateX(4px) rotate(2deg); } 75% { transform: translateX(-2px) rotate(-1deg); } 100% { transform: translateX(0); } } @keyframes swing { 20% { transform: rotate(15deg); } 40% { transform: rotate(-10deg); } 60% { transform: rotate(5deg); } 80% { transform: rotate(-5deg); } 100% { transform: rotate(0deg); } } @keyframes tada { 0% { transform: scale(1) rotate(0); } 10%, 20% { transform: scale(0.9) rotate(-3deg); } 30%, 50%, 70%, 90% { transform: scale(1.1) rotate(3deg); } 40%, 60%, 80% { transform: scale(1.1) rotate(-3deg); } 100% { transform: scale(1) rotate(0); } } @keyframes heartBeat { 0% { transform: scale(1); } 14% { transform: scale(1.3); } 28% { transform: scale(1); } 42% { transform: scale(1.3); } 70% { transform: scale(1); } } @keyframes flash { 0%, 50%, 100% { opacity: 1; } 25%, 75% { opacity: 0; } } @keyframes rubberBand { 0% { transform: scale(1); } 30% { transform: scaleX(1.25) scaleY(0.75); } 40% { transform: scaleX(0.75) scaleY(1.25); } 50% { transform: scaleX(1.15) scaleY(0.85); } 65% { transform: scaleX(0.95) scaleY(1.05); } 75% { transform: scaleX(1.05) scaleY(0.95); } 100% { transform: scale(1); } } @keyframes jello { 0%, 100% { transform: skewX(0) skewY(0); } 11.1% { transform: skewX(-12.5deg) skewY(-12.5deg); } 22.2% { transform: skewX(6.25deg) skewY(6.25deg); } 33.3% { transform: skewX(-3.125deg) skewY(-3.125deg); } 44.4% { transform: skewX(1.5625deg) skewY(1.5625deg); } 55.5% { transform: skewX(-0.78125deg) skewY(-0.78125deg); } 66.6% { transform: skewX(0.390625deg) skewY(0.390625deg); } 77.7% { transform: skewX(-0.1953125deg) skewY(-0.1953125deg); } } @keyframes headShake { 0% { transform: translateX(0); } 6.5% { transform: translateX(-6px) rotateY(-9deg); } 18.5% { transform: translateX(5px) rotateY(7deg); } 31.5% { transform: translateX(-3px) rotateY(-5deg); } 43.5% { transform: translateX(2px) rotateY(3deg); } 50% { transform: translateX(0); } } /* === CONTINUOUS ANIMATIONS === */ @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes spinReverse { from { transform: rotate(360deg); } to { transform: rotate(0deg); } } @keyframes ping { 75%, 100% { transform: scale(2); opacity: 0; } } @keyframes pingSlow { 0% { transform: scale(1); opacity: 0.8; } 75%, 100% { transform: scale(2); opacity: 0; } } @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } } @keyframes floatRotate { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-15px) rotate(5deg); } } @keyframes glow { 0%, 100% { box-shadow: 0 0 5px var(--color-accent), 0 0 10px var(--color-accent-dim); } 50% { box-shadow: 0 0 20px var(--color-accent), 0 0 40px var(--color-accent-dim); } } @keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } } @keyframes wave { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(20deg); } 75% { transform: rotate(-15deg); } } @keyframes morph { 0%, 100% { border-radius: 40% 60% 60% 40% / 60% 30% 70% 40%; } 25% { border-radius: 50% 50% 30% 70% / 50% 50% 70% 30%; } 50% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; } 75% { border-radius: 60% 40% 30% 70% / 40% 40% 60% 50%; } } /* === TEXT ANIMATIONS === */ @keyframes typewriter { from { width: 0; } to { width: 100%; } } @keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } } @keyframes textGlow { 0%, 100% { text-shadow: 0 0 4px var(--color-accent), 0 0 8px var(--color-accent-dim); } 50% { text-shadow: 0 0 8px var(--color-accent), 0 0 16px var(--color-accent), 0 0 24px var(--color-accent-dim); } } @keyframes glitch { 0%, 100% { transform: translate(0); text-shadow: -2px 0 var(--color-secondary), 2px 0 var(--color-accent); } 20% { transform: translate(-2px, 2px); text-shadow: 2px 0 var(--color-secondary), -2px 0 var(--color-accent); } 40% { transform: translate(-2px, -2px); text-shadow: 2px 0 var(--color-accent), -2px 0 var(--color-secondary); } 60% { transform: translate(2px, 2px); text-shadow: -2px 0 var(--color-secondary), 2px 0 var(--color-accent); } 80% { transform: translate(2px, -2px); text-shadow: 2px 0 var(--color-accent), -2px 0 var(--color-secondary); } } @keyframes revealText { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 0 0 0); } } /* === BACKGROUND ANIMATIONS === */ @keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } @keyframes colorCycle { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } } @keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.1); opacity: 1; } } /* ============================================ ANIMATION UTILITY CLASSES ============================================ */ /* Base animation properties */ .animate { animation-fill-mode: both; animation-timing-function: var(--anim-easing-default); } /* Duration modifiers */ .animate-fast { animation-duration: var(--anim-duration-fast); } .animate-normal { animation-duration: var(--anim-duration-normal); } .animate-slow { animation-duration: var(--anim-duration-slow); } /* Easing modifiers */ .ease-bounce { animation-timing-function: var(--anim-easing-bounce); } .ease-elastic { animation-timing-function: var(--anim-easing-elastic); } /* Iteration modifiers */ .animate-infinite { animation-iteration-count: infinite; } .animate-once { animation-iteration-count: 1; } .animate-twice { animation-iteration-count: 2; } /* Delay modifiers */ .delay-100 { animation-delay: 100ms; } .delay-200 { animation-delay: 200ms; } .delay-300 { animation-delay: 300ms; } .delay-500 { animation-delay: 500ms; } .delay-700 { animation-delay: 700ms; } .delay-1000 { animation-delay: 1000ms; } /* Fill mode modifiers */ .fill-forwards { animation-fill-mode: forwards; } .fill-backwards { animation-fill-mode: backwards; } .fill-both { animation-fill-mode: both; } /* State modifiers */ .animate-paused { animation-play-state: paused; } .animate-running { animation-play-state: running; } /* === ENTRANCE CLASSES === */ .fade-in { animation-name: fadeIn; } .fade-in-up { animation-name: fadeInUp; } .fade-in-down { animation-name: fadeInDown; } .fade-in-left { animation-name: fadeInLeft; } .fade-in-right { animation-name: fadeInRight; } .scale-in { animation-name: scaleIn; } .scale-in-bounce { animation-name: scaleInBounce; animation-timing-function: var(--anim-easing-bounce); } .slide-in-left { animation-name: slideInLeft; } .slide-in-right { animation-name: slideInRight; } .slide-in-up { animation-name: slideInUp; } .slide-in-down { animation-name: slideInDown; } .rotate-in { animation-name: rotateIn; } .flip-in { animation-name: flipIn; } .zoom-in { animation-name: zoomIn; } .roll-in { animation-name: rollIn; } /* === EXIT CLASSES === */ .fade-out { animation-name: fadeOut; } .fade-out-up { animation-name: fadeOutUp; } .fade-out-down { animation-name: fadeOutDown; } .scale-out { animation-name: scaleOut; } .zoom-out { animation-name: zoomOut; } .slide-out-left { animation-name: slideOutLeft; } .slide-out-right { animation-name: slideOutRight; } /* === ATTENTION CLASSES === */ .pulse { animation-name: pulse; } .bounce { animation-name: bounce; } .shake { animation-name: shake; } .wobble { animation-name: wobble; } .swing { animation-name: swing; } .tada { animation-name: tada; } .heart-beat { animation-name: heartBeat; } .flash { animation-name: flash; } .rubber-band { animation-name: rubberBand; } .jello { animation-name: jello; } .head-shake { animation-name: headShake; } /* === CONTINUOUS CLASSES === */ .spin { animation-name: spin; animation-timing-function: linear; } .spin-reverse { animation-name: spinReverse; animation-timing-function: linear; } .ping { animation-name: ping; animation-timing-function: linear; } .float { animation-name: float; } .float-rotate { animation-name: floatRotate; } .glow { animation-name: glow; } .shimmer { animation-name: shimmer; background: linear-gradient(90deg, transparent 0%, var(--color-accent-dim) 50%, transparent 100%); background-size: 200% 100%; } .wave { animation-name: wave; transform-origin: bottom center; } .morph { animation-name: morph; } /* === TEXT CLASSES === */ .text-glow { animation-name: textGlow; } .glitch { animation-name: glitch; } .reveal-text { animation-name: revealText; } /* === BACKGROUND CLASSES === */ .gradient-shift { background-size: 200% 200%; animation-name: gradientShift; } .color-cycle { animation-name: colorCycle; animation-timing-function: linear; } .breathe { animation-name: breathe; } /* ============================================ TRANSITION UTILITIES ============================================ */ .transition-all { transition: all var(--anim-duration-normal) var(--anim-easing-default); } .transition-fast { transition-duration: var(--anim-duration-fast); } .transition-slow { transition-duration: var(--anim-duration-slow); } .transition-bounce { transition-timing-function: var(--anim-easing-bounce); } /* ============================================ HOVER ANIMATIONS ============================================ */ .hover-scale:hover { transform: scale(1.05); } .hover-lift:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); } .hover-glow:hover { box-shadow: var(--shadow-glow); } .hover-rotate:hover { transform: rotate(5deg); } .hover-bounce:hover { animation: bounce 0.5s var(--anim-easing-bounce); } .hover-shake:hover { animation: shake 0.5s var(--anim-easing-default); } .hover-pulse:hover { animation: pulse 0.5s var(--anim-easing-default); } /* ============================================ SCROLL TRIGGERED ANIMATIONS ============================================ */ .scroll-animate { opacity: 0; } .scroll-animate.in-view { opacity: 1; } /* Stagger children */ .stagger-children > * { opacity: 0; } .stagger-children.in-view > *:nth-child(1) { animation: fadeInUp var(--anim-duration-normal) var(--anim-easing-default) 0ms forwards; } .stagger-children.in-view > *:nth-child(2) { animation: fadeInUp var(--anim-duration-normal) var(--anim-easing-default) 100ms forwards; } .stagger-children.in-view > *:nth-child(3) { animation: fadeInUp var(--anim-duration-normal) var(--anim-easing-default) 200ms forwards; } .stagger-children.in-view > *:nth-child(4) { animation: fadeInUp var(--anim-duration-normal) var(--anim-easing-default) 300ms forwards; } .stagger-children.in-view > *:nth-child(5) { animation: fadeInUp var(--anim-duration-normal) var(--anim-easing-default) 400ms forwards; } .stagger-children.in-view > *:nth-child(6) { animation: fadeInUp var(--anim-duration-normal) var(--anim-easing-default) 500ms forwards; } .stagger-children.in-view > *:nth-child(7) { animation: fadeInUp var(--anim-duration-normal) var(--anim-easing-default) 600ms forwards; } .stagger-children.in-view > *:nth-child(8) { animation: fadeInUp var(--anim-duration-normal) var(--anim-easing-default) 700ms forwards; } /* ============================================ LOADING ANIMATIONS ============================================ */ .loader-dots { display: inline-flex; gap: 4px; } .loader-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); animation: bounce 1.4s infinite ease-in-out both; } .loader-dots span:nth-child(1) { animation-delay: -0.32s; } .loader-dots span:nth-child(2) { animation-delay: -0.16s; } .loader-dots span:nth-child(3) { animation-delay: 0s; } .loader-spinner { width: 24px; height: 24px; border: 2px solid var(--color-border); border-top-color: var(--color-accent); border-radius: 50%; animation: spin 0.8s linear infinite; } .loader-ring { width: 40px; height: 40px; border: 3px solid transparent; border-top-color: var(--color-accent); border-right-color: var(--color-accent); border-radius: 50%; animation: spin 1s linear infinite; } /* ============================================ COMPONENT STYLES ============================================ */ /* Background Pattern */ .bg-pattern { position: fixed; inset: 0; background-image: radial-gradient(circle at 20% 80%, var(--color-accent-dim) 0%, transparent 50%), radial-gradient(circle at 80% 20%, rgba(255, 107, 53, 0.08) 0%, transparent 50%); pointer-events: none; z-index: 0; } .bg-grid { position: fixed; inset: 0; background-image: linear-gradient(var(--color-border) 1px, transparent 1px), linear-gradient(90deg, var(--color-border) 1px, transparent 1px); background-size: 60px 60px; opacity: 0.15; pointer-events: none; z-index: 0; } /* Cards */ .card { background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-lg); transition: all var(--anim-duration-normal) var(--anim-easing-default); } .card:hover { border-color: var(--color-accent); box-shadow: var(--shadow-glow); } /* Buttons */ .btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-md); font-weight: 500; cursor: pointer; transition: all var(--anim-duration-normal) var(--anim-easing-default); border: none; outline: none; } .btn-primary { background: var(--color-accent); color: var(--color-bg); } .btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); } .btn-secondary { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); } .btn-secondary:hover { border-color: var(--color-accent); color: var(--color-accent); } /* Focus states */ .btn:focus-visible, button:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; } /* Code blocks */ .code-block { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-md); font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; overflow-x: auto; white-space: pre-wrap; color: var(--color-text-muted); } .code-block .keyword { color: var(--color-secondary); } .code-block .property { color: var(--color-accent); } .code-block .value { color: var(--color-warning); } .code-block .comment { color: var(--color-text-muted); opacity: 0.6; } /* Preview Box */ .preview-box { width: 60px; height: 60px; background: var(--color-accent); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; } /* Tab styles */ .tab { padding: var(--space-sm) var(--space-md); border-radius: var(--radius-md); cursor: pointer; transition: all var(--anim-duration-fast) var(--anim-easing-default); color: var(--color-text-muted); border: 1px solid transparent; } .tab:hover { color: var(--color-text); background: var(--color-bg-elevated); } .tab.active { color: var(--color-accent); background: var(--color-accent-dim); border-color: var(--color-accent); } /* Theme Picker */ .theme-dot { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; transition: transform var(--anim-duration-fast) var(--anim-easing-bounce); border: 2px solid transparent; } .theme-dot:hover { transform: scale(1.2); } .theme-dot.active { border-color: var(--color-text); transform: scale(1.1); } /* Toast */ .toast { position: fixed; bottom: var(--space-xl); left: 50%; transform: translateX(-50%) translateY(100px); background: var(--color-bg-elevated); border: 1px solid var(--color-accent); padding: var(--space-md) var(--space-xl); border-radius: var(--radius-lg); opacity: 0; transition: all var(--anim-duration-normal) var(--anim-easing-bounce); z-index: 1000; } .toast.show { transform: translateX(-50%) translateY(0); opacity: 1; } /* Reduced Motion */ @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } } /* Floating Particles */ .particle { position: absolute; width: 4px; height: 4px; background: var(--color-accent); border-radius: 50%; opacity: 0.5; pointer-events: none; } </style> </head> <body> <!-- Background Effects --> <div class="bg-pattern"></div> <div class="bg-grid"></div> <!-- Floating Particles Container --> <div id="particles" class="fixed inset-0 overflow-hidden pointer-events-none z-0"></div> <!-- Main Content --> <div class="relative z-10 min-h-screen"> <!-- Header --> <header class="sticky top-0 z-50 backdrop-blur-lg bg-[var(--color-bg)]/80 border-b border-[var(--color-border)]"> <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4"> <div class="flex items-center justify-between"> <div class="flex items-center gap-3"> <div class="w-10 h-10 rounded-lg bg-[var(--color-accent)] flex items-center justify-center animate pulse animate-infinite animate-slow"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="text-[var(--color-bg)]"> <path d="M12 2L2 7l10 5 10-5-10-5z"/> <path d="M2 17l10 5 10-5"/> <path d="M2 12l10 5 10-5"/> </svg> </div> <div> <h1 class="text-xl font-bold">Motion.css</h1> <p class="text-xs text-[var(--color-text-muted)]">Custom Animation Library</p> </div> </div> <div class="flex items-center gap-4"> <!-- Theme Picker --> <div class="flex items-center gap-2"> <button class="theme-dot active" data-theme="dark" style="background: linear-gradient(135deg, #0a0a0f, #1a1a24);" title="Dark Theme"></button> <button class="theme-dot" data-theme="light" style="background: linear-gradient(135deg, #f5f5f7, #ffffff);" title="Light Theme"></button> <button class="theme-dot" data-theme="ocean" style="background: linear-gradient(135deg, #0d1b2a, #00b4d8);" title="Ocean Theme"></button> <button class="theme-dot" data-theme="sunset" style="background: linear-gradient(135deg, #1a1423, #ff7b54);" title="Sunset Theme"></button> <button class="theme-dot" data-theme="forest" style="background: linear-gradient(135deg, #0f1a0f, #4ade80);" title="Forest Theme"></button> </div> </div> </div> </div> </header> <!-- Hero Section --> <section class="py-20 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto"> <div class="text-center mb-16"> <h2 class="text-5xl sm:text-6xl font-bold mb-6 animate fade-in-up animate-slow"> Powerful CSS Animations </h2> <p class="text-xl text-[var(--color-text-muted)] max-w-2xl mx-auto animate fade-in-up delay-200"> A comprehensive animation library built with pure CSS and CSS variables for complete theme control. </p> <!-- Quick Stats --> <div class="flex justify-center gap-8 mt-10 stagger-children in-view"> <div class="text-center"> <div class="text-3xl font-bold text-[var(--color-accent)]">40+</div> <div class="text-sm text-[var(--color-text-muted)]">Animations</div> </div> <div class="text-center"> <div class="text-3xl font-bold text-[var(--color-accent)]">5</div> <div class="text-sm text-[var(--color-text-muted)]">Themes</div> </div> <div class="text-center"> <div class="text-3xl font-bold text-[var(--color-accent)]">0KB</div> <div class="text-sm text-[var(--color-text-muted)]">JavaScript</div> </div> </div> </div> </section> <!-- Category Tabs --> <section class="px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto mb-8"> <div class="flex flex-wrap gap-2" id="category-tabs" role="tablist"> <button class="tab active" data-category="entrance" role="tab" aria-selected="true">Entrance</button> <button class="tab" data-category="attention" role="tab" aria-selected="false">Attention</button> <button class="tab" data-category="continuous" role="tab" aria-selected="false">Continuous</button> <button class="tab" data-category="text" role="tab" aria-selected="false">Text Effects</button> <button class="tab" data-category="hover" role="tab" aria-selected="false">Hover Effects</button> <button class="tab" data-category="loaders" role="tab" aria-selected="false">Loaders</button> </div> </section> <!-- Animation Grid --> <section class="px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto pb-20"> <div id="animation-grid" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4"> <!-- Animation cards will be injected here --> </div> </section> <!-- Theme Customizer Panel --> <section class="px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto pb-20"> <div class="card p-6"> <h3 class="text-xl font-bold mb-6 flex items-center gap-2"> <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <circle cx="12" cy="12" r="3"/> <path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/> </svg> Theme Customizer </h3> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> <div> <label class="block text-sm text-[var(--color-text-muted)] mb-2">Accent Color</label> <div class="flex items-center gap-2"> <input type="color" id="custom-accent" value="#00d4aa" class="w-10 h-10 rounded cursor-pointer border-0"> <input type="text" id="custom-accent-text" value="#00d4aa" class="bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-2 font-mono text-sm w-28"> </div> </div> <div> <label class="block text-sm text-[var(--color-text-muted)] mb-2">Animation Speed</label> <input type="range" id="anim-speed" min="100" max="1000" value="400" class="w-full"> <div class="flex justify-between text-xs text-[var(--color-text-muted)] mt-1"> <span>Fast</span> <span id="speed-value">400ms</span> <span>Slow</span> </div> </div> <div> <label class="block text-sm text-[var(--color-text-muted)] mb-2">Border Radius</label> <input type="range" id="border-radius" min="0" max="24" value="8" class="w-full"> <div class="flex justify-between text-xs text-[var(--color-text-muted)] mt-1"> <span>Sharp</span> <span id="radius-value">8px</span> <span>Round</span> </div> </div> </div> </div> </section> </div> <!-- Toast Notification --> <div id="toast" class="toast"> <span class="text-[var(--color-accent)]">Copied to clipboard!</span> </div> <script> // Animation data organized by category const animations = { entrance: [ { name: 'Fade In', class: 'fade-in', code: 'animation: fadeIn 0.4s ease-out;' }, { name: 'Fade In Up', class: 'fade-in-up', code: 'animation: fadeInUp 0.4s ease-out;' }, { name: 'Fade In Down', class: 'fade-in-down', code: 'animation: fadeInDown 0.4s ease-out;' }, { name: 'Fade In Left', class: 'fade-in-left', code: 'animation: fadeInLeft 0.4s ease-out;' }, { name: 'Fade In Right', class: 'fade-in-right', code: 'animation: fadeInRight 0.4s ease-out;' }, { name: 'Scale In', class: 'scale-in', code: 'animation: scaleIn 0.4s ease-out;' }, { name: 'Scale In Bounce', class: 'scale-in-bounce', code: 'animation: scaleInBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);' }, { name: 'Slide In Left', class: 'slide-in-left', code: 'animation: slideInLeft 0.4s ease-out;' }, { name: 'Slide In Right', class: 'slide-in-right', code: 'animation: slideInRight 0.4s ease-out;' }, { name: 'Slide In Up', class: 'slide-in-up', code: 'animation: slideInUp 0.4s ease-out;' }, { name: 'Rotate In', class: 'rotate-in', code: 'animation: rotateIn 0.6s ease-out;' }, { name: 'Flip In', class: 'flip-in', code: 'animation: flipIn 0.6s ease-out;' }, { name: 'Zoom In', class: 'zoom-in', code: 'animation: zoomIn 0.4s ease-out;' }, { name: 'Roll In', class: 'roll-in', code: 'animation: rollIn 0.6s ease-out;' }, ], attention: [ { name: 'Pulse', class: 'pulse', code: 'animation: pulse 1s ease-in-out infinite;' }, { name: 'Bounce', class: 'bounce', code: 'animation: bounce 1s ease-in-out infinite;' }, { name: 'Shake', class: 'shake', code: 'animation: shake 0.5s ease-in-out;' }, { name: 'Wobble', class: 'wobble', code: 'animation: wobble 1s ease-in-out;' }, { name: 'Swing', class: 'swing', code: 'animation: swing 1s ease-in-out;' }, { name: 'Tada', class: 'tada', code: 'animation: tada 1s ease-in-out;' }, { name: 'Heart Beat', class: 'heart-beat', code: 'animation: heartBeat 1.3s ease-in-out infinite;' }, { name: 'Flash', class: 'flash', code: 'animation: flash 1s ease-in-out;' }, { name: 'Rubber Band', class: 'rubber-band', code: 'animation: rubberBand 1s ease-in-out;' }, { name: 'Jello', class: 'jello', code: 'animation: jello 1s ease-in-out;' }, { name: 'Head Shake', class: 'head-shake', code: 'animation: headShake 1s ease-in-out;' }, ], continuous: [ { name: 'Spin', class: 'spin', code: 'animation: spin 1s linear infinite;' }, { name: 'Spin Reverse', class: 'spin-reverse', code: 'animation: spinReverse 1s linear infinite;' }, { name: 'Ping', class: 'ping', code: 'animation: ping 1s ease-in-out infinite;' }, { name: 'Float', class: 'float', code: 'animation: float 3s ease-in-out infinite;' }, { name: 'Float Rotate', class: 'float-rotate', code: 'animation: floatRotate 3s ease-in-out infinite;' }, { name: 'Glow', class: 'glow', code: 'animation: glow 2s ease-in-out infinite;' }, { name: 'Wave', class: 'wave', code: 'animation: wave 1s ease-in-out infinite;' }, { name: 'Morph', class: 'morph', code: 'animation: morph 8s ease-in-out infinite;' }, { name: 'Breathe', class: 'breathe', code: 'animation: breathe 4s ease-in-out infinite;' }, ], text: [ { name: 'Text Glow', class: 'text-glow', code: 'animation: textGlow 2s ease-in-out infinite;' }, { name: 'Glitch', class: 'glitch', code: 'animation: glitch 0.3s ease-in-out infinite;' }, ], hover: [ { name: 'Hover Scale', class: 'hover-scale', code: 'transition: transform 0.3s;\n:hover { transform: scale(1.05); }', isHover: true }, { name: 'Hover Lift', class: 'hover-lift', code: 'transition: all 0.3s;\n:hover { transform: translateY(-4px); }', isHover: true }, { name: 'Hover Glow', class: 'hover-glow', code: 'transition: box-shadow 0.3s;\n:hover { box-shadow: 0 0 30px var(--color-accent-dim); }', isHover: true }, { name: 'Hover Rotate', class: 'hover-rotate', code: 'transition: transform 0.3s;\n:hover { transform: rotate(5deg); }', isHover: true }, ], loaders: [ { name: 'Dots', class: 'loader-dots', code: '.loader-dots span {\n animation: bounce 1.4s infinite;\n}', isLoader: true }, { name: 'Spinner', class: 'loader-spinner', code: 'animation: spin 0.8s linear infinite;\nborder-top-color: var(--color-accent);', isLoader: true }, { name: 'Ring', class: 'loader-ring', code: 'animation: spin 1s linear infinite;\nborder-top-color: var(--color-accent);', isLoader: true }, ], }; // DOM elements - initialized after data const grid = document.getElementById('animation-grid'); const tabs = document.querySelectorAll('.tab'); const themeDots = document.querySelectorAll('.theme-dot'); const toast = document.getElementById('toast'); const customAccent = document.getElementById('custom-accent'); const customAccentText = document.getElementById('custom-accent-text'); const animSpeed = document.getElementById('anim-speed'); const speedValue = document.getElementById('speed-value'); const borderRadius = document.getElementById('border-radius'); const radiusValue = document.getElementById('radius-value'); // Current category let currentCategory = 'entrance'; // Render animation cards function renderAnimations(category) { const items = animations[category]; if (!items || !grid) return; grid.innerHTML = items.map((anim, index) => ` <div class="card p-4 animate fade-in-up" style="animation-delay: ${index * 50}ms"> <div class="flex items-center justify-between mb-4"> <h4 class="font-semibold text-sm">${anim.name}</h4> <button class="copy-btn text-[var(--color-text-muted)] hover:text-[var(--color-accent)] transition-all p-1" data-code="${anim.code}" title="Copy code" aria-label="Copy ${anim.name} code"> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <rect x="9" y="9" width="13" height="13" rx="2" ry="2"/> <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/> </svg> </button> </div> <div class="flex items-center justify-center h-24 bg-[var(--color-bg)] rounded-lg mb-4 overflow-hidden"> ${anim.isLoader ? renderLoader(anim.class) : ` <div class="preview-box animate ${anim.class} ${anim.isHover ? 'transition-all ' + anim.class : ''}" style="animation-duration: var(--anim-duration-normal); animation-iteration-count: ${anim.class.includes('shake') || anim.class.includes('wobble') || anim.class.includes('tada') ? '1' : 'infinite'}"> </div> `} </div> <div class="code-block text-xs max-h-20 overflow-auto"> <span class="comment">/* ${anim.name} */</span> <br><span class="property">${anim.code.split('\n').join('</span><br><span class="property">')}</span> </div> </div> `).join(''); // Add copy functionality document.querySelectorAll('.copy-btn').forEach(btn => { btn.addEventListener('click', () => { const code = btn.dataset.code; navigator.clipboard.writeText(code).then(() => { showToast(); }); }); }); } // Render loader preview function renderLoader(loaderClass) { if (loaderClass === 'loader-dots') { return `<div class="loader-dots"><span></span><span></span><span></span></div>`; } return `<div class="${loaderClass}"></div>`; } // Show toast notification function showToast() { if (!toast) return; toast.classList.add('show'); setTimeout(() => { toast.classList.remove('show'); }, 2000); } // Category tab switching tabs.forEach(tab => { tab.addEventListener('click', () => { tabs.forEach(t => { t.classList.remove('active'); t.setAttribute('aria-selected', 'false'); }); tab.classList.add('active'); tab.setAttribute('aria-selected', 'true'); currentCategory = tab.dataset.category; renderAnimations(currentCategory); }); }); // Theme switching themeDots.forEach(dot => { dot.addEventListener('click', () => { themeDots.forEach(d => d.classList.remove('active')); dot.classList.add('active'); document.documentElement.setAttribute('data-theme', dot.dataset.theme); }); }); // Custom accent color if (customAccent) { customAccent.addEventListener('input', (e) => { const color = e.target.value; if (customAccentText) customAccentText.value = color; document.documentElement.style.setProperty('--color-accent', color); document.documentElement.style.setProperty('--color-accent-dim', color + '26'); }); } if (customAccentText) { customAccentText.addEventListener('change', (e) => { const color = e.target.value; if (/^#[0-9A-Fa-f]{6}$/.test(color)) { if (customAccent) customAccent.value = color; document.documentElement.style.setProperty('--color-accent', color); document.documentElement.style.setProperty('--color-accent-dim', color + '26'); } }); } // Animation speed if (animSpeed) { animSpeed.addEventListener('input', (e) => { const value = e.target.value; if (speedValue) speedValue.textContent = value + 'ms'; document.documentElement.style.setProperty('--anim-duration-normal', value + 'ms'); }); } // Border radius if (borderRadius) { borderRadius.addEventListener('input', (e) => { const value = e.target.value; if (radiusValue) radiusValue.textContent = value + 'px'; document.documentElement.style.setProperty('--radius-md', value + 'px'); }); } // Create floating particles function createParticles() { const container = document.getElementById('particles'); if (!container) return; const particleCount = 20; for (let i = 0; i < particleCount; i++) { const particle = document.createElement('div'); particle.className = 'particle'; // Random position particle.style.left = Math.random() * 100 + '%'; particle.style.top = Math.random() * 100 + '%'; // Random animation const duration = 3 + Math.random() * 4; const delay = Math.random() * 2; particle.style.animation = `float ${duration}s ease-in-out ${delay}s infinite`; // Random size const size = 2 + Math.random() * 4; particle.style.width = size + 'px'; particle.style.height = size + 'px'; container.appendChild(particle); } } // Intersection Observer for scroll animations function initScrollAnimations() { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('in-view'); } }); }, { threshold: 0.1 }); document.querySelectorAll('.scroll-animate, .stagger-children').forEach(el => { observer.observe(el); }); } // Initialize document.addEventListener('DOMContentLoaded', () => { renderAnimations(currentCategory); createParticles(); initScrollAnimations(); }); </script> </body> </html>Key Features
Animation Categories
- Entrance Animations - fade-in, slide-in, scale-in, rotate-in, flip-in, zoom-in, roll-in
- Attention Seekers - pulse, bounce, shake, wobble, swing, tada, heartbeat, flash, rubberband, jello
- Continuous Animations - spin, ping, float, glow, wave, morph, breathe
- Text Effects - text-glow, glitch
- Hover Effects - scale, lift, glow, rotate on hover
- Loaders - dots, spinner, ring
Theme System
- 5 Built-in Themes: Dark, Light, Ocean, Sunset, Forest
- CSS Variables for all colors, spacing, timing, and radii
- Live Theme Customizer: Change accent color, animation speed, border radius in real-time
Technical Highlights
- Zero JavaScript for Animations - All animations are pure CSS keyframes
- CSS Custom Properties - Complete theming via
--color-*,--anim-*,--space-*,--radius-*variables - Utility Classes -
.animate-fast,.animate-slow,.delay-*,.ease-bounce,.animate-infinite - Scroll Triggered - Staggered entrance animations on scroll
- Reduced Motion - Respects
prefers-reduced-motionmedia query - Accessibility - ARIA labels, focus-visible states, semantic HTML
Interactive Features
- Live animation previews for each effect
- Copy-to-clipboard for animation code
- Theme picker with instant switching
- Custom accent color picker
- Animation speed slider
- Border radius control
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.