Kombai Logo

Tailwind CSS Transition Delay

Transition delay defines how long a transition should wait before it begins. When crafting user experiences and animations, transition delay adds subtle elegance and control over the timing of transitions. Tailwind CSS provides preconfigured utilities and customization options for the transition-delay property, making it efficient and easy to apply.

In this guide, we'll explore various ways to use and customize transition delays with Tailwind CSS, including conditional applications, responsiveness, and custom values.

ClassPropertiesExample
delay-0transition-delay: 0s;<div className="delay-0"></div>
delay-75transition-delay: 75ms;<div className="delay-75"></div>
delay-100transition-delay: 100ms;<div className="delay-100"></div>
delay-150transition-delay: 150ms;<div className="delay-150"></div>
delay-200transition-delay: 200ms;<div className="delay-200"></div>
delay-300transition-delay: 300ms;<div className="delay-300"></div>
delay-500transition-delay: 500ms;<div className="delay-500"></div>
delay-700transition-delay: 700ms;<div className="delay-700"></div>
delay-1000transition-delay: 1000ms;<div className="delay-1000"></div>

Overview of Transition Delay

Adding the Transition Delay

To add transition delay to an element, use Tailwind's delay utilities- delay-100, delay-200, delay-300, etc.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

States and Responsiveness

Hover and Focus States

Tailwind allows you to conditionally apply the transition delay on certain states like hover and focus. Use Tailwind's state modifiers like- hover, focus, etc. to apply the utility only when these states are active, e.g., hover:delay-500.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Breakpoint Modifiers

Tailwind supports breakpoint modifiers, allowing you to change transition delay based on specific screen breakpoints. This ensures animations adapt for varying viewports, creating a polished appearance across devices.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Custom Transition Delay

In some scenarios, the default transition delay values provided by Tailwind CSS might not cover your specific use cases. Tailwind enables you to extend the theme or apply completely arbitrary values to achieve precise timings.

Extending the Theme

One way to introduce custom delay values is by extending the Tailwind theme configuration in your Tailwind CSS setup. You can define these custom values in your tailwind.config.js file. The below configuration introduces two custom transition delay values: 1500ms and 2500ms.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Using Arbitrary Values

For one-off customizations, Tailwind CSS supports arbitrary values. These values can be applied inline with the utility class syntax, wrapped in square brackets.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Real World Examples

Info Cards

A grid of product cards that reveal additional details on hover with staggered delays.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

A menu where social links expand with sequential delays on hover.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Feature Grid Expansion

A grid of feature cards that expand to show more details on hover with delayed transitions.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Pricing Card Comparison

A set of pricing cards that reveal feature comparisons on hover with delayed animations.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Profile Cards Expansion

A grid of team member profile cards that expand to show additional info with delayed animations.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Customization Examples

Expandable Info Card

A card that reveals additional information with a staggered delay on hover.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Feature Showcase

A component that reveals feature details with cascading delays on hover.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Layered Image Reveal

An image component that reveals multiple layers with different delays on hover.

This is a live editor. Play around with it!
export default function App() {
  return <h1>Hello world</h1>
}

Best Practices

Maintain Design Consistency

Transition effects should align with the overall theme and pacing of animations across your project. For example, if one button uses a delay-300 utility for hover effects, ensure that similar buttons across the UI adopt the same delay timing.

If custom delay utilities are needed apart from the predetermined ones- define them within your tailwind.config.js to maintain consistency. These custom delay values can then become the default palette for your animations. This approach makes your transitions predictable and avoids excessive variation that might confuse users.

Leverage Utility Combinations

Combining transition-delay with other Tailwind utilities can help you achieve advanced animations while maintaining a utility-first approach. For example, layering transform classes like hover:scale-105 with delay-500 and duration-500 creates hover effects that feel both dynamic and seamless.

For complex animations, such as cascading modals or progressive reveals, experiment with state variants like hover, focus, etc. in combination with transition, delay, and layout utilities. An example is pairing opacity-0 with hover:opacity-100 for fade-in effects.

Accessibility Considerations

Enhance Readability and Navigability

When applying transition-delay in a Tailwind CSS project, always consider how animations affect the readability and navigability of content. Delays should guide attention, not hinder it. For example, using delay-200 to smoothly transition text-based elements allows readers to focus sequentially without creating visual clutter.

Animations should support content flow rather than distract users. Use utilities like opacity-0, paired with delay-300 and hover:opacity-100, to create fade-ins specifically for less critical content. Keep transitions short to avoid obstructing access to essential features, particularly for assistive technology users who rely on screen readers and other tools.

Focus on High Contrast

High-contrast interfaces benefit significantly from properly configured transition-delay utilities. Adding delays like delay-200 for hover states help users perceive color transitions more clearly. For example, transitioning from bg-gray-700 to bg-yellow-400 ensures high contrast differences remain visually distinct.

Ensure that combining transition-delay with other utilities like focus:ring and outline-none highlights interacted or focused elements without compromising readability. Set delays conservatively to avoid overshadowing the contrast or animations taking too long to visually establish new states.