text-underline-offset

Class Description

underline-offset

Sets text-underline-offset via --underline-offset. E.g. 4px.

CSS Rules

.underline-offset {
  text-underline-offset: var(--underline-offset);
}

Usage

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

Responsive

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

<element class="md:underline-offset" style="--md-underline-offset: /* 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="underline-offset:hover" style="--underline-offset-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="underline-offset: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 underline-offset::before" style="--underline-offset-before: /* value */;" />

<element class="content-after underline-offset::after" style="--underline-offset-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="underline-offset=value" />

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

CLS Alert

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

.underline-offset Sets text-underline-offset via --underline-offset. E.g. 4px.

underline-offset-auto

Sets text-underline-offset to auto, using the browser's default underline offset.

CSS Rules

.underline-offset-auto {
  text-underline-offset: auto;
}

Usage

<element class="underline-offset-auto" />

Responsive

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

<element class="md:underline-offset-auto" />

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="underline-offset-auto: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="underline-offset-auto: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 underline-offset-auto::before" />

<element class="content-after underline-offset-auto::after" />
.underline-offset-auto Sets text-underline-offset to auto, using the browser's default underline offset.