Layout
Overscroll Behavior
Utilities for controlling how the browser behaves when reaching the boundary of a scrolling area.
Quick reference
Class | Properties |
---|---|
overscroll-auto | overscroll-behavior: auto; |
overscroll-contain | overscroll-behavior: contain; |
overscroll-none | overscroll-behavior: none; |
overscroll-y-auto | overscroll-behavior-y: auto; |
overscroll-y-contain | overscroll-behavior-y: contain; |
overscroll-y-none | overscroll-behavior-y: none; |
overscroll-x-auto | overscroll-behavior-x: auto; |
overscroll-x-contain | overscroll-behavior-x: contain; |
overscroll-x-none | overscroll-behavior-x: none; |
Basic usage
Preventing parent overscrolling
Use overscroll-contain
to prevent scrolling in the target area from triggering scrolling in the parent element, but preserve “bounce” effects when scrolling past the end of the container in operating systems that support it.
<div class="overscroll-contain ...">Well, let me tell you something, ...</div>
Preventing overscroll bouncing
Use overscroll-none
to prevent scrolling in the target area from triggering scrolling in the parent element, and also prevent “bounce” effects when scrolling past the end of the container.
<div class="overscroll-none ...">Well, let me tell you something, ...</div>
Using the default overscroll behavior
Use overscroll-auto
to make it possible for the user to continue scrolling a parent scroll area when they reach the boundary of the primary scroll area.
<div class="overscroll-auto ...">Well, let me tell you something, ...</div>
Applying conditionally
Hover, focus, and other states
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:overscroll-contain
to only apply the overscroll-contain
utility on hover.
<div class="overscroll-auto hover:overscroll-contain">
<!-- ... -->
</div>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
Breakpoints and media queries
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:overscroll-contain
to apply the overscroll-contain
utility at only medium screen sizes and above.
<div class="overscroll-auto md:overscroll-contain">
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.