Skip to content

Layout

Overflow

Utilities for controlling how an element handles content that is too large for the container.

Quick reference

ClassDescription
overflow-autooverflow: auto
overflow-hiddenoverflow: hidden
overflow-clipoverflow: clip
overflow-visibleoverflow: visible
overflow-scrolloverflow: scroll
overflow-x-autooverflow-x: auto
overflow-y-autooverflow-y: auto
overflow-x-hiddenoverflow-x: hidden
overflow-y-hiddenoverflow-y: hidden
overflow-x-clipoverflow-x: clip
overflow-y-clipoverflow-y: clip
overflow-x-visibleoverflow-x: visible
overflow-y-visibleoverflow-y: visible
overflow-x-scrolloverflow-x: scroll
overflow-y-scrolloverflow-y: scroll

Basic usage

Showing content that overflows

Use overflow-visible to prevent content within an element from being clipped. Note that any content that overflows the bounds of the element will then be visible.

AI generated picture of 1950s scientists working on a warp drive
Justina Matter
Warp Scientist
html
<div class="overflow-visible ..."></div>

Hiding content that overflows

Use overflow-hidden to clip any content within an element that overflows the bounds of that element.

AI generated picture of 1950s scientists working on a warp drive
Justina Matter
Warp Scientist
html
<div class="overflow-hidden ..."></div>

Scrolling if needed

Use overflow-auto to add scrollbars to an element in the event that its content overflows the bounds of that element. Unlike overflow-scroll, which always shows scrollbars, this utility will only show them if scrolling is necessary.

AI generated picture of 1950s scientists working on a warp drive
Justina Matter
Warp Scientist
AI generated picture of 1950s scientists working on a warp drive
Narve Hoops
Warp Scientist
AI generated picture of 1950s scientists working on a warp drive
Dagny Calamity
Warp Scientist
AI generated picture of 1950s scientists working on a warp drive
Joar Quack
Warp Scientist
html
<div class="overflow-y-auto h-128 ..."></div>

Scrolling horizontally always

Use overflow-x-scroll to allow horizontal scrolling and always show scrollbars unless always-visible scrollbars are disabled by the operating system.

AI generated picture of 1950s scientists working on a warp drive
Matter
AI generated picture of 1950s scientists working on a warp drive
Hoops
AI generated picture of 1950s scientists working on a warp drive
Quack
AI generated picture of 1950s scientists working on a warp drive
Sparks
AI generated picture of 1950s scientists working on a warp drive
Hubble
AI generated picture of 1950s scientists working on a warp drive
Calamity
AI generated picture of 1950s scientists working on a warp drive
Glum

Scrolling vertically always

Use overflow-y-scroll to allow vertical scrolling and always show scrollbars unless always-visible scrollbars are disabled by the operating system.

AI generated picture of 1950s scientists working on a warp drive
Justina Matter
Warp Scientist
AI generated picture of 1950s scientists working on a warp drive
Narve Hoops
Warp Scientist
AI generated picture of 1950s scientists working on a warp drive
Dagny Calamity
Warp Scientist
AI generated picture of 1950s scientists working on a warp drive
Joar Quack
Warp Scientist
html
<div class="overflow-y-scroll ..."></div>

Scrolling in all directions

Use overflow-scroll to add scrollbars to an element. Unlike overflow-auto, which only shows scrollbars if they are necessary, this utility always shows them. Note that some operating systems (like macOS) hide unnecessary scrollbars regardless of this setting.

Ai generated picture of warp scientists from the 1950s
html
<div class="overflow-scroll ..."></div>

Applying conditionally

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:overflow-scroll to apply the overflow-scroll utility at only medium screen sizes and above.

html
<div class="overflow-auto md:overflow-scroll">
  <!-- ... -->
</div>

Released under the Apache 2.0 License.