transition-duration

Class Description

duration

Sets transition-duration via --duration. E.g. 300ms, 0.5s.

CSS Rules

.duration {
  transition-duration: var(--duration);
}

Usage

The .duration class is flagged as a value-driven selector. The variable --duration is required.
<element class="duration" style="--duration: /* value */;" />

Responsive

Prefix .duration utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl).

<element class="md:duration" style="--md-duration: /* value */;" />

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints .

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element class="duration:hover" style="--duration-hover: /* value */;" />

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="duration:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element class="content-before duration::before" style="--duration-before: /* value */;" />

<element class="content-after duration::after" style="--duration-after: /* value */;" />

Shorthand

Value-driven classes support a shorthand syntax like bg=pink or p=4. The runtime processes this for you. Unlike :hover that is generating CSS on the fly, shorthand only splits it and appends the corresponding style.

<!-- Input -->
<element class="duration=value" />

<!-- Output -->
<element class="duration" style="--duration: value;" />

CLS Alert

This feature may cause CLS (Cumulative Layout Shift). Make sure to include a z-not-ready class in your <head> tag.

.duration Sets transition-duration via --duration. E.g. 300ms, 0.5s.

duration-initial

Resets transition-duration to its initial CSS value.

CSS Rules

.duration-initial {
  transition-duration: initial;
}

Usage

<element class="duration-initial" />

Responsive

Prefix .duration-initial utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl).

<element class="md:duration-initial" />

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints .

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element class="duration-initial:hover" />

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="duration-initial:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element class="content-before duration-initial::before" />

<element class="content-after duration-initial::after" />
.duration-initial Resets transition-duration to its initial CSS value.