Skip to content
handling-animations logo

Handling Animations

handling-animations

Define animations with @keyframes within @theme directive, use animate-{name} utilities, and implement entry animations with starting: variant. Use when creating custom animations or entry effects.

SKILL.md

Full skill instructions

Handling Animations

Purpose

Define custom animations using @keyframes within the @theme directive and use Tailwind's animation utilities with full variant support.

Basic Animation Pattern

Define animations within @theme:

@import 'tailwindcss';

@theme {
  --animate-fade-in: fade-in 0.3s ease-out;

  @keyframes fade-in {
    0% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }
}

Usage:

<div class="animate-fade-in">Fades in on load</​div>

Animation Variable Naming

Pattern: --animate-{name}: {animation-shorthand};

The variable name determines the utility class:

@theme {
  --animate-spin: spin 1s linear infinite;
  --animate-bounce: bounce 1s infinite;
  --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

Generates utilities:

  • animate-spin
  • animate-bounce
  • animate-pulse

Common Animation Types

Fade Animations

Fade In:

@theme {
  --animate-fade-in: fade-in 0.3s ease-out;

  @keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
  }
}

Fade In with Scale:

@theme {
  --animate-fade-in-scale: fade-in-scale 0.3s ease-out;

  @keyframes fade-in-scale {
    0% {
      opacity: 0;
      transform: scale(0.95);
    }
    100% {
      opacity: 1;
      transform: scale(1);
    }
  }
}

Slide Animations

Slide Up:

@theme {
  --animate-slide-up: slide-up 0.4s ease-out;

  @keyframes slide-up {
    0% {
      opacity: 0;
      transform: translateY(20px);
    }
    100% {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

For complete directional slide examples (left, right, top, bottom), see Animation Library.

Motion Animations

Spin:

@theme {
  --animate-spin: spin 1s linear infinite;

  @keyframes spin {
    to { transform: rotate(360deg); }
  }
}

Bounce:

@theme {
  --animate-bounce: bounce 1s infinite;

  @keyframes bounce {
    0%, 100% {
      transform: translateY(-25%);
      animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
      transform: translateY(0);
      animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
  }
}

For additional motion animations (pulse, ping, shake, wiggle), see Animation Library.

Entry Animations with starting:

The starting: variant applies styles before animations begin:

<div class="opacity-100 transition-opacity duration-300 starting:opacity-0">
  Fades in smoothly
</​div>

<div class="
  translate-y-0 opacity-100
  transition-all duration-300
  starting:translate-y-4 starting:opacity-0
">
  Slides up while fading in
</​div>

How it works:

  1. Element starts with starting: styles
  2. Browser renders first frame
  3. Transition/​animation begins to final state

Animation with Variants

Animations work with all Tailwind variants:

<div class="hover:animate-spin">Spins on hover</​div>
<div class="focus:animate-pulse">Pulses on focus</​div>
<div class="group-hover:animate-bounce">Bounces when parent hovered</​div>
<div class="lg:animate-fade-in">Animates on large screens</​div>
<div class="dark:animate-pulse">Pulses in dark mode</​div>

Advanced Animation Techniques

Staggered Animations

<div class="space-y-4">
  <div class="animate-slide-up [animation-delay:0s]">Item 1</​div>
  <div class="animate-slide-up [animation-delay:0.1s]">Item 2</​div>
  <div class="animate-slide-up [animation-delay:0.2s]">Item 3</​div>
  <div class="animate-slide-up [animation-delay:0.3s]">Item 4</​div>
</​div>

Animation Control

Delayed Animation:

<div class="
  animate-fade-in
  [animation-delay:0.1s]
  [animation-fill-mode:both]
">
  Delayed fade in
</​div>

Pause on Hover:

<div class="animate-spin hover:[animation-play-state:paused]">
  Pauses on hover
</​div>

Best Practices

  1. Define within @theme - Keep all animations in one place
  2. Use semantic names - fade-in not anim-1
  3. Include timing in variable - Full animation shorthand
  4. Test performance - Avoid animating expensive properties (width, height)
  5. Use transform and opacity - Hardware accelerated
  6. Add will-change sparingly - Only for known animations
  7. Respect prefers-reduced-motion - Disable animations for accessibility

Accessibility

Respect user motion preferences:

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

References

For comprehensive animation examples and patterns, see:

  • Animation Library - Complete collection of animation examples
    • Fade animations (in, out, scale)
    • Slide animations (all directions)
    • Motion animations (spin, pulse, ping, bounce)
    • Complex patterns (shake, wiggle, loading dots)
    • Complete animation library code
    • Advanced techniques and performance considerations

See Also

  • RESEARCH.md sections: "Entry Animations with starting:" and "Animation Keyframes"

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View