Spacing & Sizing
Rosetta Stone: Spacing, Padding, Margin & Sizing
Every spacing utility in Standard (p-*, m-*, gap-*, w-*, h-*) accepts two interchangeable scales:
- Numeric Rhythm Scale (multiples of the vertical baseline
var(--space)=1rlh): bare class (.p,.gap) = 1 unit,.p-2...p-12= 2 to 12 units, plus fractions.p-halfand.p-trim. - Optical T-Shirt Scale (derived from
var(--scale-*)):3xs,2xs,xs,sm,base,lg,xl,2xl..6xl.
1. Scale Mapping (Token $\leftrightarrow$ Utility Suffix)
| Suffix | Example Utility | CSS Token (var(...)) |
Meaning |
|---|---|---|---|
| (bare) | .p, .m, .gap |
var(--space) |
1 baseline rhythm unit (1rlh) |
-half |
.p-half, .gap-half |
var(--space-half) |
0.5 baseline unit |
-trim |
.p-trim, .gap-compact |
var(--trim) / var(--gap-compact) |
Quarter-step micro spacing |
-2 .. -12 |
.p-2, .gap-4, .mt-6 |
var(--space-2) .. var(--space-12) |
2x to 12x baseline rhythm units |
-3xs .. -sm |
.p-xs, .p-sm, .gap-sm |
var(--scale-d5) .. var(--scale-d2) |
Optical micro/small steps |
-base |
.p-base, .gap-base |
var(--scale) |
Optical base font size (1rem) |
-lg .. -6xl |
.p-lg, .p-xl, .py-2xl |
var(--scale-2) .. var(--scale-8) |
Optical large steps |
-0 / -auto / -full |
.m-0, .mx-auto, .w-full |
0 / auto / 100% |
Reset, centering, full measure |
2. Logical Directions (RTL & Writing-Mode Safe)
| Prefix | CSS Property Emitted | Example |
|---|---|---|
p / m |
padding / margin (all 4 sides) |
.p-2, .m-0 |
px / mx |
padding-inline / margin-inline (horizontal axis) |
.px-2, .mx-auto |
py / my |
padding-block / margin-block (vertical axis) |
.py-half, .my-4 |
pt, pr, pb, pl |
padding-top, -right, -bottom, -left |
.pb-2, .pt-4 |
mt, mr, mb, ml |
margin-top, -right, -bottom, -left |
.mt-4, .mb-0 |
gap, gap-x, gap-y |
gap, column-gap, row-gap |
.gap-2, .gap-compact |
Generated spacing scale classes
Generated live via
@mixin generate-scalein_standard-50-utilities.scssacross all 13 spacing steps (0to12) and responsive breakpoints (sm:,md:,lg:).
One scale, stamped into 37 CSS properties by @include generate-scale(prefix, property) — one row below per call in the source. .{prefix} is the bare class (the scale’s default entry below); .{prefix}-{suffix} covers the rest of the scale.
| Suffix | Value |
|---|---|
| full | 100% |
| 0 | 0 |
| auto | auto |
| 3xs — Optical Scale | var(--scale-d5) |
| 2xs | var(--scale-d4) |
| xs | var(--scale-d3) |
| sm | var(--scale-d2) |
| base | var(--scale) |
| lg | var(--scale-2) |
| xl | var(--scale-3) |
| 2xl | var(--scale-4) |
| 3xl | var(--scale-5) |
| 4xl | var(--scale-6) |
| 5xl | var(--scale-7) |
| 6xl | var(--scale-8) |
| (bare) — Mathematical Unit Scale (1-12) | var(--space) |
| 2 | var(--space-2) |
| 3 | var(--space-3) |
| 4 | var(--space-4) |
| 5 | var(--space-5) |
| 6 | var(--space-6) |
| 7 | var(--space-7) |
| 8 | var(--space-8) |
| 9 | var(--space-9) |
| 10 | var(--space-10) |
| 11 | var(--space-11) |
| 12 | var(--space-12) |
| half | var(--space-d2) |
| trim — Vertical Rhythm Tokens | var(--trim) |
| leading | var(--leading) |
| Prefix | CSS property | Breakpoint | Classes |
|---|---|---|---|
w |
width |
— | .w / .w-{suffix} |
min-w |
min-width |
— | .min-w / .min-w-{suffix} |
max-w |
max-width |
— | .max-w / .max-w-{suffix} |
h |
height |
— | .h / .h-{suffix} |
min-h |
min-height |
— | .min-h / .min-h-{suffix} |
max-h |
max-height |
— | .max-h / .max-h-{suffix} |
m |
margin |
— | .m / .m-{suffix} |
my |
margin-block |
— | .my / .my-{suffix} |
mx |
margin-inline |
— | .mx / .mx-{suffix} |
mt |
margin-top |
— | .mt / .mt-{suffix} |
mr |
margin-right |
— | .mr / .mr-{suffix} |
mb |
margin-bottom |
— | .mb / .mb-{suffix} |
ml |
margin-left |
— | .ml / .ml-{suffix} |
p |
padding |
— | .p / .p-{suffix} |
py |
padding-block |
— | .py / .py-{suffix} |
px |
padding-inline |
— | .px / .px-{suffix} |
pt |
padding-top |
— | .pt / .pt-{suffix} |
pr |
padding-right |
— | .pr / .pr-{suffix} |
pb |
padding-bottom |
— | .pb / .pb-{suffix} |
pl |
padding-left |
— | .pl / .pl-{suffix} |
gap |
gap |
— | .gap / .gap-{suffix} |
gap-x |
column-gap |
— | .gap-x / .gap-x-{suffix} |
gap-y |
row-gap |
— | .gap-y / .gap-y-{suffix} |
sm:mt |
margin-top |
(max-width: $small) | .sm:mt / .sm:mt-{suffix} |
sm:mr |
margin-right |
(max-width: $small) | .sm:mr / .sm:mr-{suffix} |
sm:mb |
margin-bottom |
(max-width: $small) | .sm:mb / .sm:mb-{suffix} |
sm:ml |
margin-left |
(max-width: $small) | .sm:ml / .sm:ml-{suffix} |
sm:my |
margin-block |
(max-width: $small) | .sm:my / .sm:my-{suffix} |
sm:mx |
margin-inline |
(max-width: $small) | .sm:mx / .sm:mx-{suffix} |
sm:m |
margin |
(max-width: $small) | .sm:m / .sm:m-{suffix} |
sm:pt |
padding-top |
(max-width: $small) | .sm:pt / .sm:pt-{suffix} |
sm:pr |
padding-right |
(max-width: $small) | .sm:pr / .sm:pr-{suffix} |
sm:pb |
padding-bottom |
(max-width: $small) | .sm:pb / .sm:pb-{suffix} |
sm:pl |
padding-left |
(max-width: $small) | .sm:pl / .sm:pl-{suffix} |
sm:py |
padding-block |
(max-width: $small) | .sm:py / .sm:py-{suffix} |
sm:px |
padding-inline |
(max-width: $small) | .sm:px / .sm:px-{suffix} |
sm:p |
padding |
(max-width: $small) | .sm:p / .sm:p-{suffix} |
Sizing, gap & aspect ratio utilities
Extracted live from
_standard-50-utilities.scss.
Width
Widths the generated w-* scale does not cover: viewport units (screen), intrinsic sizes (min, max, fit) and the reading and mobile measures.
| Class | Declares |
|---|---|
.w-screen |
width: 100vw !important |
.w-min |
width: min-content !important |
.w-max |
width: max-content !important |
.w-fit |
width: fit-content !important |
.min-w-screen |
min-width: 100vw !important |
.max-w-none |
max-width: none !important |
.max-w-screen |
max-width: 100vw !important |
.max-w-mobile |
max-width: var(--breakpoint-mobile) !important |
.max-w-prose |
max-width: var(--prose-width) !important |
.narrow |
margin-inline: var(--prose-inset) !important |
.max-w-wide, .wide:not(.prose *) |
max-width: calc(var(--prose-width) + (var(--space-4) * 2)) !important |
.max-w-page |
max-width: var(--page-max-width) !important |
Height
Heights the generated h-* scale does not cover: viewport units and intrinsic sizes.
| Class | Declares |
|---|---|
.h-screen |
height: 100vh !important |
.h-min |
height: min-content !important |
.h-max |
height: max-content !important |
.h-fit |
height: fit-content !important |
.min-h-screen |
min-height: 100vh !important |
.max-h-none |
max-height: none !important |
.max-h-screen |
max-height: 100vh !important |
Spacing: Gaps
.gap-compact: a gap of --trim, the compact step of the baseline.
| Class | Declares |
|---|---|
.gap-compact |
gap: var(--gap-compact) !important |