Tailwind CSS Overflow
The overflow utility class in Tailwind CSS allows you to control how content that overflows its container is displayed.
Tailwind Overflow
The overflow
utility class in Tailwind CSS allows you to control how content that overflows its container is displayed. With Tailwind's overflow class, you can specify whether to show or hide the overflowing content, and how it should be scrolled if necessary.
Applying Overflow
To apply the overflow behavior to an element, you can use the overflow-{value}
utility class, where {value}
represents the desired overflow behavior. Here are the available options:
- overflow-auto: Automatically shows scrollbars when needed, and hides them when not needed.
- overflow-hidden: Hides any content that overflows the container.
- overflow-visible: Displays the overflowing content without any clipping.
- overflow-scroll: Always shows scrollbars, even if the content doesn't overflow.
- overflow-x-auto: Applies auto overflow on the horizontal axis only.
- overflow-y-auto: Applies auto overflow on the vertical axis only.
<div class="overflow-y-scroll"> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda, quia temporibus eveniet a libero incidunt suscipit.</div>
Preview
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda, quia temporibus eveniet a libero incidunt suscipit.
Responsive Overflow
Tailwind CSS allows you to apply overflow classes responsively at different breakpoints. To use responsive overflow classes, you can append the breakpoint prefix to the utility class. For example, md:overflow-hidden hides overflowing content starting from the medium breakpoint and above.
<div class="overflow-auto md:overflow-hidden"> <!-- Content that may overflow --></div>
In the above example, the overflow behavior is set to auto by default (overflow-auto
), but starting from the medium breakpoint and above, the overflow behavior is changed to hidden (md:overflow-hidden
).
Tailwind Overflow Class Table
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; |
Windframe Tailwind blocks
Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs