GuideOptional

Grid

Lay out a page with a 12-column grid, containers and breakpoint mixins.

Opt in

Grid is its own entry point. Add it to your global stylesheet.

@use 'ngwr/grid';

Breakpoints

NameMin widthContainer max-width
xs0—
sm576px540px
md768px720px
lg992px960px
xl1200px1140px
xxl1400px1320px
xga1600px1530px
fhd1920px1830px
rt2560px2470px

12-column grid

Give each cell col-<span>, or col-<breakpoint>-<span> to apply from that breakpoint up.

.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-2
.col-2
.col-2
.col-2
.col-2
.col-2
.col-3
.col-3
.col-3
.col-3
.col-4
.col-4
.col-4
.col-6
.col-6
.col-12
<div class="grid">
  <div class="col-12 col-md-6 col-lg-4">A</div>
  <div class="col-12 col-md-6 col-lg-4">B</div>
  <div class="col-12 col-md-12 col-lg-4">C</div>
</div>

Container

Caps the content width at each breakpoint.

<div class="container">…</div>          <!-- full width below sm, then steps up -->
<div class="container-md">…</div>       <!-- fluid below md, then steps up -->
<div class="container-fluid">…</div>    <!-- always 100% width -->

Gutter

One custom property sets the gap between cells and the container padding.

:root {
  --wr-grid-gutter: 1.5rem; /* default: 1rem */
}

Media-query mixin

The same breakpoints in your own SCSS. This entry emits no CSS.

@use 'ngwr/breakpoints' as bp;

.card {
  padding: 1rem;

  @include bp.media-up(md) {
    padding: 2rem;
  }

  @include bp.media-down(lg) {
    border-radius: 0;
  }
}

See also