stnd.build

Flexbox & Layout

Rosetta Stone: Flexbox, Alignment & Layout Helpers

Use Flexbox for 1D toolbars, button groups, and centered containers. Children of .flex, .flex-row, .flex-col, .flex-far, .flex-left, and .flex-right automatically have their vertical rhythm margins stripped so gap controls all spacing cleanly.

.flex-far  — Pushes left & right groups apart
Draft
.center-content — Centered on both horizontal & vertical axes

1. Core Flex Patterns

Intention HTML Utility Classes CSS Equivalent
Horizontal row with gap .flex gap-2 display: flex; gap: var(--space-2)
Vertical stack with gap .flex-col gap-2 display: flex; flex-direction: column; gap: var(--space-2)
Toolbar (left & right ends) .flex-far (or .flex justify-between items-center) display: flex; justify-content: space-between; align-items: baseline; gap: var(--space)
Push group to right .flex-right display: flex; justify-content: flex-end; align-items: baseline; gap: var(--space)
Center child in both axes .center-content display: flex; align-items: center; justify-content: center
Center bounded block horizontally .mx-auto (or .center-horizontally) margin-inline: auto
Vertical alignment .items-center, .items-start, .items-end, .items-baseline align-items: ...
Horizontal distribution .justify-between, .justify-center, .justify-end, .justify-start justify-content: ...

2. Copy-Paste Recipes

<!-- Toolbar: Title on the left, actions pushed to the right -->
<header class="flex-far py-half border-b">
  <h2 class="text-lg">Project Settings</h2>
  <div class="flex gap-half items-center">
    <button>Cancel</button>
    <button class="bg-accent">Save</button>
  </div>
</header>

<!-- Centered reading column outside .prose -->
<section class="max-w-prose mx-auto p-base">
  <h1>Centered Container</h1>
</section>

Flexbox & layout utility classes

Extracted live from _standard-50-utilities.scss.

Display

Display keywords. .hidden removes an element from the layout; the flex and grid helpers are under Flexbox and on the Grid System page.

Class Declares
.block display: block !important
.inline display: inline !important
.inline-block display: inline-block !important
.grid display: grid !important
.hidden display: none !important

Position

The positioning keywords.

Class Declares
.relative position: relative !important
.absolute position: absolute !important
.fixed position: fixed !important
.sticky position: sticky !important

Flexbox

Flex containers and the usual alignment, wrapping and distribution helpers. Children of a .flex have their rhythm margin removed so it never stacks with the gap (see Rhythm).

Class Declares
.flex, .flex-row, .flex-col display: flex !important
.flex-1 flex: 1 1 0% !important
.flex-row flex-direction: row !important
.flex-col flex-direction: column !important
.flex-wrap flex-wrap: wrap !important
.flex-nowrap flex-wrap: nowrap !important
.flex-far display: flex
.flex-right display: flex
.flex-left display: flex
.items-start align-items: flex-start !important
.items-center align-items: center !important
.items-end align-items: flex-end !important
.items-baseline align-items: baseline !important
.items-stretch align-items: stretch !important
.justify-start justify-content: flex-start !important
.justify-center justify-content: center !important
.justify-end justify-content: flex-end !important
.justify-between justify-content: space-between !important
.justify-around justify-content: space-around !important
.justify-evenly justify-content: space-evenly !important

Layout helpers

Centering, full-bleed breakouts and screen-height sections, for laying out a whole page.

Class Declares
.center-content display: flex
.center-horizontally margin-left: auto
.center-vertically display: flex
.no-body-margin margin-inline: calc((var(--page-padding) * -1)) !important
.full-bleed width: 100vw !important
.breakout width: min(100%, var(--page-max-width)) !important
.stnd-screen-break border: none
.stnd-screen-section width: 100%

Accessibility and resets

Visually hidden text for screen readers, removing decoration or bullets, and hyphenation and wrapping resets.

Class Declares
.visually-hidden position: absolute
.no-decoration, .no-decoration * text-decoration: none !important
.no-mouse pointer-events: none
.no-bullet list-style: none
.keep-words word-break: keep-all
.no-hyphen hyphens: none

Responsive breakpoints

Classes that apply at one breakpoint: the sm:, md: and lg: prefixes, and .only helpers that show an element at a single size (Breakpoints).

Class Declares
.sm\:hidden display: none !important
.sm\:only display: inherit !important
.md\:only display: none !important
.lg\:only display: none !important
.sm\:text-center text-align: center !important
.md\:hidden display: none !important
.sm\:only display: none !important
.md\:only display: inherit !important
.lg\:only display: none !important
.lg\:hidden display: none !important
.sm\:only display: none !important
.md\:only display: none !important
.lg\:only display: inherit !important