Layout and grid
A centered page, a 12-column grid and four breakpoints. Phones get one column; from tablets up, content takes the columns you give it.
- CSS
css/base.css, css/components/panel.css, css/components/section-head.css
01 — The grid
Twelve columns
Put .grid on a container. Each child spans all 12 columns until you say otherwise. Gutters grow from 16px on a phone to 32px on a wide screen.
How to use it
.span-1to.span-12set how many columns a child takes..start-1to.start-12set the column it starts in. Combine them:class="span-9 start-4"runs from column 4 to 12.- Below 48rem (tablets) every child is full width, so phones get one column without extra classes.
- Children that don’t fill a row wrap to the next one. Rows space themselves with
row-gap(32px). - Nest a
.gridinside a child to divide it again.
02 — Common layouts
Halves
Two equal columns: a form and its help, two cards.
Thirds
Three cards or figures.
Sidebar and content
A narrow column for a title or filters, and a wide one for content.
Editorial offset
Jewel’s signature: content panels start their content at column 4, under the section head, and leave the first three columns empty.
Centered
A narrow centered column for reading.
03 — Breakpoints
Four breakpoints, mobile first
Style the phone first, then add min-width rules. Custom properties can’t be read inside @media, so write the value and name the token beside it: @media (min-width: 48rem) { … } /* --bp-md */.
| Token | Value | What changes |
|---|---|---|
--bp-sm | 40rem, 640px | Large phones. Phone-only tweaks use max-width: 40rem; tables stack below it. |
--bp-md | 48rem, 768px | Tablets. The grid opens up and the header shows its links instead of the menu button. |
--bp-lg | 64rem, 1024px | Laptops. The side nav becomes a column beside the content. |
--bp-xl | 80rem, 1280px | The page stops growing at --page-max. |
04 — Page structure
The frame
A page is the background, the cap, then .page holding the sticky header and a column of content panels. The gradient shows between the panels.
Section head
A numbered label opens each content panel. The rule under it runs to both edges of the panel. Content follows in span-9 start-4.
01 — Typography
One family, many voices
Content starts at column 4, under the label.
With a side nav
Wrap the page in .with-side-nav to put a sticky nav column beside the content from 64rem. This site is built that way; see Side nav.
05 — Stacking order
Z-index
Use the scale, never a raw number. Sheets, the lightbox and pop-up menus open in the browser’s top layer, above everything.
| Token | Value | What it’s for |
|---|---|---|
--z-below | The lava lamp animation | |
--z-base | Normal flow | |
--z-raised | Badges over photos, sticky table headers | |
--z-overlay | Hover cards inside a component | |
--z-cap | The cap above the header | |
--z-sticky | The sticky header | |
--z-fab | The floating action button | |
--z-dropdown | Menus, calendars, suggestions | |
--z-drawer | The side nav drawer | |
--z-toast | Toasts, skip links |
06 — Usage
Use it for
.gridfor page-level layout;.stackand.clusterinside components.span-9 start-4for the content of a content panel.- Letting phones fall back to one column.
Avoid
- Fixed widths in pixels. Let the grid and
--page-maxdecide. - A breakpoint value that isn’t one of the four.
- Raw z-index numbers.
07 — Tokens
| Token | Value | What it’s for |
|---|---|---|
--grid-columns | Columns in .grid | |
--grid-gutter | Space between columns | |
--page-max | Widest the page gets | |
--page-margin | Space at the page edges | |
--panel-padding | Inside a padded panel | |
--sticky-offset | Gap above the header | |
--header-h | Header height | |
--side-nav-w | Side nav column | |
--bp-sm | Large phones | |
--bp-md | Tablets | |
--bp-lg | Laptops | |
--bp-xl | Wide screens | |
--layer-w-sm | Menus: minimum width | |
--layer-w-md | Menus: maximum width, drawer | |
--layer-w-lg | Floating chat | |
--layer-h | Menus scroll past this | |
--region-h | Tall code and tables scroll past this | |
--chat-h | Chat in a page |