Utilities
Overflow
Use these shorthand utilities for quickly configuring how content overflows an element.
Overview
Adjust the overflow property on the fly with four default values and classes. These classes
are not responsive by default.
.overflow-auto on an element with set width and height dimensions. By design, this content will vertically scroll.
.overflow-hidden on an element with set width and height dimensions.
.overflow-visible on an element with set width and height dimensions.
.overflow-scroll on an element with set width and height dimensions.
HTML
<div class="overflow-auto p-3 bg-body-tertiary border" style="max-width: 260px; max-height: 100px;">
This is an example of using <code>.overflow-auto</code> on an element with set width and height dimensions. By design, this content will vertically scroll.
</div>
<div class="overflow-hidden p-3 bg-body-tertiary border" style="max-width: 260px; max-height: 100px;">
This is an example of using <code>.overflow-hidden</code> on an element with set width and height dimensions.
</div>
<div class="overflow-visible p-3 bg-body-tertiary border" style="max-width: 260px; max-height: 100px;">
This is an example of using <code>.overflow-visible</code> on an element with set width and height dimensions.
</div>
<div class="overflow-scroll p-3 bg-body-tertiary border" style="max-width: 260px; max-height: 100px;">
This is an example of using <code>.overflow-scroll</code> on an element with set width and height dimensions.
</div>.overflow-auto.overflow-hidden.overflow-visible.overflow-scroll
overflow-x
Adjust the overflow-x property to affect the overflow of content horizontally.
.overflow-x-auto example on an element.overflow-x-hidden example.overflow-x-visible example .overflow-x-scroll example on an elementHTML
<div class="overflow-x-auto p-3 bg-body-tertiary border" style="max-width: 200px; max-height: 100px; white-space: nowrap;">
<div><code>.overflow-x-auto</code> example on an element</div>
<div>with set width and height dimensions.</div>
</div>
<div class="overflow-x-hidden p-3 bg-body-tertiary border" style="max-width: 200px; max-height: 100px; white-space: nowrap;">
<div><code>.overflow-x-hidden</code> example</div>
<div>on an element with set width and height dimensions.</div>
</div>
<div class="overflow-x-visible p-3 bg-body-tertiary border" style="max-width: 200px; max-height: 100px; white-space: nowrap;">
<div><code>.overflow-x-visible</code> example </div>
<div>on an element with set width and height dimensions.</div>
</div>
<div class="overflow-x-scroll p-3 bg-body-tertiary border" style="max-width: 200px; max-height: 100px; white-space: nowrap;">
<div><code>.overflow-x-scroll</code> example on an element</div>
<div>with set width and height dimensions.</div>
</div>.overflow-x-auto.overflow-x-hidden.overflow-x-visible.overflow-x-scroll
overflow-y
Adjust the overflow-y property to affect the overflow of content vertically.
.overflow-y-auto example on an element with set width and height dimensions.
.overflow-y-hidden example on an element with set width and height dimensions.
.overflow-y-visible example on an element with set width and height dimensions.
.overflow-y-scroll example on an element with set width and height dimensions.
HTML
<div class="overflow-y-auto p-3 bg-body-tertiary border" style="max-width: 200px; max-height: 100px;">
<code>.overflow-y-auto</code> example on an element with set width and height dimensions.
</div>
<div class="overflow-y-hidden p-3 bg-body-tertiary border" style="max-width: 200px; max-height: 100px;">
<code>.overflow-y-hidden</code> example on an element with set width and height dimensions.
</div>
<div class="overflow-y-visible p-3 bg-body-tertiary border" style="max-width: 200px; max-height: 100px;">
<code>.overflow-y-visible</code> example on an element with set width and height dimensions.
</div>
<div class="overflow-y-scroll p-3 bg-body-tertiary border" style="max-width: 200px; max-height: 100px;">
<code>.overflow-y-scroll</code> example on an element with set width and height dimensions.
</div>.overflow-y-auto.overflow-y-hidden.overflow-y-visible.overflow-y-scroll
Scroll snap
This theme adds scroll-snap-type utilities because the no-JS
carousel is built on scroll snapping. Put one on the scrolling
container and scroll-snap-align on the children (inline, or via your own CSS).
| Class | scroll-snap-type |
|---|---|
.snap-x | x mandatory |
.snap-y | y mandatory |
.snap-both | both mandatory |
.snap-none | none |
HTML
<div class="d-flex overflow-x-auto snap-x gap-3 pb-2">
<div class="flex-shrink-0 p-4 text-bg-navy rounded text-center" style="width: 60%; scroll-snap-align: start;">Match 1 — Opener</div>
<div class="flex-shrink-0 p-4 text-bg-navy rounded text-center" style="width: 60%; scroll-snap-align: start;">Match 2 — Tag team</div>
<div class="flex-shrink-0 p-4 text-bg-navy rounded text-center" style="width: 60%; scroll-snap-align: start;">Match 3 — Title bout</div>
<div class="flex-shrink-0 p-4 text-bg-navy rounded text-center" style="width: 60%; scroll-snap-align: start;">Match 4 — Cage</div>
</div>.overflow-x-auto (or -scroll) for the snap to have anything to snap.Accessibility
A box with overflow: auto or scroll is only keyboard-scrollable when it can take
focus. Add tabindex="0" and an accessible name (aria-label or a heading via
aria-labelledby) so keyboard users can reach the content. The docs' own code blocks do exactly
that.
CSS
"overflow": (
property: overflow,
values: auto hidden visible scroll,
),
"overflow-x": (
property: overflow-x,
values: auto hidden visible scroll,
),
"overflow-y": (
property: overflow-y,
values: auto hidden visible scroll,
),
// rb-bootstrap addition (scss/_utilities.scss)
"scroll-snap": (
property: scroll-snap-type,
class: snap,
values: (x: x mandatory, y: y mandatory, both: both mandatory, none: none),
),