Micro Animation
Implement purposeful UI micro-interactions grounded in direction-aware easing (ease-in, ease-out, ease-in-out), classical animation principles, and GPU-composited motion orchestration. Every transition must clarify spatial relationships, confirm intent, and feel responsive without delaying user action.
Read references/easing-and-patterns.md when implementing CSS tokens, enter/exit transitions, staggered lists, or reduced-motion fallbacks.
When to Use
- Implementing hover, focus, press, toggle, or feedback transitions on interactive controls
- Building enter, exit, and layout transitions for modals, drawers, popovers, or cards
- Orchestrating staggered lists, multi-step state changes, or shared-element transitions
- Auditing or refining CSS/JS animations that feel stiff, sluggish, or janky
Easing & Timing Rules (Slow In, Slow Out)
Match every easing curve to motion direction and intent. Never apply linear to spatial UI movement (reserve linear strictly for continuous spinners and determinate progress fills):
- Entering / Appearing (
ease-out): Start fast for immediate feedback and decelerate cleanly into rest (cubic-bezier(0.16, 1, 0.3, 1)orcubic-bezier(0, 0, 0.2, 1)). - Exiting / Leaving (
ease-in): Accelerate cleanly out of view so departing surfaces never linger (cubic-bezier(0.4, 0, 1, 1)). Make exits 20% to 30% faster than entrances. - On-Screen State Change / Repositioning (
ease-in-out): Accelerate from rest and decelerate into the new state (cubic-bezier(0.4, 0, 0.2, 1)). - Tactile / Spring Controls: Use spring physics (or slight overshoot
cubic-bezier(0.34, 1.56, 0.64, 1)) sparingly for toggles, reactions, or drag-release snap-back.
Scale durations strictly to travel distance:
- Micro-feedback (button press, hover, checkbox, toggle):
100msto150ms - Small surfaces (tooltips, dropdowns, tabs, toast enter):
150msto220ms - Large surfaces (modals, drawers, card expansions):
220msto350ms
Classical Animation Principles for UI
- Slow In and Slow Out: Apply
ease-outon entry,ease-inon exit, andease-in-outfor in-place state transitions. - Anticipation: Provide subtle pre-action feedback before major transitions (such as
scale(0.97)on pointer-down or elevation lift before drag). - Staging: Direct focus to the active surface by dimming or blurring background layers (
opacity+backdrop-filter) while keeping non-target elements still. - Follow-Through and Overlapping Action: Avoid moving every child as a rigid slab; offset secondary elements (title, body, actions) by
25msto50msafter the container. - Secondary Action: Reinforce primary state transitions with subtle supporting motion (icon morph, checkmark stroke draw, soft ring pulse) that never competes with the main control.
- Subtle Squash and Stretch: Apply minimal scale shifts on tactile interactions (
active:scale-[0.98]) while preserving crisp text rendering. - Arcs: Move floating or shared elements along curved paths across X and Y axes rather than mechanical two-step L-shapes.
- Timing and Restraint: Keep motion crisp so the UI never forces the user to wait.
Motion Orchestration
- Choreograph by hierarchy: Animate the container first, then stagger child items by
25msto45ms. Cap total stagger delay (for example,<= 200ms) so long lists never trickle in slowly. - Unify exits: Dismiss modals and groups together with a short
ease-ininstead of reversing a long stagger. - Preserve interruptibility: Use CSS transitions, Web Animations API, or interruptible springs so rapid hover/unhover or open/close toggles reverse smoothly from the current frame without snapping.
Performance & Accessibility (Mandatory)
- Composite-only properties: Animate
transform(translate,scale,rotate) andopacity. Never animate layout-thrashing properties (width,height,top,left,margin,padding) in micro-animations. - Reduced motion: Always ship
@media (prefers-reduced-motion: reduce)fallbacks that disable spatial translation/scaling and reduce motion to instant updates or subtleopacityfades.
Red Flags
- Applying
lineareasing to modals, drawers, or button transitions - Applying
ease-into elements entering the viewport - Animating
height,width,margin, ortop/leftinstead oftransform - Staggering long lists without a total delay cap
- Omitting
@media (prefers-reduced-motion: reduce)handling
Gotchas
- Never let decorative animation block pointer events or delay input responsiveness.
- Verify transitions under CPU throttling; a
300msanimation that drops frames degrades UX more than no animation.