Layout
Breakpoints
The six viewport widths that drive every responsive class, container and media query in the theme.
Core concepts
A breakpoint is a viewport width at which the layout is allowed to change. rb-bootstrap keeps Bootstrap's
six breakpoints untouched. Everything responsive — the grid,
containers, display and
flex utilities, the offcanvas and navbar components — reads from the
same $grid-breakpoints map.
- Mobile first. Styles apply from a breakpoint upwards. Write the small layout first and add
md,lg… classes to widen it. - Media queries use
min-width. Amax-widthmixin exists for the rare "only below this" case. - Infixes name the breakpoint.
.col-md-6,.d-lg-none,.g-xl-6— the same word wherever it appears. The smallest breakpoint,xs, has no infix.
Available breakpoints
The values are pixel widths because they target device classes, not type sizes. They are also exported as
CSS variables (--bs-breakpoint-sm …) on :root for use in your own code.
| Breakpoint | Class infix | Dimensions | CSS variable |
|---|---|---|---|
| Extra small | none | < 576px | --bs-breakpoint-xs: 0 |
| Small | sm | ≥ 576px | --bs-breakpoint-sm: 576px |
| Medium | md | ≥ 768px | --bs-breakpoint-md: 768px |
| Large | lg | ≥ 992px | --bs-breakpoint-lg: 992px |
| Extra large | xl | ≥ 1200px | --bs-breakpoint-xl: 1200px |
| Extra extra large | xxl | ≥ 1400px | --bs-breakpoint-xxl: 1400px |
The map in Sass:
$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1400px
);
lg. That is the
same breakpoint the navbar uses to stop collapsing.Media queries
Bootstrap ships four mixins. Each takes a key from $grid-breakpoints. The theme does not alter
them; it only passes different values through them.
Min-width
The default. Styles apply at that width and everything above it.
// No media query for `xs` since it is the baseline
@include media-breakpoint-up(sm) { ... }
@include media-breakpoint-up(md) { ... }
@include media-breakpoint-up(lg) { ... }
@include media-breakpoint-up(xl) { ... }
@include media-breakpoint-up(xxl) { ... }
// Example: give the ring-card a border only from md up
.ring-card {
@include media-breakpoint-up(md) {
border: var(--bs-border-width) solid var(--bs-border-color);
}
}
Compiled output:
@media (min-width: 576px) { ... }
@media (min-width: 768px) { ... }
@media (min-width: 992px) { ... }
@media (min-width: 1200px) { ... }
@media (min-width: 1400px) { ... }
Max-width
Occasionally you need the opposite direction. media-breakpoint-down targets everything
below the named breakpoint. The value is breakpoint − .02px to avoid overlap at
fractional viewport widths.
// No media query necessary for xxl since there is nothing above it
@include media-breakpoint-down(sm) { ... }
@include media-breakpoint-down(md) { ... }
@include media-breakpoint-down(lg) { ... }
@include media-breakpoint-down(xl) { ... }
@include media-breakpoint-down(xxl) { ... }
// Example: stack the tale-of-the-tape below md
.tape {
@include media-breakpoint-down(md) {
flex-direction: column;
}
}
@media (max-width: 575.98px) { ... }
@media (max-width: 767.98px) { ... }
@media (max-width: 991.98px) { ... }
@media (max-width: 1199.98px) { ... }
@media (max-width: 1399.98px) { ... }
Single breakpoint
Target one breakpoint only — its minimum up to the next breakpoint's minimum.
@include media-breakpoint-only(xs) { ... }
@include media-breakpoint-only(sm) { ... }
@include media-breakpoint-only(md) { ... }
@include media-breakpoint-only(lg) { ... }
@include media-breakpoint-only(xl) { ... }
@include media-breakpoint-only(xxl) { ... }
For example, media-breakpoint-only(md) compiles to:
@media (min-width: 768px) and (max-width: 991.98px) { ... }
Between breakpoints
Span a range with a lower and an upper key.
@include media-breakpoint-between(md, xl) { ... }
@media (min-width: 768px) and (max-width: 1199.98px) { ... }
Infix naming
Every responsive class follows .{property}-{infix}-{value}. Leave the infix out for the
xs baseline. A few examples from this theme, all using the same six keys:
| Pattern | Examples | Page |
|---|---|---|
.col-{bp}-{n} | .col-6, .col-md-4, .col-xxl-auto | Grid |
.g-{bp}-{0–8} | .g-4, .gx-lg-7, .gy-md-0 | Gutters |
.g-col-{bp}-{n} | .g-col-6, .g-col-md-4 | CSS grid |
.container-{bp} | .container-md, .container-xxl | Containers |
.d-{bp}-{value} | .d-none, .d-lg-flex | Display |
.order-{bp}-{n}, .offset-{bp}-{n} | .order-md-first, .offset-lg-3 | Columns |
.table-responsive-{bp} | .table-responsive-md | Tables |
The infix always refers to a min-width. .d-lg-none hides the element at
lg and above, not only at lg.