Interactivity
Utilities for controlling the scroll behavior of an element.
Use the scroll-smooth
utility to enable smooth scrolling within an element.
<html class="scroll-smooth">
<!-- ... -->
</html>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use focus:scroll-auto
to only apply the scroll-auto
utility on focus.
<html class="scroll-smooth focus:scroll-auto">
<!-- ... -->
</html>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:scroll-auto
to apply the scroll-auto
utility at only medium screen sizes and above.
<html class="scroll-smooth md:scroll-auto">
<!-- ... -->
</html>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.