Kombai Logo

Tailwind CSS Transition Duration

Transition duration is a critical CSS property used to define the length of time a visual transition takes to complete. It controls the pacing of transitions applied to properties such as colors, borders, or positioning. Tailwind CSS comes with pre-defined utilities to handle transition durations, offering a quick and scalable way to implement rich, interactive designs.

In this guide, we’ll explore the transition duration utilities in Tailwind CSS, covering fundamental usage, conditionally applying states, customizing durations, and much more.

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

Overview of Transition Duration

Adding the Transition Duration

Transition durations control the time span for transitions applied to styles. Apply duration-* utilities to set the duration of a transition:

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

Transitions often need to be conditional, responding to user interactions like hover or focus. Tailwind facilitates this by combining transition classes with state variants.

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

Breakpoint Modifiers

Different screen sizes often require unique transition durations. Tailwind’s breakpoint modifiers enable developers to define responsive transition durations.

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

Custom Transition Duration

Extending the Theme

Tailwind allows you to customize themes if the default duration utilities don’t meet your requirements. For instance, you may want durations not included by default, like 750ms. To add such custom values, extend your Tailwind configuration file:

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

Using Arbitrary Values

For ultimate flexibility, arbitrary values are a powerful feature in Tailwind CSS. You can specify exact durations outside the pre-defined or theme-extended values.

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

Real World Examples

Animated Product Cards Showcase

A product grid that reveals additional information with smooth transitions when hovering over each card.

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

Staggered Menu Animation

A navigation menu with staggered item animations on hover.

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

Animated Feature Cards

Interactive feature cards with smooth transition effects for icons and content.

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

Animated Team Members Grid

A responsive team members grid with smooth hover transitions and social media links.

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

Accordion FAQ

An FAQ section with smooth expanding and collapsing animations.

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

Customization Examples

Animated Product Card Hover Effect

Configure custom transition durations for a smooth product card animation that reveals additional details on hover.

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

Elegant Menu Transition

Create a sophisticated menu transition with custom durations for different elements.

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

Feature Section Reveal

Implement a staggered reveal effect for feature sections with custom transition timings.

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

Best Practices

Maintain Design Consistency

Achieving a consistent design language is crucial when working with transition duration in Tailwind CSS. By defining and adhering to a standardized set of transition duration values, you can create a unified user experience across your project.

For instance, setting uniform durations for similar interactions, such as button hover effects or modal animations, ensures users perceive the interface as cohesive. Tailwind provides pre-defined duration utilities like duration-150 and duration-300, which can be consistently applied across components for this purpose.

Leverage Utility Combinations

Combining multiple Tailwind CSS utilities with transition duration can help create sophisticated and dynamic interfaces while maintaining clarity in your code. For instance, pairing duration-200 with ease-in-out and transform can make animations feel smooth and natural. These utilities are most effective when used together to enhance user interaction, such as scaling a card on hover or fading in a tooltip.

You can also combine transition duration with delay-* utilities to create staggered animations or delay the start of certain effects. For example, pairing delay-100 with duration-300 allows you to control the timing and order of animations, creating visually appealing interactions like staggered list animations. These combinations are especially useful in storytelling interfaces, where dynamic content needs to draw attention progressively.

Accessibility Considerations

Enhance Readability and Navigability

Transition duration impacts how users perceive and interact with content. By setting appropriate durations, you can improve readability and navigability for all users. For instance, using duration-200 for hover states on buttons ensures that users can clearly identify active elements without unnecessary delays.

Ensuring consistent durations for navigational elements, such as menus or tabs, enhances usability. When transitions are predictable and uniform, users can easily identify patterns, making navigation more intuitive. Avoid overly long durations that may confuse or frustrate users, particularly in interactive elements.

Focus on High Contrast

High contrast is a fundamental aspect of accessibility, and transition duration can help reinforce this principle. For example, pairing duration-150 with transition-colors ensures that color changes in interactive elements, such as buttons or links, are immediate and noticeable. This is particularly important for users with low vision, who rely on clear visual cues to navigate interfaces.

Additionally, use transition-transform and duration-300 to emphasize changes in scale or position, drawing attention to critical elements. For instance, scaling up a button on hover provides a clear visual cue, improving accessibility for users who may struggle with fine motor control.