Overflow
Utilities for controlling how an element handles content that is too large for the container.
Default class reference
Class | Properties |
---|---|
overflow-auto | overflow: auto; |
overflow-hidden | overflow: hidden; |
overflow-visible | overflow: visible; |
overflow-scroll | overflow: scroll; |
overflow-x-auto | overflow-x: auto; |
overflow-y-auto | overflow-y: auto; |
overflow-x-hidden | overflow-x: hidden; |
overflow-y-hidden | overflow-y: hidden; |
overflow-x-visible | overflow-x: visible; |
overflow-y-visible | overflow-y: visible; |
overflow-x-scroll | overflow-x: scroll; |
overflow-y-scroll | overflow-y: scroll; |
Visible
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.
<div class="overflow-visible h-24 ...">Lorem ipsum dolor sit amet...</div>
Auto
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.
<div class="overflow-auto h-32 ...">Lorem ipsum dolor sit amet...</div>
Hidden
Use overflow-hidden
to clip any content within an element that overflows the bounds of that element.
<div class="overflow-hidden h-32 ...">Lorem ipsum dolor sit amet...</div>
Scroll horizontally if needed
Use overflow-x-auto
to allow horizontal scrolling if needed.
<div class="overflow-x-auto ...">QrLmmW69vMQD...</div>
Scroll vertically if needed
Use overflow-y-auto
to allow vertical scrolling if needed.
<div class="overflow-y-auto h-32 ...">Lorem ipsum dolor sit amet...</div>
Scroll horizontally always
Use overflow-x-scroll
to allow horizontal scrolling and always show scrollbars unless always-visible scrollbars are disabled by the operating system.
<div class="overflow-x-scroll ...">QrLmmW69vMQD...</div>
Scroll vertically always
Use overflow-y-scroll
to allow vertical scrolling and always show scrollbars unless always-visible scrollbars are disabled by the operating system.
<div class="overflow-y-scroll h-32 ...">Lorem ipsum dolor sit amet...</div>
Scroll 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.
<div class="overflow-scroll h-32 ...">Lorem ipsum dolor sit amet...</div>
Responsive
To apply an overflow utility only at a specific breakpoint, add a {screen}:
prefix to the existing class name. For example, adding the class md:overflow-scroll
to an element would apply the overflow-scroll
utility at medium screen sizes and above.
<div class="overflow-auto md:overflow-scroll ...">
Lorem ipsum dolor sit amet...
</div>
For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.
Customizing
Variants
By default, only responsive variants are generated for overflow utilities.
You can control which variants are generated for the overflow utilities by modifying the overflow
property in the variants
section of your tailwind.config.js
file.
For example, this config will also generate hover and focus variants:
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
+ overflow: ['hover', 'focus'],
}
}
}
Disabling
If you don’t plan to use the overflow utilities in your project, you can disable them entirely by setting the overflow
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ overflow: false,
}
}