scroll-behavior

Class Description

scroll-auto

Sets scroll-behavior: auto. Default instant scroll behavior.

CSS Rules

.scroll-auto {
  scroll-behavior: auto;
}

Usage

<element class="scroll-auto" />

Responsive

Prefix .scroll-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:scroll-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="scroll-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="scroll-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 scroll-auto::before" />

<element class="content-after scroll-auto::after" />
.scroll-auto Sets scroll-behavior: auto. Default instant scroll behavior.

scroll-smooth

Sets scroll-behavior: smooth. Anchor links scroll smoothly.

CSS Rules

.scroll-smooth {
  scroll-behavior: smooth;
}

Usage

<element class="scroll-smooth" />

Responsive

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

<element class="md:scroll-smooth" />

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="scroll-smooth: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="scroll-smooth: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 scroll-smooth::before" />

<element class="content-after scroll-smooth::after" />
.scroll-smooth Sets scroll-behavior: smooth. Anchor links scroll smoothly.