The user wants me to create a reusable animation library using vanilla CSS keyframes and CSS variables (custom properties). This should be a comprehensive, well-organized library that can be easily reused across projects.
Let me think about what makes a great animation library:
-
Core Features:
- CSS Custom Properties for easy customization
- Named keyframe animations
- Utility classes for quick application
- Staggered/delayed animations
- Hover and interaction states
- Entrance/exit animations
- Attention-grabbing effects
- Motion preferences (prefers-reduced-motion)
-
Animation Categories:
- Fade (in, out, up, down, left, right)
- Slide (from different directions)
- Scale (grow, shrink, pop)
- Rotate (spin, wiggle, flip)
- Bounce
- Pulse
- Shake
- Float
- Blur
- Typing effect
- Glitch
- Morph/blob
-
Controls via CSS Variables:
- --animation-duration
- --animation-delay
- --animation-timing-function
- --animation-iteration-count
- --animation-fill-mode
- --animation-distance (for slides)
- --animation-scale
- --animation-rotate
-
Interactive Demo Page:
- Show all animations
- Allow customization
- Copy code feature
- Live preview
- Dark theme (per design spec)
-
Structure:
- animations.css - The core library file
- A demo HTML page to showcase
Let me create a comprehensive, modern, and visually striking animation library with a beautiful demo page.
Reusable CSS Animation Library
I'll create a comprehensive, customizable animation library with a beautiful interactive demo page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Motion CSS - Animation Library</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<!-- ========================================
MOTION CSS - REUSABLE ANIMATION LIBRARY
======================================== -->
<style>
/* ========================================
1. CSS CUSTOM PROPERTIES (CONFIGURATION)
======================================== */
:root {
/* Core Animation Settings */
--motion-duration-fast: 200ms;
--motion-duration-normal: 500ms;
--motion-duration-slow: 800ms;
--motion-duration-slower: 1200ms;
--motion-duration-slowest: 2000ms;
/* Easing Functions */
--motion-ease-default: cubic-bezier(0.4, 0, 0.2, 1);
--motion-ease-in: cubic-bezier(0.4, 0, 1, 1);
--motion-ease-out: cubic-bezier(0, 0, 0.2, 1);
--motion-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
--motion-ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
--motion-ease-elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6);
--motion-ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
/* Animation Distances */
--motion-distance-sm: 10px;
--motion-distance-md: 20px;
--motion-distance-lg: 40px;
--motion-distance-xl: 60px;
/* Transform Values */
--motion-scale-in: 0;
--motion-scale-out: 0;
--motion-scale-grow: 1.2;
--motion-scale-shrink: 0.8;
--motion-rotate-amount: 360deg;
--motion-skew-amount: 10deg;
/* Colors for Effects */
--motion-color-primary: #6366f1;
--motion-color-secondary: #8b5cf6;
--motion-glow-color: rgba(99, 102, 241, 0.5);
}
/* ========================================
2. BASE ANIMATION UTILITY CLASS
======================================== */
.motion {
animation-duration: var(--motion-duration-normal, 500ms);
animation-timing-function: var(--motion-ease-default);
animation-fill-mode: both;
}
/* Speed Modifiers */
.motion-fast { animation-duration: var(--motion-duration-fast) !important; }
.motion-slow { animation-duration: var(--motion-duration-slow) !important; }
.motion-slower { animation-duration: var(--motion-duration-slower) !important; }
.motion-slowest { animation-duration: var(--motion-duration-slowest) !important; }
/* Easing Modifiers */
.motion-ease-bounce { animation-timing-function: var(--motion-ease-bounce) !important; }
.motion-ease-elastic { animation-timing-function: var(--motion-ease-elastic) !important; }
.motion-ease-spring { animation-timing-function: var(--motion-ease-spring) !important; }
/* Iteration Modifiers */
.motion-infinite { animation-iteration-count: infinite !important; }
.motion-once { animation-iteration-count: 1 !important; }
.motion-twice { animation-iteration-count: 2 !important; }
/* Fill Mode Modifiers */
.motion-forwards { animation-fill-mode: forwards !important; }
.motion-backwards { animation-fill-mode: backwards !important; }
.motion-both { animation-fill-mode: both !important; }
/* Delay Utilities */
.motion-delay-100 { animation-delay: 100ms !important; }
.motion-delay-200 { animation-delay: 200ms !important; }
.motion-delay-300 { animation-delay: 300ms !important; }
.motion-delay-400 { animation-delay: 400ms !important; }
.motion-delay-500 { animation-delay: 500ms !important; }
.motion-delay-700 { animation-delay: 700ms !important; }
.motion-delay-1000 { animation-delay: 1000ms !important; }
/* ========================================
3. FADE ANIMATIONS
======================================== */
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes fade-out {
from { opacity: 1; }
to { opacity: 0; }
}
@keyframes fade-in-up {
from {
opacity: 0;
transform: translateY(var(--motion-distance-lg));
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fade-in-down {
from {
opacity: 0;
transform: translateY(calc(var(--motion-distance-lg) * -1));
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fade-in-left {
from {
opacity: 0;
transform: translateX(calc(var(--motion-distance-lg) * -1));
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes fade-in-right {
from {
opacity: 0;
transform: translateX(var(--motion-distance-lg));
}
to {
opacity: 1;
transform: translateX(0);
}
}
.animate-fade-in { animation-name: fade-in; }
.animate-fade-out { animation-name: fade-out; }
.animate-fade-in-up { animation-name: fade-in-up; }
.animate-fade-in-down { animation-name: fade-in-down; }
.animate-fade-in-left { animation-name: fade-in-left; }
.animate-fade-in-right { animation-name: fade-in-right; }
/* ========================================
4. SLIDE ANIMATIONS
======================================== */
@keyframes slide-up {
from { transform: translateY(100%); }
to { transform: translateY(0); }
}
@keyframes slide-down {
from { transform: translateY(-100%); }
to { transform: translateY(0); }
}
@keyframes slide-left {
from { transform: translateX(100%); }
to { transform: translateX(0); }
}
@keyframes slide-right {
from { transform: translateX(-100%); }
to { transform: translateX(0); }
}
@keyframes slide-out-up {
from { transform: translateY(0); }
to { transform: translateY(-100%); }
}
@keyframes slide-out-down {
from { transform: translateY(0); }
to { transform: translateY(100%); }
}
.animate-slide-up { animation-name: slide-up; }
.animate-slide-down { animation-name: slide-down; }
.animate-slide-left { animation-name: slide-left; }
.animate-slide-right { animation-name: slide-right; }
.animate-slide-out-up { animation-name: slide-out-up; }
.animate-slide-out-down { animation-name: slide-out-down; }
/* ========================================
5. SCALE ANIMATIONS
======================================== */
@keyframes scale-in {
from {
opacity: 0;
transform: scale(var(--motion-scale-in));
}
to {
opacity: 1;
transform: scale(1);
}
}
@keyframes scale-out {
from {
opacity: 1;
transform: scale(1);
}
to {
opacity: 0;
transform: scale(var(--motion-scale-out));
}
}
@keyframes scale-up {
from { transform: scale(1); }
to { transform: scale(var(--motion-scale-grow)); }
}
@keyframes scale-down {
from { transform: scale(1); }
to { transform: scale(var(--motion-scale-shrink)); }
}
@keyframes pop {
0% { transform: scale(1); }
50% { transform: scale(var(--motion-scale-grow)); }
100% { transform: scale(1); }
}
@keyframes pop-in {
0% {
opacity: 0;
transform: scale(0.5);
}
70% {
transform: scale(1.1);
}
100% {
opacity: 1;
transform: scale(1);
}
}
.animate-scale-in { animation-name: scale-in; }
.animate-scale-out { animation-name: scale-out; }
.animate-scale-up { animation-name: scale-up; }
.animate-scale-down { animation-name: scale-down; }
.animate-pop { animation-name: pop; }
.animate-pop-in { animation-name: pop-in; }
/* ========================================
6. ROTATE ANIMATIONS
======================================== */
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(var(--motion-rotate-amount)); }
}
@keyframes spin-reverse {
from { transform: rotate(var(--motion-rotate-amount)); }
to { transform: rotate(0deg); }
}
@keyframes wiggle {
0%, 100% { transform: rotate(0deg); }
25% { transform: rotate(calc(var(--motion-skew-amount) * -1)); }
75% { transform: rotate(var(--motion-skew-amount)); }
}
@keyframes swing {
0% { transform: rotate(0deg); }
20% { transform: rotate(15deg); }
40% { transform: rotate(-10deg); }
60% { transform: rotate(5deg); }
80% { transform: rotate(-5deg); }
100% { transform: rotate(0deg); }
}
@keyframes flip {
0% {
transform: perspective(400px) rotateY(0);
}
100% {
transform: perspective(400px) rotateY(360deg);
}
}
@keyframes flip-x {
0% {
transform: perspective(400px) rotateX(0);
}
100% {
transform: perspective(400px) rotateX(360deg);
}
}
.animate-spin { animation-name: spin; animation-timing-function: linear; }
.animate-spin-reverse { animation-name: spin-reverse; animation-timing-function: linear; }
.animate-wiggle { animation-name: wiggle; }
.animate-swing { animation-name: swing; }
.animate-flip { animation-name: flip; }
.animate-flip-x { animation-name: flip-x; }
/* ========================================
7. BOUNCE ANIMATIONS
======================================== */
@keyframes bounce {
0%, 100% {
transform: translateY(0);
animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
}
50% {
transform: translateY(-25%);
animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
}
}
@keyframes bounce-in {
0% {
opacity: 0;
transform: scale(0.3);
}
50% {
transform: scale(1.05);
}
70% {
transform: scale(0.9);
}
100% {
opacity: 1;
transform: scale(1);
}
}
@keyframes bounce-out {
0% { transform: scale(1); }
25% { transform: scale(0.95); }
50% {
opacity: 1;
transform: scale(1.1);
}
100% {
opacity: 0;
transform: scale(0.3);
}
}
@keyframes rubber-band {
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); }
}
.animate-bounce { animation-name: bounce; }
.animate-bounce-in { animation-name: bounce-in; }
.animate-bounce-out { animation-name: bounce-out; }
.animate-rubber-band { animation-name: rubber-band; }
/* ========================================
8. ATTENTION ANIMATIONS
======================================== */
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
@keyframes pulse-scale {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
20%, 40%, 60%, 80% { transform: translateX(5px); }
}
@keyframes head-shake {
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); }
}
@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 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 jello {
0%, 100% { transform: skewX(0deg) skewY(0deg); }
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); }
}
.animate-pulse { animation-name: pulse; }
.animate-pulse-scale { animation-name: pulse-scale; }
.animate-shake { animation-name: shake; }
.animate-head-shake { animation-name: head-shake; }
.animate-heartbeat { animation-name: heartbeat; }
.animate-tada { animation-name: tada; }
.animate-jello { animation-name: jello; }
/* ========================================
9. FLOAT & HOVER ANIMATIONS
======================================== */
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
@keyframes float-rotate {
0%, 100% {
transform: translateY(0) rotate(0deg);
}
50% {
transform: translateY(-10px) rotate(3deg);
}
}
@keyframes hover-lift {
0%, 100% { transform: translateY(0) scale(1); }
50% { transform: translateY(-5px) scale(1.02); }
}
@keyframes sway {
0%, 100% { transform: rotate(-3deg); }
50% { transform: rotate(3deg); }
}
.animate-float { animation-name: float; }
.animate-float-rotate { animation-name: float-rotate; }
.animate-hover-lift { animation-name: hover-lift; }
.animate-sway { animation-name: sway; }
/* ========================================
10. REVEAL ANIMATIONS
======================================== */
@keyframes reveal-up {
0% {
clip-path: inset(100% 0 0 0);
opacity: 0;
}
100% {
clip-path: inset(0 0 0 0);
opacity: 1;
}
}
@keyframes reveal-down {
0% {
clip-path: inset(0 0 100% 0);
opacity: 0;
}
100% {
clip-path: inset(0 0 0 0);
opacity: 1;
}
}
@keyframes reveal-left {
0% {
clip-path: inset(0 100% 0 0);
opacity: 0;
}
100% {
clip-path: inset(0 0 0 0);
opacity: 1;
}
}
@keyframes reveal-right {
0% {
clip-path: inset(0 0 0 100%);
opacity: 0;
}
100% {
clip-path: inset(0 0 0 0);
opacity: 1;
}
}
@keyframes expand-h {
0% {
clip-path: inset(0 50% 0 50%);
}
100% {
clip-path: inset(0 0 0 0);
}
}
@keyframes expand-v {
0% {
clip-path: inset(50% 0 50% 0);
}
100% {
clip-path: inset(0 0 0 0);
}
}
.animate-reveal-up { animation-name: reveal-up; }
.animate-reveal-down { animation-name: reveal-down; }
.animate-reveal-left { animation-name: reveal-left; }
.animate-reveal-right { animation-name: reveal-right; }
.animate-expand-h { animation-name: expand-h; }
.animate-expand-v { animation-name: expand-v; }
/* ========================================
11. SPECIAL EFFECTS
======================================== */
@keyframes glow-pulse {
0%, 100% {
box-shadow: 0 0 5px var(--motion-glow-color),
0 0 10px var(--motion-glow-color);
}
50% {
box-shadow: 0 0 20px var(--motion-glow-color),
0 0 40px var(--motion-glow-color);
}
}
@keyframes blur-in {
0% {
opacity: 0;
filter: blur(20px);
}
100% {
opacity: 1;
filter: blur(0);
}
}
@keyframes blur-out {
0% {
opacity: 1;
filter: blur(0);
}
100% {
opacity: 0;
filter: blur(20px);
}
}
@keyframes typewriter {
from { width: 0; }
to { width: 100%; }
}
@keyframes blink-caret {
from, to { border-color: transparent; }
50% { border-color: currentColor; }
}
@keyframes gradient-shift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
@keyframes shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}
@keyframes ripple {
0% {
transform: scale(0);
opacity: 1;
}
100% {
transform: scale(4);
opacity: 0;
}
}
.animate-glow-pulse { animation-name: glow-pulse; }
.animate-blur-in { animation-name: blur-in; }
.animate-blur-out { animation-name: blur-out; }
.animate-gradient-shift {
animation-name: gradient-shift;
background-size: 200% 200%;
}
.animate-shimmer {
animation-name: shimmer;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
background-size: 200% 100%;
}
.animate-ripple { animation-name: ripple; }
/* ========================================
12. ENTRANCE SEQUENCES
======================================== */
@keyframes drop-in {
0% {
opacity: 0;
transform: translateY(-100px) scale(0.8);
}
60% {
transform: translateY(10px) scale(1.02);
}
100% {
opacity: 1;
transform: translateY(0) scale(1);
}
}
@keyframes whoosh-in-left {
0% {
opacity: 0;
transform: translateX(-100px) skewX(20deg);
}
60% {
transform: translateX(10px) skewX(-5deg);
}
100% {
opacity: 1;
transform: translateX(0) skewX(0);
}
}
@keyframes whoosh-in-right {
0% {
opacity: 0;
transform: translateX(100px) skewX(-20deg);
}
60% {
transform: translateX(-10px) skewX(5deg);
}
100% {
opacity: 1;
transform: translateX(0) skewX(0);
}
}
@keyframes flip-in {
0% {
opacity: 0;
transform: perspective(500px) rotateX(90deg);
}
100% {
opacity: 1;
transform: perspective(500px) rotateX(0);
}
}
@keyframes rotate-scale-in {
0% {
opacity: 0;
transform: rotate(-180deg) scale(0);
}
100% {
opacity: 1;
transform: rotate(0) scale(1);
}
}
.animate-drop-in { animation-name: drop-in; }
.animate-whoosh-in-left { animation-name: whoosh-in-left; }
.animate-whoosh-in-right { animation-name: whoosh-in-right; }
.animate-flip-in { animation-name: flip-in; }
.animate-rotate-scale-in { animation-name: rotate-scale-in; }
/* ========================================
13. TEXT ANIMATIONS
======================================== */
@keyframes text-shadow-pop {
0% {
text-shadow: 0 0 rgba(0,0,0,0), 0 0 rgba(0,0,0,0);
}
100% {
text-shadow:
2px 2px 0 var(--motion-color-primary),
-2px -2px 0 var(--motion-color-secondary);
}
}
@keyframes tracking-in {
0% {
opacity: 0;
letter-spacing: 1em;
}
100% {
opacity: 1;
letter-spacing: normal;
}
}
@keyframes focus-in {
0% {
opacity: 0;
filter: blur(12px);
}
100% {
opacity: 1;
filter: blur(0);
}
}
.animate-text-shadow-pop { animation-name: text-shadow-pop; }
.animate-tracking-in { animation-name: tracking-in; }
.animate-focus-in { animation-name: focus-in; }
/* ========================================
14. REDUCED MOTION
======================================== */
@media (prefers-reduced-motion: reduce) {
.motion,
[class*="animate-"] {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
/* Class to manually disable animations */
.motion-off,
.motion-off * {
animation: none !important;
transition: none !important;
}
/* ========================================
15. HOVER INTERACTIONS
======================================== */
.hover-bounce:hover {
animation: bounce 0.5s ease;
}
.hover-pop:hover {
animation: pop 0.3s ease;
}
.hover-shake:hover {
animation: shake 0.5s ease;
}
.hover-wiggle:hover {
animation: wiggle 0.5s ease;
}
.hover-pulse:hover {
animation: pulse-scale 0.3s ease;
}
.hover-swing:hover {
animation: swing 0.5s ease;
}
.hover-tada:hover {
animation: tada 0.5s ease;
}
.hover-heartbeat:hover {
animation: heartbeat 0.6s ease;
}
/* ========================================
16. SCROLL-TRIGGERED (via IntersectionObserver)
======================================== */
.scroll-animate {
opacity: 0;
}
.scroll-animate.is-visible {
opacity: 1;
}
/* ========================================
17. STAGGER UTILITIES (CSS only approximation)
======================================== */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }
.stagger-children > *:nth-child(9) { animation-delay: 400ms; }
.stagger-children > *:nth-child(10) { animation-delay: 450ms; }
.stagger-slow > *:nth-child(1) { animation-delay: 0ms; }
.stagger-slow > *:nth-child(2) { animation-delay: 100ms; }
.stagger-slow > *:nth-child(3) { animation-delay: 200ms; }
.stagger-slow > *:nth-child(4) { animation-delay: 300ms; }
.stagger-slow > *:nth-child(5) { animation-delay: 400ms; }
.stagger-slow > *:nth-child(6) { animation-delay: 500ms; }
.stagger-slow > *:nth-child(7) { animation-delay: 600ms; }
.stagger-slow > *:nth-child(8) { animation-delay: 700ms; }
.stagger-slow > *:nth-child(9) { animation-delay: 800ms; }
.stagger-slow > *:nth-child(10) { animation-delay: 900ms; }
</style>
<!-- Demo Page Styles -->
<style>
body {
font-family: 'Inter', sans-serif;
background: #0a0a0a;
color: #f5f5f4;
min-height: 100vh;
}
.serif { font-family: 'Playfair Display', serif; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #44403c; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #78716c; }
.demo-box {
width: 80px;
height: 80px;
background: linear-gradient(135deg, #6366f1, #8b5cf6);
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 24px;
cursor: pointer;
transition: transform 0.2s ease;
}
.demo-box:hover {
transform: scale(1.05);
}
.code-block {
background: #171717;
border-radius: 8px;
padding: 16px;
font-family: 'Monaco', 'Consolas', monospace;
font-size: 13px;
overflow-x: auto;
border: 1px solid #262626;
}
.code-block .keyword { color: #c084fc; }
.code-block .string { color: #4ade80; }
.code-block .property { color: #60a5fa; }
.code-block .value { color: #fb923c; }
.code-block .comment { color: #525252; }
.nav-link {
transition: color 0.2s ease;
}
.nav-link:hover {
color: #f5f5f4;
}
.category-card {
background: linear-gradient(145deg, #171717, #0d0d0d);
border: 1px solid #262626;
border-radius: 16px;
padding: 32px;
transition: all 0.3s ease;
}
.category-card:hover {
border-color: #44403c;
transform: translateY(-4px);
}
.tab-btn {
transition: all 0.2s ease;
}
.tab-btn.active {
background: linear-gradient(135deg, #6366f1, #8b5cf6);
color: white;
}
.play-btn {
position: absolute;
inset: 0;
background: rgba(0,0,0,0.6);
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
transition: opacity 0.2s ease;
border-radius: 12px;
}
.demo-wrapper:hover .play-btn {
opacity: 1;
}
</style>
</head>
<body class="antialiased">
<!-- Navigation -->
<nav class="fixed top-0 left-0 right-0 z-50 backdrop-blur-xl bg-black/70 border-b border-white/5">
<div class="max-w-7xl mx-auto px-6 md:px-12">
<div class="flex items-center justify-between h-20">
<a href="#" class="flex items-center gap-3">
<div class="w-10 h-10 rounded-xl bg-gradient-to-br from-violet-600 to-indigo-600 flex items-center justify-center">
<span class="text-white font-bold text-lg">M</span>
</div>
<span class="text-stone-100 font-semibold text-lg tracking-tight">Motion CSS</span>
</a>
<div class="hidden md:flex items-center gap-8">
<a href="#animations" class="nav-link text-sm text-stone-400 hover:text-stone-100">Animations</a>
<a href="#utilities" class="nav-link text-sm text-stone-400 hover:text-stone-100">Utilities</a>
<a href="#usage" class="nav-link text-sm text-stone-400 hover:text-stone-100">Usage</a>
<a href="#download" class="px-5 py-2.5 bg-gradient-to-r from-violet-600 to-indigo-600 text-white text-xs font-semibold uppercase tracking-wider rounded-full hover:shadow-lg hover:shadow-violet-500/25 transition-all">
Download
</a>
</div>
</div>
</div>
</nav>
<!-- Hero Section -->
<section class="min-h-screen flex items-center justify-center pt-20 px-6">
<div class="max-w-5xl mx-auto text-center">
<!-- Animated Logo -->
<div class="mb-8 flex justify-center">
<div class="w-24 h-24 rounded-2xl bg-gradient-to-br from-violet-600 to-indigo-600 flex items-center justify-center motion animate-float motion-infinite motion-slowest">
<span class="text-white font-bold text-4xl">M</span>
</div>
</div>
<h1 class="serif text-5xl md:text-7xl lg:text-8xl font-normal tracking-tighter leading-[0.9] mb-8">
<span class="text-stone-100">Motion</span>
<span class="bg-gradient-to-r from-violet-400 to-indigo-400 bg-clip-text text-transparent"> CSS</span>
</h1>
<p class="text-stone-400 text-lg md:text-xl max-w-2xl mx-auto mb-12 leading-relaxed">
A lightweight, reusable animation library built with pure CSS keyframes and custom properties.
Zero dependencies, fully customizable.
</p>
<div class="flex flex-col sm:flex-row gap-4 justify-center">
<a href="#animations" class="px-8 py-4 bg-white text-black text-xs font-bold uppercase tracking-widest rounded-full hover:bg-stone-200 transition-all">
Explore Animations
</a>
<button onclick="copyToClipboard()" class="px-8 py-4 border border-stone-700 text-stone-300 text-xs font-bold uppercase tracking-widest rounded-full hover:bg-white/5 transition-all flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"/>
</svg>
Copy Library
</button>
</div>
<!-- Stats -->
<div class="mt-20 grid grid-cols-3 gap-8 max-w-lg mx-auto">
<div class="text-center">
<div class="text-3xl font-semibold text-stone-100">50+</div>
<div class="text-stone-500 text-sm mt-1">Animations</div>
</div>
<div class="text-center">
<div class="text-3xl font-semibold text-stone-100">4KB</div>
<div class="text-stone-500 text-sm mt-1">Minified</div>
</div>
<div class="text-center">
<div class="text-3xl font-semibold text-stone-100">0</div>
<div class="text-stone-500 text-sm mt-1">Dependencies</div>
</div>
</div>
</div>
</section>
<!-- Animations Showcase -->
<section id="animations" class="py-24 md:py-32 px-6">
<div class="max-w-7xl mx-auto">
<div class="text-center mb-16">
<span class="text-xs font-bold uppercase tracking-[0.3em] text-violet-400">Library</span>
<h2 class="serif text-4xl md:text-5xl font-normal tracking-tight mt-4">Animation Showcase</h2>
<p class="text-stone-400 mt-4 max-w-xl mx-auto">Click on any animation to replay it. All animations are pure CSS with zero JavaScript.</p>
</div>
<!-- Category: Fade -->
<div class="category-card mb-8">
<h3 class="text-xl font-semibold mb-2">Fade Animations</h3>
<p class="text-stone-400 text-sm mb-6">Smooth opacity transitions with optional directional movement</p>
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-6">
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-fade-in" data-animation="animate-fade-in">F</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">fade-in</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-fade-in-up" data-animation="animate-fade-in-up">↑</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">fade-in-up</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-fade-in-down" data-animation="animate-fade-in-down">↓</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">fade-in-down</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-fade-in-left" data-animation="animate-fade-in-left">←</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">fade-in-left</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-fade-in-right" data-animation="animate-fade-in-right">→</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">fade-in-right</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-fade-out motion-forwards" data-animation="animate-fade-out">O</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">fade-out</span>
</div>
</div>
</div>
<!-- Category: Scale -->
<div class="category-card mb-8">
<h3 class="text-xl font-semibold mb-2">Scale Animations</h3>
<p class="text-stone-400 text-sm mb-6">Transform-based size animations with smooth easing</p>
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-6">
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-scale-in" data-animation="animate-scale-in">S</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">scale-in</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-pop-in motion-ease-spring" data-animation="animate-pop-in">P</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">pop-in</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-pop motion-infinite" data-animation="animate-pop">!</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">pop</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-bounce-in motion-ease-bounce" data-animation="animate-bounce-in">B</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">bounce-in</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-rubber-band" data-animation="animate-rubber-band">R</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">rubber-band</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-scale-out motion-forwards" data-animation="animate-scale-out">O</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">scale-out</span>
</div>
</div>
</div>
<!-- Category: Rotate -->
<div class="category-card mb-8">
<h3 class="text-xl font-semibold mb-2">Rotate Animations</h3>
<p class="text-stone-400 text-sm mb-6">Rotation-based animations from subtle to dramatic</p>
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-6">
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-spin motion-infinite motion-slow" data-animation="animate-spin">↻</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">spin</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-flip motion-slow" data-animation="animate-flip">F</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">flip</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-wiggle motion-infinite motion-slow" data-animation="animate-wiggle">W</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">wiggle</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-swing" data-animation="animate-swing">S</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">swing</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-rotate-scale-in motion-ease-spring" data-animation="animate-rotate-scale-in">R</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">rotate-scale-in</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-flip-in" data-animation="animate-flip-in">X</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">flip-in</span>
</div>
</div>
</div>
<!-- Category: Attention -->
<div class="category-card mb-8">
<h3 class="text-xl font-semibold mb-2">Attention Seekers</h3>
<p class="text-stone-400 text-sm mb-6">Eye-catching animations to draw focus to elements</p>
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-6">
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-pulse motion-infinite" data-animation="animate-pulse">P</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">pulse</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-shake" data-animation="animate-shake">S</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">shake</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-heartbeat motion-infinite motion-slow" data-animation="animate-heartbeat">♥</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">heartbeat</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-tada" data-animation="animate-tada">T</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">tada</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-jello" data-animation="animate-jello">J</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">jello</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-head-shake" data-animation="animate-head-shake">H</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">head-shake</span>
</div>
</div>
</div>
<!-- Category: Bounce & Slide -->
<div class="category-card mb-8">
<h3 class="text-xl font-semibold mb-2">Bounce & Slide</h3>
<p class="text-stone-400 text-sm mb-6">Dynamic movement animations with natural physics</p>
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-6">
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-bounce motion-infinite" data-animation="animate-bounce">B</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">bounce</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-slide-up" data-animation="animate-slide-up">U</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">slide-up</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-slide-left" data-animation="animate-slide-left">L</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">slide-left</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-drop-in motion-ease-bounce" data-animation="animate-drop-in">D</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">drop-in</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-whoosh-in-left" data-animation="animate-whoosh-in-left">←</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">whoosh-in-left</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-whoosh-in-right" data-animation="animate-whoosh-in-right">→</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">whoosh-in-right</span>
</div>
</div>
</div>
<!-- Category: Float & Reveal -->
<div class="category-card mb-8">
<h3 class="text-xl font-semibold mb-2">Float & Reveal</h3>
<p class="text-stone-400 text-sm mb-6">Subtle continuous animations and clip-path reveals</p>
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-6">
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-float motion-infinite motion-slow" data-animation="animate-float">F</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">float</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-sway motion-infinite motion-slow" data-animation="animate-sway">S</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">sway</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-reveal-up" data-animation="animate-reveal-up">U</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">reveal-up</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-reveal-left" data-animation="animate-reveal-left">L</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">reveal-left</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-expand-h" data-animation="animate-expand-h">H</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">expand-h</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-expand-v" data-animation="animate-expand-v">V</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">expand-v</span>
</div>
</div>
</div>
<!-- Category: Special Effects -->
<div class="category-card">
<h3 class="text-xl font-semibold mb-2">Special Effects</h3>
<p class="text-stone-400 text-sm mb-6">Blur, glow, and other advanced CSS effects</p>
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-6">
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-blur-in" data-animation="animate-blur-in">B</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">blur-in</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-glow-pulse motion-infinite" data-animation="animate-glow-pulse">G</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">glow-pulse</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-tracking-in motion-slow" data-animation="animate-tracking-in">T</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">tracking-in</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-focus-in" data-animation="animate-focus-in">F</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">focus-in</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box animate-gradient-shift motion-infinite motion-slowest"
style="background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899, #6366f1);"
data-animation="animate-gradient-shift">✦</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">gradient-shift</span>
</div>
<div class="text-center">
<div class="demo-wrapper relative mb-3 flex justify-center">
<div class="demo-box motion animate-pulse-scale motion-infinite" data-animation="animate-pulse-scale">P</div>
<button class="play-btn" onclick="replayAnimation(this)">
<svg class="w-8 h-8 text-white" fill="currentColor" viewBox="0 0 24 24">
<path d="M8 5v14l11-7z"/>
</svg>
</button>
</div>
<span class="text-stone-400 text-xs">pulse-scale</span>
</div>
</div>
</div>
</div>
</section>
<!-- Utilities Section -->
<section id="utilities" class="py-24 md:py-32 px-6 bg-gradient-to-b from-transparent to-stone-950/50">
<div class="max-w-7xl mx-auto">
<div class="text-center mb-16">
<span class="text-xs font-bold uppercase tracking-[0.3em] text-violet-400">Customization</span>
<h2 class="serif text-4xl md:text-5xl font-normal tracking-tight mt-4">Utility Classes</h2>
<p class="text-stone-400 mt-4 max-w-xl mx-auto">Fine-tune animations with modifier classes for timing, duration, and more.</p>
</div>
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
<!-- Speed Utilities -->
<div class="category-card">
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
<span class="text-violet-400">⚡</span> Speed Modifiers
</h3>
<div class="code-block text-stone-300">
<div class="mb-2"><span class="property">.motion-fast</span> <span class="text-stone-500">→ 200ms</span></div>
<div class="mb-2"><span class="property">.motion-slow</span> <span class="text-stone-500">→ 800ms</span></div>
<div class="mb-2"><span class="property">.motion-slower</span> <span class="text-stone-500">→ 1200ms</span></div>
<div><span class="property">.motion-slowest</span> <span class="text-stone-500">→ 2000ms</span></div>
</div>
</div>
<!-- Easing Utilities -->
<div class="category-card">
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
<span class="text-violet-400">↯</span> Easing Modifiers
</h3>
<div class="code-block text-stone-300">
<div class="mb-2"><span class="property">.motion-ease-bounce</span></div>
<div class="mb-2"><span class="property">.motion-ease-elastic</span></div>
<div><span class="property">.motion-ease-spring</span></div>
</div>
</div>
<!-- Iteration Utilities -->
<div class="category-card">
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
<span class="text-violet-400">∞</span> Loop Control
</h3>
<div class="code-block text-stone-300">
<div class="mb-2"><span class="property">.motion-infinite</span> <span class="text-stone-500">→ forever</span></div>
<div class="mb-2"><span class="property">.motion-once</span> <span class="text-stone-500">→ 1 time</span></div>
<div><span class="property">.motion-twice</span> <span class="text-stone-500">→ 2 times</span></div>
</div>
</div>
<!-- Delay Utilities -->
<div class="category-card">
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
<span class="text-violet-400">⏱</span> Delay Classes
</h3>
<div class="code-block text-stone-300">
<div class="mb-1"><span class="property">.motion-delay-100</span> <span class="text-stone-500">→ 100ms</span></div>
<div class="mb-1"><span class="property">.motion-delay-200</span> <span class="text-stone-500">→ 200ms</span></div>
<div class="mb-1"><span class="property">.motion-delay-300</span> <span class="text-stone-500">→ 300ms</span></div>
<div class="mb-1"><span class="property">.motion-delay-500</span> <span class="text-stone-500">→ 500ms</span></div>
<div><span class="property">.motion-delay-1000</span> <span class="text-stone-500">→ 1000ms</span></div>
</div>
</div>
<!-- Hover Interactions -->
<div class="category-card">
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
<span class="text-violet-400">👆</span> Hover Triggers
</h3>
<div class="code-block text-stone-300">
<div class="mb-1"><span class="property">.hover-bounce</span></div>
<div class="mb-1"><span class="property">.hover-pop</span></div>
<div class="mb-1"><span class="property">.hover-shake</span></div>
<div class="mb-1"><span class="property">.hover-wiggle</span></div>
<div><span class="property">.hover-tada</span></div>
</div>
</div>
<!-- Stagger -->
<div class="category-card">
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
<span class="text-violet-400">↔</span> Stagger Groups
</h3>
<div class="code-block text-stone-300">
<div class="mb-2"><span class="property">.stagger-children</span></div>
<div class="text-stone-500 text-xs">Auto-delays (50ms) between child elements</div>
<div class="mt-3"><span class="property">.stagger-slow</span></div>
<div class="text-stone-500 text-xs">Slower stagger (100ms delay)</div>
</div>
</div>
</div>
</div>
</section>
<!-- Usage Section -->
<section id="usage" class="py-24 md:py-32 px-6">
<div class="max-w-4xl mx-auto">
<div class="text-center mb-16">
<span class="text-xs font-bold uppercase tracking-[0.3em] text-violet-400">Getting Started</span>
<h2 class="serif text-4xl md:text-5xl font-normal tracking-tight mt-4">Usage Guide</h2>
</div>
<!-- Basic Usage -->
<div class="category-card mb-8">
<h3 class="text-lg font-semibold mb-4">Basic Usage</h3>
<p class="text-stone-400 text-sm mb-4">Simply add the <code class="text-violet-400">.motion</code> base class and any animation class:</p>
<div class="code-block text-stone-300">
<div class="text-stone-500">/* HTML */</div>
<div class="mt-2"><span class="keyword"><div</span> <span class="property">class</span>=<span class="string">"motion animate-fade-in-up"</span><span class="keyword">></span></div>
<div class="ml-4">Your content here</div>
<div><span class="keyword"></div></span></div>
</div>
</div>
<!-- With Modifiers -->
<div class="category-card mb-8">
<h3 class="text-lg font-semibold mb-4">With Modifiers</h3>
<p class="text-stone-400 text-sm mb-4">Chain modifiers to customize timing and behavior:</p>
<div class="code-block text-stone-300">
<div class="text-stone-500">/* Slow + Infinite + Spring Easing */</div>
<div class="mt-2"><span class="keyword"><div</span> <span class="property">class</span>=<span class="string">"motion animate-bounce motion-slow motion-infinite motion-ease-spring"</span><span class="keyword">></span></div>
<div class="ml-4">Bouncing content</div>
<div><span class="keyword"></div></span></div>
<div class="mt-6 text-stone-500">/* With Delay */</div>
<div class="mt-2"><span class="keyword"><div</span> <span class="property">class</span>=<span class="string">"motion animate-scale-in motion-delay-300"</span><span class="keyword">></span></div>
<div class="ml-4">Delayed entrance</div>
<div><span class="keyword"></div></span></div>
</div>
</div>
<!-- CSS Variables -->
<div class="category-card mb-8">
<h3 class="text-lg font-semibold mb-4">Customizing via CSS Variables</h3>
<p class="text-stone-400 text-sm mb-4">Override default values globally or per-element:</p>
<div class="code-block text-stone-300">
<div class="text-stone-500">/* Global override in :root */</div>
<div class="mt-2"><span class="property">:root</span> {</div>
<div class="ml-4"><span class="keyword">--motion-duration-normal</span>: <span class="value">600ms</span>;</div>
<div class="ml-4"><span class="keyword">--motion-distance-lg</span>: <span class="value">60px</span>;</div>
<div class="ml-4"><span class="keyword">--motion-glow-color</span>: <span class="value">rgba(236, 72, 153, 0.5)</span>;</div>
<div>}</div>
<div class="mt-4 text-stone-500">/* Per-element override */</div>
<div class="mt-2"><span class="property">.my-element</span> {</div>
<div class="ml-4"><span class="keyword">--motion-duration-normal</span>: <span class="value">1s</span>;</div>
<div>}</div>
</div>
</div>
<!-- Stagger Example -->
<div class="category-card">
<h3 class="text-lg font-semibold mb-4">Staggered Animations</h3>
<p class="text-stone-400 text-sm mb-4">Use the stagger classes on a parent to delay children:</p>
<div class="code-block text-stone-300">
<div class="text-stone-500">/* Staggered list */</div>
<div class="mt-2"><span class="keyword"><ul</span> <span class="property">class</span>=<span class="string">"stagger-children"</span><span class="keyword">></span></div>
<div class="ml-4"><span class="keyword"><li</span> <span class="property">class</span>=<span class="string">"motion animate-fade-in-up"</span><span class="keyword">></span>Item 1<span class="keyword"></li></span></div>
<div class="ml-4"><span class="keyword"><li</span> <span class="property">class</span>=<span class="string">"motion animate-fade-in-up"</span><span class="keyword">></span>Item 2<span class="keyword"></li></span></div>
<div class="ml-4"><span class="keyword"><li</span> <span class="property">class</span>=<span class="string">"motion animate-fade-in-up"</span><span class="keyword">></span>Item 3<span class="keyword"></li></span></div>
<div><span class="keyword"></ul></span></div>
</div>
</div>
</div>
</section>
<!-- Interactive Demo -->
<section class="py-24 md:py-32 px-6 bg-gradient-to-b from-stone-950/50 to-transparent">
<div class="max-w-4xl mx-auto">
<div class="text-center mb-16">
<span class="text-xs font-bold uppercase tracking-[0.3em] text-violet-400">Try It</span>
<h2 class="serif text-4xl md:text-5xl font-normal tracking-tight mt-4">Interactive Playground</h2>
</div>
<div class="category-card">
<div class="grid md:grid-cols-2 gap-8">
<!-- Controls -->
<div>
<h3 class="text-lg font-semibold mb-6">Settings</h3>
<div class="space-y-6">
<div>
<label class="text-stone-400 text-sm mb-2 block">Animation</label>
<select id="playground-animation" class="w-full bg-stone-900 border border-stone-700 rounded-lg px-4 py-3 text-stone-100 focus:outline-none focus:border-violet-500">
<option value="animate-fade-in-up">fade-in-up</option>
<option value="animate-scale-in">scale-in</option>
<option value="animate-bounce-in">bounce-in</option>
<option value="animate-slide-up">slide-up</option>
<option value="animate-flip-in">flip-in</option>
<option value="animate-drop-in">drop-in</option>
<option value="animate-rotate-scale-in">rotate-scale-in</option>
<option value="animate-blur-in">blur-in</option>
</select>
</div>
<div>
<label class="text-stone-400 text-sm mb-2 block">Speed</label>
<select id="playground-speed" class="w-full bg-stone-900 border border-stone-700 rounded-lg px-4 py-3 text-stone-100 focus:outline-none focus:border-violet-500">
<option value="motion-fast">Fast (200ms)</option>
<option value="" selected>Normal (500ms)</option>
<option value="motion-slow">Slow (800ms)</option>
<option value="motion-slower">Slower (1200ms)</option>
</select>
</div>
<div>
<label class="text-stone-400 text-sm mb-2 block">Easing</label>
<select id="playground-easing" class="w-full bg-stone-900 border border-stone-700 rounded-lg px-4 py-3 text-stone-100 focus:outline-none focus:border-violet-500">
<option value="" selected>Default</option>
<option value="motion-ease-bounce">Bounce</option>
<option value="motion-ease-elastic">Elastic</option>
<option value="motion-ease-spring">Spring</option>
</select>
</div>
<div>
<label class="text-stone-400 text-sm mb-2 block">Delay</label>
<select id="playground-delay" class="w-full bg-stone-900 border border-stone-700 rounded-lg px-4 py-3 text-stone-100 focus:outline-none focus:border-violet-500">
<option value="" selected>None</option>
<option value="motion-delay-200">200ms</option>
<option value="motion-delay-500">500ms</option>
<option value="motion-delay-700">700ms</option>
</select>
</div>
<button onclick="playDemo()" class="w-full py-4 bg-gradient-to-r from-violet-600 to-indigo-600 text-white text-xs font-bold uppercase tracking-widest rounded-full hover:shadow-lg hover:shadow-violet-500/25 transition-all">
Play Animation
</button>
</div>
</div>
<!-- Preview -->
<div>
<h3 class="text-lg font-semibold mb-6">Preview</h3>
<div class="bg-stone-900/50 rounded-2xl p-12 flex items-center justify-center min-h-[300px]">
<div id="playground-box" class="w-24 h-24 rounded-2xl bg-gradient-to-br from-violet-600 to-indigo-600 flex items-center justify-center">
<span class="text-white font-bold text-2xl">M</span>
</div>
</div>
<div class="mt-4">
<p class="text-stone-400 text-sm mb-2">Generated Class:</p>
<code id="generated-class" class="block bg-stone-900 rounded-lg px-4 py-3 text-violet-400 text-sm break-all">
motion animate-fade-in-up
</code>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="py-12 px-6 border-t border-stone-800/50">
<div class="max-w-7xl mx-auto">
<div class="flex flex-col md:flex-row items-center justify-between gap-6">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-xl bg-gradient-to-br from-violet-600 to-indigo-600 flex items-center justify-center">
<span class="text-white font-bold text-lg">M</span>
</div>
<span class="text-stone-400">Motion CSS • Open Source Animation Library</span>
</div>
<div class="text-stone-500 text-sm">
Made with pure CSS keyframes and custom properties
</div>
</div>
</div>
</footer>
<!-- Toast Notification -->
<div id="toast" class="fixed bottom-8 left-1/2 -translate-x-1/2 px-6 py-3 bg-stone-800 text-white rounded-full shadow-2xl opacity-0 transition-all duration-300 -translate-y-4 pointer-events-none">
Copied to clipboard!
</div>
<script>
// Replay animation on click
function replayAnimation(button) {
const box = button.previousElementSibling;
const animationClass = box.dataset.animation;
// Remove animation class
box.classList.remove(animationClass);
// Force reflow
void box.offsetWidth;
// Re-add animation class
box.classList.add(animationClass);
}
// Interactive playground
function playDemo() {
const animation = document.getElementById('playground-animation').value;
const speed = document.getElementById('playground-speed').value;
const easing = document.getElementById('playground-easing').value;
const delay = document.getElementById('playground-delay').value;
const box = document.getElementById('playground-box');
const generatedClass = document.getElementById('generated-class');
// Remove all animation classes
box.className = 'w-24 h-24 rounded-2xl bg-gradient-to-br from-violet-600 to-indigo-600 flex items-center justify-center motion ' + animation;
if (speed) box.classList.add(speed);
if (easing) box.classList.add(easing);
if (delay) box.classList.add(delay);
// Update generated class display
let classes = 'motion ' + animation;
if (speed) classes += ' ' + speed;
if (easing) classes += ' ' + easing;
if (delay) classes += ' ' + delay;
generatedClass.textContent = classes;
// Replay animation
void box.offsetWidth;
box.classList.remove(animation);
void box.offsetWidth;
box.classList.add(animation);
}
// Copy library to clipboard
async function copyToClipboard() {
// Get the style content
const styleContent = document.querySelector('style').textContent;
// Find just the animation library part
const startMarker = '/* ========================================\n 1. CSS CUSTOM PROPERTIES';
const endMarker = '/* Demo Page Styles */';
const startIndex = styleContent.indexOf(startMarker);
const endIndex = styleContent.indexOf(endMarker);
const libraryCSS = styleContent.substring(startIndex, endIndex).trim();
try {
await navigator.clipboard.writeText(libraryCSS);
showToast('Copied to clipboard!');
} catch (err) {
showToast('Failed to copy');
}
}
function showToast(message) {
const toast = document.getElementById('toast');
toast.textContent = message;
toast.classList.remove('opacity-0', '-translate-y-4');
toast.classList.add('opacity-100', 'translate-y-0');
setTimeout(() => {
toast.classList.remove('opacity-100', 'translate-y-0');
toast.classList.add('opacity-0', '-translate-y-4');
}, 2000);
}
// Update generated class on change
document.getElementById('playground-animation').addEventListener('change', playDemo);
document.getElementById('playground-speed').addEventListener('change', playDemo);
document.getElementById('playground-easing').addEventListener('change', playDemo);
document.getElementById('playground-delay').addEventListener('change', playDemo);
// Smooth scroll for nav links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});
</script>
</body>
</html>
Key Features of This Animation Library
1. CSS Custom Properties for Customization
- Duration variables:
--motion-duration-fast through --motion-duration-slowest
- Easing functions: bounce, elastic, spring, default
- Transform values: scale, rotate, skew amounts
- Distance values for slide/fade animations
2. 50+ Animation Types
- Fade: in, out, with directional variants (up/down/left/right)
- Scale: scale-in, scale-out, pop, pop-in, bounce-in, rubber-band
- Rotate: spin, flip, wiggle, swing, rotate-scale-in
- Attention: pulse, shake, heartbeat, tada, jello, head-shake
- Bounce/Slide: bounce, slide-up/down/left/right, drop-in, whoosh
- Float/Reveal: float, sway, reveal animations, expand
- Special Effects: blur, glow-pulse, gradient-shift, tracking-in
3. Utility Classes
- Speed:
.motion-fast, .motion-slow, .motion-slower, .motion-slowest
- Easing:
.motion-ease-bounce, .motion-ease-elastic, .motion-ease-spring
- Iteration:
.motion-infinite, .motion-once, .motion-twice
- Delays:
.motion-delay-100 through .motion-delay-1000
- Hover triggers:
.hover-bounce, .hover-pop, .hover-shake, etc.
- Stagger:
.stagger-children, .stagger-slow
4. Accessibility
- Respects
prefers-reduced-motion
.motion-off class to disable all animations