Breakpoints

Breakpoints are the triggers in Bootstrap React for how your layout responsive changes across device or viewport sizes.

Core concepts#

  • Breakpoints are the building blocks of responsive design. Use them to control when your layout can be adapted at a particular viewport or device size.

  • Use media queries to architect your CSS by breakpoint. Media queries are a feature of CSS that allow you to conditionally apply styles based on a set of browser and operating system parameters. We most commonly use min-width in our media queries.

  • Mobile first, responsive design is the goal. Bootstrap React's CSS aims to apply the bare minimum of styles to make a layout work at the smallest breakpoint, and then layers on styles to adjust that design for larger devices. This optimizes your CSS, improves rendering time, and provides a great experience for your visitors.

Available breakpoints#

Bootstrap React includes six default breakpoints, sometimes referred to as grid tiers, for building responsively. These breakpoints can be customized if you're using our source Sass files.

BreakpointClass infixDimensions
X-SmallNone<576px
Smallsm≥576px
Mediummd≥768px
Largelg≥992px
Extra largexl≥1200px
Extra extra largexxl≥1400px

Each breakpoint was chosen to comfortably hold containers whose widths are multiples of 12. Breakpoints are also representative of a subset of common device sizes and viewport dimensions—they don't specifically target every use case or device. Instead, the ranges provide a strong and consistent foundation to build on for nearly any device.

These breakpoints are customizable via Sass—you'll find them in a Sass map in our _variables.scss stylesheet.

1$grid-breakpoints: (
2 xs: 0,
3 sm: 576px,
4 md: 768px,
5 lg: 992px,
6 xl: 1200px,
7 xxl: 1400px
8);

For more information and examples on how to modify our Sass maps and variables, please refer to the Sass section of the Grid documentation.

Media queries#

Since Bootstrap React is developed to be mobile first, we use a handful of media queries to create sensible breakpoints for our layouts and interfaces. These breakpoints are mostly based on minimum viewport widths and allow us to scale up elements as the viewport changes.

Min-width#

Bootstrap React primarily uses the following media query ranges—or breakpoints—in our source Sass files for our layout, grid system, and components.

1// Source mixins
2
3// No media query necessary for xs breakpoint as it's effectively `@media (min-width: 0) { ... }`
4@include media-breakpoint-up(sm) { ... }
5@include media-breakpoint-up(md) { ... }
6@include media-breakpoint-up(lg) { ... }
7@include media-breakpoint-up(xl) { ... }
8@include media-breakpoint-up(xxl) { ... }
9
10// Usage
11
12// Example: Hide starting at `min-width: 0`, and then show at the `sm` breakpoint
13.custom-class {
14 display: none;
15}
16@include media-breakpoint-up(sm) {
17 .custom-class {
18 display: block;
19 }
20}

These Sass mixins translate in our compiled CSS using the values declared in our Sass variables. For example:

1// X-Small devices (portrait phones, less than 576px)
2// No media query for `xs` since this is the default in Bootstrap React
3
4// Small devices (landscape phones, 576px and up)
5@media (min-width: 576px) { ... }
6
7// Medium devices (tablets, 768px and up)
8@media (min-width: 768px) { ... }
9
10// Large devices (desktops, 992px and up)
11@media (min-width: 992px) { ... }
12
13// X-Large devices (large desktops, 1200px and up)
14@media (min-width: 1200px) { ... }
15
16// XX-Large devices (larger desktops, 1400px and up)
17@media (min-width: 1400px) { ... }

Max-width#

We occasionally use media queries that go in the other direction (the given screen size or smaller):

1// No media query necessary for xs breakpoint as it's effectively `@media (max-width: 0) { ... }`
2@include media-breakpoint-down(sm) { ... }
3@include media-breakpoint-down(md) { ... }
4@include media-breakpoint-down(lg) { ... }
5@include media-breakpoint-down(xl) { ... }
6@include media-breakpoint-down(xxl) { ... }
7
8// Example: Style from medium breakpoint and down
9@include media-breakpoint-down(md) {
10 .custom-class {
11 display: block;
12 }
13}

These mixins take those declared breakpoints, subtract .02px from them, and use them as our max-width values. For example:

1// X-Small devices (portrait phones, less than 576px)
2@media (max-width: 575.98px) { ... }
3
4// Small devices (landscape phones, less than 768px)
5@media (max-width: 767.98px) { ... }
6
7// Medium devices (tablets, less than 992px)
8@media (max-width: 991.98px) { ... }
9
10// Large devices (desktops, less than 1200px)
11@media (max-width: 1199.98px) { ... }
12
13// X-Large devices (large desktops, less than 1400px)
14@media (max-width: 1399.98px) { ... }
15
16// XX-Large devices (larger desktops)
17// No media query since the xxl breakpoint has no upper bound on its width
Why subtract .02px? Browsers don’t currently support range context queries, so we work around the limitations of min- and max- prefixes and viewports with fractional widths (which can occur under certain conditions on high-dpi devices, for instance) by using values with higher precision.

Single breakpoint#

There are also media queries and mixins for targeting a single segment of screen sizes using the minimum and maximum breakpoint widths.

1@include media-breakpoint-only(xs) { ... }
2@include media-breakpoint-only(sm) { ... }
3@include media-breakpoint-only(md) { ... }
4@include media-breakpoint-only(lg) { ... }
5@include media-breakpoint-only(xl) { ... }
6@include media-breakpoint-only(xxl) { ... }

For example the @include media-breakpoint-only(md) { ... } will result in :

1@media (min-width: 768px) and (max-width: 991.98px) { ... }

Between breakpoints#

Similarly, media queries may span multiple breakpoint widths:

1@include media-breakpoint-between(md, xl) { ... }

Which results in:

1// Example
2// Apply styles starting from medium devices and up to extra large devices
3@media (min-width: 768px) and (max-width: 1199.98px) { ... }