Dustin Johnson ← Design Primitives
Design Primitive Reference · Part I · October 2026

Spacing & Density

The base unit, the scale built from it, and the rules that bind one gap to the next — how space does the grouping work of an interface, and how a system decides how much of it to spend.

I. Why Space Is a Primitive

Space is not what is left over after the content is placed. It is the material that tells the eye which things belong together — and in most interfaces it does more of that work than every border, background, and divider combined.

Start with the failure, because it is the common case. A screen where a card's padding is 8px, the gap beneath its title is 22px, the space between two form fields is 10px, the space between those fields and the next section is 13px, and a toolbar somewhere above sits 40px from everything. Every one of those values was chosen by someone, for a reason that made sense in the moment and in the component they were building. None of them was chosen relative to the others. The result is a screen that no one can describe as wrong in any single place and everyone can feel is wrong as a whole — it reads as unfinished, and worse, it reads as structured in ways it isn't.

Notification settings
Choose what reaches you.
Email
Weekly digest
Mobile
Mentions only
CancelSave
Ad hoc · 2 / 22 / 10 / 7 / 3 / 13
Notification settings
Choose what reaches you.
Email
Weekly digest
Mobile
Mentions only
CancelSave
On a scale · 4 / 16 / 24 by level
Same content, same components. Left: “Mobile” sits closer to the field above it than to its own field. Right: four values, each meaning one relationship.

The mechanism behind that unease is old and well understood. The Gestalt principle of proximity says that elements closer to each other than to their surroundings are perceived as a group, and the perception is pre-attentive — it happens before reading, before the user has decided to look at anything. That makes space the cheapest grouping device a system has. A border groups too, but it costs ink, contrast, and a line the eye must parse; a background fill groups, but it adds a surface that must then be padded, and the padding must then be spaced. Proximity groups for free.

Uniform · One field of dots
Proximity · Two groups, zero ink
Enclosure · Same groups, more ink

The practical consequence is that a product which does not control proximity ends up compensating with enclosure. When gaps carry no meaning, teams draw boxes to restore the grouping that space failed to provide — then pad the boxes, then nest boxes inside boxes — and the screen becomes what designers call box soup: every group outlined, every outline competing with the content. Most “this screen feels heavy” complaints are spacing problems wearing a border costume.

A spacing system answers three questions, and this part takes them in order. Which values exist — the base unit and the scale (sections II–III). Where each value is used — the roles of space (IV). Which gaps must be larger than which — the relationships, above all the nesting rule (V–VI). Then a fourth, system-wide question sits over all three: how much space the product spends by default — its density posture (VII–VIII).

A spacing system is not a list of values. It is a set of inequalities — this gap is smaller than that one — and the values exist only to make the inequalities easy to keep.

II. The Base Unit

The base unit is the quantum of the system: every spacing value is a whole multiple of it. Its job is less mathematical than social. A base unit removes a decision from every person who will ever touch the product — nobody debates 13px versus 14px when neither is legal — and it makes values communicable: “one step bigger” means the same thing to a designer in a design tool and an engineer in a stylesheet.

Why 4 Won

For most of the last decade the loudest convention was the 8-point grid: every dimension a multiple of 8. The argument is sound as far as it goes. Eight divides cleanly into common screen dimensions, survives the 1.5× and 3× pixel densities of mobile screens without fractional pixels, and its steps are big enough to be visibly different from each other, which discourages fiddling.

Where 8 breaks down is inside components. The numbers that recur at small scale are not multiples of 8: the 20px line-height of 14px body text, the 12px gap between an icon and its label, the 36px and 28px heights of default and compact controls, the 44pt touch target. A strict 8-point system has to either reject those values or quietly cheat. In practice almost every “8-point” system cheats in the same direction — it uses multiples of 8 for layout and allows multiples of 4 for the inside of components. Material made this explicit long ago: an 8dp grid for components and layout, a 4dp baseline grid for type and iconography. Once the half-step is allowed, the system is a 4-point system that prefers its even steps. The industry has converged on saying so directly.

4 px base · every need lands on a tick
12 16 20 28 36 44
081624324048
8 px base · four of six fall between ticks
12 16 20 28 36 44
081624324048
12icon-to-label gap; compact inset 16standard icon; default container inset 20line-height of 14px body text 28compact control and row height 36default control height 44touch-target floor (Apple HIG)
Rendered at 6× scale. The values a component needs most are the ones an 8-point grid forbids.

Below 4 there is a small, legitimate territory: 1px and 2px values exist in nearly every mature system, for borders, focus-ring offsets, and optical nudges. Carbon's scale begins at 2px, and Atlassian's at 2px as a quarter-step. Treat that territory as an escape hatch for detailing, never as a layout value — a 2px gap between two things says they are one thing.

SystemBaseHow it is expressed
Material8 / 4 dp8dp grid for layout and components; 4dp baseline grid for type and icons.
Carbon8 px / 2 pxThe 2x Grid is built from an 8px “mini unit”; the spacing tokens reach down to 2px and 4px for detail work.
Apple HIGpointsSpecifies in points rather than declaring a grid; standard margins and the 44×44pt minimum hit target are where the iOS 8-point convention grew from. See Layout.
Tailwind0.25remOne spacing unit is 0.25rem (4px at the default root); p-4 is 16px. See padding.
Atlassian8 pxTokens named as multiples of 8: space.100 is 8px, with space.050 and space.025 as half and quarter steps.
Polaris4 pxTokens named as multiples of 4: space-100 is 4px, space-400 is 16px. See space tokens.
Primer4 pxBase sizes in 4px steps (2px at the bottom), with role tokens built on top.

Read the table for the pattern, not the differences. Systems that state an 8px base (Carbon, Atlassian) still ship 4px and 2px values; systems that state a 4px base (Polaris, Primer, Tailwind) still lean on the even steps for layout. Everyone ends up in the same place. The recommendation here is to state the truth: a 4px base, with a scale that thins out as it grows, which is what the next section builds.

px or rem for Space

Type should be specified in rem so that it respects the user's browser font-size preference — that is settled, and Buttons Part IV §A1 makes the argument in full. Whether space should follow is a genuine trade-off, and the two answers fail in opposite directions.

Spacing in rem scales the whole layout with the user's font preference. Text keeps its proportion to the padding around it, which is good; but a user who sets their default to 24px also gets 144px section gaps and 48px page margins, and on a laptop screen the layout runs out of width long before the text gets comfortable. Spacing in px holds the layout still while text grows inside it, which preserves real estate; but the padding inside a button or input stays fixed while its label swells, and the control starts to look crammed. (Browser zoom, the more common accommodation, scales px and rem alike, so it does not decide the question.)

The resolution most careful systems reach is to split by role. The inset of text-bearing components should scale with the text it surrounds — em or rem — because its whole purpose is to frame that text. Layout space — section gaps, page margins, gutters — generally should not scale the way type does, because it is spending the screen, and the screen did not get bigger. Systems that author everything in rem, as Tailwind and Carbon do, have made a defensible choice for proportional scaling; the choice that is not defensible is mixing units within a single role, so that two adjacent cards scale differently.

III. Scale Generation

The base unit says which values are possible. The scale says which are allowed. Those are very different sets: a 4px base permits 4, 8, 12, 16, 20, 24, 28, and on forever, and a system that permits all of them has not made a decision — it has only rounded.

Linear, Geometric, Hybrid

Linear · 4n · every multiple, 12 steps to 48
4
8
12
16
20
24
28
32
36
40
44
48
Geometric · ×2 · perceptually even, missing 12 and 24
4
8
12?
16
24?
32
64
Hybrid · linear at the bottom, widening at the top
4
8
12
16
24
32
48
64
96
Actual size. Dashed squares in the linear scale are steps you cannot tell apart at a glance — which means different people will pick different ones.

A linear scale — every multiple of the base — is right at the bottom and wrong at the top. Between 4 and 8 the difference is a doubling; between 44 and 48 it is under ten percent, below what anyone notices across a screen. Perception of size is roughly logarithmic (the Weber–Fechner observation: the smallest noticeable change grows in proportion to the thing being changed), so equal arithmetic steps produce steps that feel enormous when small and invisible when large.

A geometric scale — each step a fixed ratio of the last — fixes the top end and breaks the bottom. Doubling from 4 gives 4, 8, 16, 32, 64, which skips 12 and 24: two of the most-used values in any interface. A gentler ratio (1.5×) produces fractional values that must be rounded back to the base, at which point it is no longer geometric.

The hybrid is where nearly every production system has landed: linear steps of 4 through 16, where fine control inside components matters, then widening steps above. The shape is so consistent across Carbon, Atlassian, Polaris, Primer, and Material that it is fair to call it the industry's answer.

TokenActual sizepxrem× prev space-140.25— space-280.52.00 space-3120.751.50 space-41611.33 space-6241.51.50 space-83221.33 space-124831.50 space-166441.33 space-249661.50
The reference scale for this series: nine steps on a 4px base. Above 8, neighbors settle into an alternation of ×1.5 and ×1.33.

Look at the last column. Past the first doubling, adjacent steps alternate between roughly 1.5× and 1.33× — every step is a clearly perceptible jump, and no step is so large that the gap between neighbors becomes a hole. That is the property to preserve when adapting the scale. Adding 20 is common and harmless (it sits between 16 and 24 at 1.25× and 1.2×, the edge of distinguishable); adding 40 between 32 and 48 is about as fine as the top end can go; adding 28 or 36 to the scale is a sign that someone is matching a mockup rather than choosing a relationship.

How Many Steps

Eight to twelve. Fewer than about eight and the scale cannot express the levels of nesting a real application has (section V needs at least five distinct levels, and inset needs a few of its own). More than about twelve and adjacent steps become indistinguishable, which quietly reintroduces the problem the scale was built to solve: if 40 and 44 are both legal and look the same, half the team will pick one and half the other, and the screen drifts back toward ad hoc.

Twenty-step scales fail for exactly that reason, and the most visible counterexample proves the rule rather than breaking it. Tailwind's default spacing has over thirty steps, and in v4 it is a multiplier — --spacing times any integer. That is the right design for a framework, which must serve every product; it is the wrong scale for a product, which must serve one. Teams on Tailwind that stay coherent are the ones that agree on a subset and treat the rest as off-limits. For contrast, the theme this series is set in uses an editorial scale of just seven steps — 4, 8, 16, 32, 48, 72, 120 — because a reading surface has few relationships to express and wants each of them unmistakable.

Naming the Steps

Convention16px is calledUsed byTrade-off
Multiplierspace-4 · space-400 · space.200Tailwind, Polaris, AtlassianName encodes the math; a new step (space-5) slots in without renaming. Must know the base to read it.
Valuespace-16Common in homegrown systemsMaximally honest. Retuning a value means renaming the token — arguably correct, since every usage changes.
Ordinalspacing-05CarbonCompact and stable, but the value is opaque, and inserting a step between 05 and 06 is impossible.
T-shirtspace-mdMany older systemsMemorable and speakable. Runs out (xxl, xxxl), cannot take inserted steps, and invites arguing about what “medium” means.

The honest summary: numeric names are honest and named tokens are memorable, and a system can have both by giving each its own layer. Name the scale numerically, because the scale is math and should look like math. Put memorable names on the layer above it — the role tokens in the next section — where a name like inset-md carries meaning (“the default padding of a container”) that a number never could. Systems get into trouble when they use t-shirt names on the raw scale, because then md has to mean both “16px” and “the normal amount,” and the first time the normal amount changes, it can't.

A good scale makes the right value easy to find and the wrong value impossible to type. A scale with too many steps does neither.

IV. The Three Roles of Space

The same 12px can be three different things: the padding inside a card, the gap between two paragraphs, or the gap between two buttons. They draw from one scale, but they answer different questions and change for different reasons, and a system that does not distinguish them ends up unable to change any of them safely.

The vocabulary most systems now use comes from Nathan Curtis's 2016 essay “Space in Design Systems”. Inset is the padding inside a container, between its edge and its content. Stack is the vertical gap between siblings flowing down the page. Inline is the horizontal gap between siblings sitting in a row.

Inset · 24card padding
Project · Q4
Billing migration
Stack · 12between blocks
Move invoicing to the new ledger before the January close. Three teams, one cutover weekend.
Finance Inline · 8within a row Platform Due Jan 6
Inset · 24 Stack · 12 / 4 Inline · 8
Toggle the reveal: the card's own surface is the inset, the horizontal hatching is stack, the vertical hatching is inline. The 4px under the eyebrow is a tighter stack — the nesting rule, previewed.

Naming space by role matters because each role has a different owner and a different reason to change. Inset belongs to the component: a card knows how much padding it needs to frame its content, and that should travel with the card wherever it is placed. Stack and inline belong to the parent: how far a card sits from the card below it is not the card's business — it depends on what the two cards mean to each other, which only the layout that contains them knows.

The engineering rule that falls out of this is the most effective single fix for an inconsistent product: components never set their own outer margin. A button with margin-left: 16px baked in, or a card with margin-bottom: 24px, has decided its neighbors' spacing for them; drop it into a different layout and that decision is now wrong, and someone overrides it with a one-off, and the one-off becomes the next “which margin is this?” Parents set gaps between their children — in modern CSS, with the gap property on flex and grid containers, which every current browser supports and which has made margin-based spacing largely unnecessary. Components set only their inset.

Role tokenDefaultOwnerTypical use
inset-control8 · 12ComponentVertical · horizontal padding inside buttons, inputs, menu items.
inset-container-sm12ComponentPopovers, compact cards, list cells.
inset-container-md16ComponentDefault cards and panels.
inset-container-lg24ComponentDialogs, prominent cards, page regions.
stack-tight4ParentLabel to field, title to metadata — things that are one unit.
stack-related16ParentSiblings within a group: fields in a fieldset, items in a list.
stack-group32ParentBetween groups inside one region.
stack-section64ParentBetween page sections or major regions.
inline-tight4ParentIcon to label inside a compact control.
inline-related8ParentButtons in a button group, tags in a row.
inline-group24ParentBetween clusters in a toolbar.

Notice that the role tokens are fewer and more meaningful than the scale they draw from. A designer choosing the gap between two fieldsets does not reach for “32px”; they reach for stack-group, and the system decides what that is. When the system later decides groups should breathe more — or less, in a compact posture — it changes one token, and every fieldset in the product moves together. That is the payoff of the second layer, and it is impossible without it.

Gap, Gutter, and Where Layout Begins

Two words that are often used interchangeably should not be. Gap is the generic term for space between siblings — every stack and inline value is a gap. Gutter is the grid's word for the gap between columns, and choosing it is a layout decision: how many columns, how wide, what happens at each breakpoint. That belongs to the Grid & Layout chapter. The boundary is clean: gutters draw their values from this scale, and they obey this chapter's nesting rule (a gutter is an outer gap relative to anything inside a column), but the column structure itself — and the decision of which scale step the gutter takes at which width — lives there.

V. The Nesting Rule

If a team keeps only one spacing rule, it should be this one: the space between elements must be smaller than the space around their group — at every level. Inner gaps are smaller than outer gaps, which are smaller than section gaps, all the way up. It is proximity, stated as an engineering constraint.

The rule is simple enough to sound obvious, and violated often enough in production to be worth demonstrating in full. Below is the same two-group form three times. The content, components, and fields are identical; only the gaps differ.

Shipping
Full name
Ada Lovelace
Street
12 Marylebone Rd
Billing
Card number
•••• 4242
Postcode
NW1 5LR
Nested · 4 < 16 < 40 Reads correctly
Shipping
Full name
Ada Lovelace
Street
12 Marylebone Rd
Billing
Card number
•••• 4242
Postcode
NW1 5LR
Equal · 16 everywhere Grouping collapses
Shipping
Full name
Ada Lovelace
Street
12 Marylebone Rd
Billing
Card number
•••• 4242
Postcode
NW1 5LR
Inverted · inner > outer Labels belong to the wrong field
Read each column without the numbers first. Bold brackets mark the gaps that break the rule.

The nested column reads instantly: two groups, each a heading over two label–field pairs. Nobody has to think about it, which is the point — the structure is perceived, not read.

The equal column is the most common failure in products that have a spacing scale but no rules for using it, because “use 16 everywhere” feels like consistency. It is uniformity, which is different. With every gap identical, proximity carries no information; the form becomes a single undifferentiated list of ten things, and the only remaining cue that “Billing” starts a new group is its font weight. Labels float equidistant between the field above and the field below. Users can still complete the form — they do it by reading, more slowly, and with less confidence about what belongs to what.

The inverted column is the one that causes real errors. Each label sits 4px below the previous field and 16px above its own, so proximity binds “Street” to the name field above it. The eye pairs them wrong before the user has read a word. Error messages placed under a field get attributed to the next label. The billing heading, only 8px below the shipping postcode field, reads as a trailing caption for shipping. This pattern rarely comes from anyone choosing it; it emerges when a label component carries a large margin-bottom and the field component a small one, or when a design tool's auto-layout spacing is set on the wrong frame. That is the strongest argument for section IV's ownership rule: gaps owned by parents cannot invert by accident.

The Levels

LevelRelationshipRangeExamples
0 · WithinParts of one element4–8Icon to label inside a button; avatar to name in a chip.
1 · BoundTwo things that are one unit4–8Label to field; title to its metadata; field to its hint.
2 · SiblingsPeers in a group12–24Field to field; list item to list item; card to card in a set.
3 · GroupsGroups within a region32–48Fieldset to fieldset; card set to the heading of the next set.
4 · RegionsSections of a page64–96Page sections; major panels; the space below a page header.

Two properties of this table are the rule; the exact numbers are not. First, each level is strictly larger than the one inside it. Second, adjacent levels differ by at least one full scale step, preferably two — because of the same logarithmic perception that shaped the scale, a 16px gap next to a 20px gap does not read as two levels; it reads as sloppiness. The 4 → 16 → 40 progression in the first column is two steps between each level, and that is why it reads without effort.

Enclosure Buys Exemptions

The rule is strictest for groups defined only by space. Once a group has an edge — a border, a background, a card surface — the edge does some of the grouping, and the outer gap can relax. A grid of bordered cards can sit 16px apart with 24px of inset inside each card, an apparent inversion that reads perfectly well because the borders have already settled what belongs to what. This is a legitimate trade, but recognize it as a trade: you are spending ink to save space. It is the right call in dense dashboards, and the wrong reflex everywhere else, where it leads straight back to box soup.

Auditing a Screen

The nesting rule is also the most practical audit a team can run on an existing product. Take a screenshot, measure and annotate every vertical gap, then label each gap with its level from the table above. Two kinds of finding fall out immediately: inversions, where an inner gap is larger than or equal to the gap outside it (fix these first — they cause misreading), and level drift, where the same level has five different values across the screen (fix these second — they are why the screen feels unfinished). A team that does this once on its three most-used screens will usually discover that its spacing problem is not a hundred problems but four or five recurring inversions, each traceable to a component carrying a margin it should not have.

Less space inside, more space between, at every level. When a screen feels wrong and no one can say why, measure the gaps and look for the first place this stops being true.

VI. Component Padding & Proportion

Inset is where spacing meets the component chapters, and the component chapters have already done much of the work. Button padding ratios and size scales are in Buttons Part I §VI–VII; the case for em-based padding that scales with a control's own font size is in Buttons Part IV §A1; input inset and the 1–1.5× inline-to-block rule are in Text Inputs Part I §V. This section takes the system's view: the shapes inset comes in, why the declared value is not what the eye sees, and how a component's inset must relate to the gaps around it.

Three Shapes of Inset

Square · 10 / 10 · 1:1
Save changes Squish · 8 / 16 · 1:2
Save changes Squish · 8 / 12 · 1:1.5
Section Stretch · 16 / 12 · Rare
Hatching is the padding. The white box is the line box of the content.

Curtis's vocabulary names the variations too. Square inset is equal on all sides: icon-only buttons, avatars in frames, and most containers — cards, panels, and dialogs almost always want square inset, because a container frames content in two dimensions. Squish inset has less vertical than horizontal padding, and it is the shape of nearly every text-bearing control: buttons, inputs, menu items, table cells, tabs. The convention across systems is a ratio of 1:1.5 to 1:2, narrower for inputs (where text should sit close to the left edge) and wider for buttons (where the label should float centered with room on both sides). Stretch inset — more vertical than horizontal — is rare and usually a sign of a touch-first list row or a section band; in a pointer-first control it reads as a component that has been accidentally made too tall.

Line-Height Eats Padding

Continue 8 / 16 · LH 1.7 · 42 tall
Continue 8 / 16 · LH 20px · 38 tall
Identical padding tokens. The dashed white box is the line box; the visible space above the letters is padding plus half-leading.

Padding is measured from the line box, not from the letters. A 14px label at the page's body line-height of 1.7 has a 24px line box, which means about 5px of invisible half-leading above and below the text before the padding even begins. Two buttons declared with the same 8px 16px inset can therefore look meaningfully different if one inherits a body line-height and the other sets its own — and the one that inherits looks over-padded and tall for reasons nobody can find in the padding value.

The fix is a convention, not a measurement: controls set their own fixed line-height (20px for 14px text is the common choice, and lands on the 4px grid), so that control height is fully determined by line-height plus twice the block inset plus borders, and that arithmetic is the same in every component. Many systems invert the derivation entirely — they specify the control's height as the token (28, 36, 44) and center the text inside it, which is what the density demo in the next section does. The newer CSS text-box properties (trimming the line box to the cap height and baseline) are beginning to make optically exact padding possible, and are now shipping in Chromium and Safari, but a design system cannot yet assume them.

Optical Adjustment

New issue 16 / 16 · Mathematically even
New issue 12 / 16 · Optically even
An icon's bounding box includes its own internal whitespace, so equal padding reads as extra space on the icon side.

The scale governs declared values; the eye judges visible ones. A leading icon's 16px box contains a glyph that is perhaps 10px wide, so equal padding on both sides of an icon-and-label button leaves the icon side looking roomier. Reducing the icon-side inset by one scale step — 16 to 12 — makes the button read as balanced. The same logic applies to round shapes (a circle in a square box needs less inset than text), to all-caps labels (no descenders, so the text sits high in its line box), and to the trailing chevron in a select trigger. These adjustments should be rules in the component, encoded once, not nudges applied by eye in each screen, and they should stay on the scale: an optical correction from 16 to 12 is a one-step decision; a correction from 16 to 13 is a magic number.

Inset and the Gap Beside It

BoldItalicLink
12px inset · 32px gap · Three strangers
BoldItalicLink
12px inset · 8px gap · 24px between groups

A component's inset sets the scale of its neighborhood. Buttons with 12px of horizontal inset, separated by 32px, look lost — the gap between them is nearly three times the air inside them, so each reads as an independent thing that happens to share a row. Close the gap to 8px (less than the inset) and the same three buttons read as a toolbar; open a 24px gap with a divider between clusters and the toolbar acquires structure. A useful working rule: the gap between related controls should be no larger than their horizontal inset, and the gap between groups of controls should be at least twice it.

Usage this month
API requests1.2M
Storage84 GB
Inset 8 · gaps 24 Content falls out of the card
Usage this month
API requests1.2M
Storage84 GB
Inset 16 · gaps 12 / 8 Inset ≥ inner gaps

The nesting rule applies to inset as well. A container's inset is an outer space relative to the gaps between its children, so it should be at least as large as the largest of them. When a card's padding is smaller than the gaps inside it, the content looks pressed against the edge and loosely scattered at the same time — it seems to belong more to the card's border than to itself.

VII. Density Posture

Everything so far has been about relationships: which gap is larger than which. Density posture is the other axis — how much space the whole system spends while keeping those relationships intact. It is a single, system-level decision, and products that never make it consciously end up making it a hundred times by accident.

Most systems settle on three postures. Compact is for data-dense tools used for hours by people who know them: spreadsheets, IDEs, issue trackers, trading screens, admin tables. Rows run 24–32px, and the user's expertise substitutes for the air a newcomer would need. Default is the general-purpose posture of most applications — 36–40px controls, comfortable with a pointer, adequate with touch. Comfortable is for reading surfaces, infrequent or high-stakes tasks, onboarding, and touch-first contexts, where 44–48px controls meet the touch-target floor and the extra space lowers the cognitive cost of every glance.

Reviewers Add
AKAisha KhanDesignApproved
JMJonas MeyerPlatformPending
RSRosa SilvaFinancePending
TNTomás NovakLegalDeclined
Add a note for reviewers… Request
Panel inset121624 Stack gap81216 Inline gap8812 Row inset · row height4 / 8 · 288 / 12 · 3612 / 16 · 44 Control height283644 UI voice121314 Border · icon · avatar · radius1 · 14 · 20 · 6 — held
One component, three postures. Only role tokens change; the scale, the relationships, and the fixed details do not.

Watch what changes as you switch, and what does not. Inset, stack, inline, row height, and control height all move — every one of them a role token resolving to a different step of the same scale. The relationships hold: in every posture, the row's inset is smaller than the panel's, and the gap between the list and the form is larger than the gap inside a row. The fixed details hold too: borders stay 1px, the avatar stays 20px, the radius stays 6px. Type moves at most one step, in compact only. A density change that alters the type scale, the icon sizes, or the border weights is not a density change; it is a different design.

One Decision, Applied Everywhere

The central claim of this section is that posture is a single decision, not a per-screen mood. Users calibrate to density quickly: after a few minutes in a product, the row height becomes the unit by which they scan, the control height becomes the size they aim for, and the gap between groups becomes the cue that something new begins. Change those per screen, and every navigation forces a small re-calibration. Users never name it, but they feel it as the product being harder to use than it should be.

Customers
All customers
NamePlanMRR
Northwind LtdScale$4,200
Halcyon LabsTeam$860
Oxbow & CoTeam$740
PinecrestStarter$90
Quill HealthScale$3,900
Edit customer
Company name Northwind Ltd Save
Mixed posture · Compact table, comfortable form Two products
Customers
All customers
NamePlanMRR
Northwind LtdScale$4,200
Halcyon LabsTeam$860
Oxbow & CoTeam$740
Edit customer
Company name Northwind Ltd Save
One posture · Both panes at default One product

The mixed-posture screen is the most recognizable symptom of a product without a spacing system, and it is worth being precise about why it reads so badly. Density is a signature. People cannot articulate it, but they perceive the amount of air in an interface as a property of who made it — so a 22px-row table beside a 46px-field form reads as two tools from two teams that happen to share a window. It almost always is: one pane was built from a data-grid library tuned for density, the other from a form kit tuned for a sign-up flow, and nobody owned the decision that would have reconciled them. The fix is not to pick the “better” pane and restyle the other to match it by eye; it is to make the posture decision once and let both panes resolve their role tokens from it.

That does not mean every surface must be identical. A system may legitimately map kinds of surface to postures — all data tables compact, all settings forms default, all long-form reading comfortable — provided the mapping is written down and applied everywhere the kind appears. That is still one decision; it just has a few clauses. What it cannot be is negotiated screen by screen.

How Real Systems Express It

SystemPosturesMechanism
GmailDefault · Comfortable · CompactA user setting. The clearest mainstream proof that the same product can carry three postures if the relationships are token-driven.
Material0 · −1 · −2 · −3A density scale applied per component; in Material Components each step down removes 4dp of height.
Carbonxs → xlExpressed as component sizes rather than a global switch; the data table offers row heights from 24px to 64px.
Primercondensed · normal · spaciousRole tokens with posture built into the name: stack-gap-condensed is 8px, -normal 16px, -spacious 24px.
SpreadsheetsCompact onlyRows near 20px. One posture, chosen for the task and never changed — the purest example of committing.
LinearDense, committedKnown for a single tight posture held consistently across views; the density is part of the product's identity rather than a setting.

User-switchable density — the Gmail model — is the subject of a later part of this chapter, along with the particular demands of data tables. For Part I the important observation is that every one of these approaches requires the same foundation: role tokens that sit between the scale and the components. A product that hard-codes pixel values in components cannot offer a density setting, cannot hold a posture across teams, and cannot fix its mixed-posture screens except by hand, one at a time.

Density is not how a screen feels. It is a decision the system makes once — and then every screen inherits it, or the product starts to look like it was made by strangers.

VIII. Implementing Posture as Tokens

The architecture that makes posture a single decision has three layers. The scale is fixed and never changes with posture. The role tokens point at steps of the scale, and they are the only thing posture changes. Components consume role tokens and never touch the scale directly. Posture is then a matter of re-pointing the middle layer — typically under a data-density attribute on the root, so the whole product moves at once.

/* Layer 1 — the scale. Multiplier names: --space-4 is 4 × 4px. Never changes. */ :root { --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-8: 32px; --space-12: 48px; --space-16: 64px; --space-24: 96px; } /* Layer 2 — role tokens, default posture. */ :root { --inset-control-y: var(--space-2); --inset-control-x: var(--space-3); --inset-container: var(--space-4); --stack-related: var(--space-3); --stack-group: var(--space-8); --inline-related: var(--space-2); --control-height: 36px; } /* Posture re-points role tokens to other steps of the same scale. */ [data-density="compact"] { --inset-control-y: var(--space-1); --inset-control-x: var(--space-2); --inset-container: var(--space-3); --stack-related: var(--space-2); --stack-group: var(--space-6); --control-height: 28px; } [data-density="comfortable"] { --inset-control-y: var(--space-3); --inset-control-x: var(--space-4); --inset-container: var(--space-6); --stack-related: var(--space-4); --stack-group: var(--space-12); --inline-related: var(--space-3); --control-height: 44px; } /* Layer 3 — components read roles, never the scale. */ .card { padding: var(--inset-container); } .fieldset { display: flex; flex-direction: column; gap: var(--stack-related); }

Two things about this structure are deliberate. Every posture resolves to steps of the scale, so a compact product is still on the grid and still obeys the nesting rule — compact moves each role down by one step, comfortable up by one, and the inequalities between roles survive. And components never change: the card does not know which posture it is in. That is what makes a user-facing density setting a one-attribute change rather than a rebuild.

The Multiplier Trap

The tempting shortcut is a single number: calc(var(--space-4) * var(--density)), with density set to 0.75 or 1.25. One knob, every space in the product scales. It fails in two ways. First, multiplication leaves the scale — 12 × 0.75 is 9, 24 × 1.25 is 30 — so the product drifts off its own grid, and the steps that were chosen to be perceptibly different now differ by a pixel or two. Second, and worse, a multiplier applied broadly scales things that should never scale.

Quarterly reportDraft
Default · 36 tall
Quarterly reportDraft
Everything × 0.75 · 0.75px border, 10.5px text, 12px icon Shrunk, not compact
Quarterly reportDraft
Compact role tokens · 28 tall · details held Compact
The multiplied row is a smaller screenshot of the default. The compact row is the same component with less air.
PropertyWith postureWhy
Inset · stack · inlineChangesThis is what density is.
Control & row heightChangesDerived from inset and line-height; usually the most visible effect.
Section spacingChanges lessOften one step at most — page structure should not collapse because rows got tighter.
Type sizeOne step per postureLegibility is not a density preference. The UI voice is 12 / 13 / 14 for compact / default / comfortable (Typography Part I §III); reading text holds at 16.
Icon sizeHoldsIcons are drawn on a pixel grid; scaled icons blur and lose stroke weight.
Border widthHoldsSub-pixel borders render inconsistently across screens; 1px is 1px.
RadiusHoldsRadius encodes the product's character, not its density (Border & Radius chapter).
Focus ringHoldsVisibility is an accessibility requirement, not a style.
Touch-target floorHoldsOn touch devices, compact may not go below the minimum target (section X).

One implementation caution. Because data-density can be set on any element, it is technically possible to set it on a single table or panel. That is the correct mechanism for a documented surface mapping (“data tables are always compact”) and for a later user preference. It is also exactly how mixed-posture screens get built, one well-intentioned attribute at a time. Treat any data-density below the root as a design-system decision that needs a written reason, not a component prop anyone can flip.

IX. Vertical Rhythm & Section Spacing

At page scale, the stack role governs the largest gaps a product has: between page sections, above and below headings, between paragraphs. These are the levels 3 and 4 of the nesting table, and they carry the page's structure the same way smaller gaps carry a form's.

Billing contacts
Equal above and below · Heading floats
Billing contacts
40 above · 12 below · Heading leads

The rule for headings is the nesting rule applied to one element: a heading belongs to what follows it, so the space above it must be clearly larger than the space below — typically two to three times. With equal space, the heading floats between two blocks and the eye cannot tell which one it names; on a long page, a reader scrolling into the middle of that gap genuinely cannot tell whether the heading closes one section or opens the next. The same principle covers every captioning relationship: a label is closer to its field than to the field above, a table's title is closer to the table than to whatever precedes it, a hint is closer to its field than to the next label.

In implementation, this is where the stack role meets one exception. A container that spaces its children with gap applies one value between every pair, but a heading needs more space above than the gap provides. The usual answer is to let the stack's gap set the default and give headings an additional top margin that applies only when they follow something — a rule like .stack > * + h2 — so that a heading at the top of a container does not push away from the container's edge. It is the one place where an element carrying its own outer space is defensible, because the space is about the heading's meaning (it starts something), not about its neighbors.

Vertical rhythm in the stricter typographic sense — aligning every baseline to a shared grid — belongs to the Typography chapter. For spacing purposes, the useful discipline is weaker and much easier to keep: page-level gaps come from the top of the scale (48, 64, 96), section spacing is the largest stack value on the page and is used for nothing else, and paragraph spacing is a single value that never varies within a body of text.

X. Mobile as a Reducing Layer

This series designs for desktop first and treats mobile as a set of reductions. For spacing, the reduction is selective: some space shrinks with the canvas, some must hold firm, and touch imposes a floor that partly reverses the intuition that a smaller screen means a denser interface.

Plan
UpgradeCompare
Desktop values · 32 margins · 64 section Column starved
Plan
UpgradeCompare
Everything shrunk · 28 targets · 3 gap Mis-taps
Plan
UpgradeCompare
Reduced · 16 margins · 40 section · 44 targets Layout shrinks, targets hold
Hatched bands are page margins. The correct reduction spends less on the frame and nothing less on the things a thumb must hit.

What shrinks is layout space — the space that frames content rather than separating interactive things. Page margins drop from 32–48px to 16px; section gaps drop a step or two (96 to 48, 64 to 40); container inset for cards and panels drops from 24 to 16; gutters narrow (the Grid & Layout chapter sets those per breakpoint). On a 375px screen, every 16px of side margin is more than four percent of the usable width, and desktop margins leave a column too narrow for its own content.

What holds is everything a finger has to hit. Interactive targets keep their minimum size — 44×44pt in Apple's HIG, 48×48dp in Material, and a hard floor of 24×24 CSS pixels (or equivalent spacing) in WCAG 2.2's target-size criterion. The inset inside tappable elements holds, because it is what makes the target big. The inline and stack gaps between adjacent targets hold at 8px or more, because a 3px gap between two 28px buttons is an invitation to tap the wrong one. And label-to-field and other level-1 gaps hold, because they were already as small as a relationship can be.

The consequence is counterintuitive and worth stating plainly: touch imposes a density floor. A compact posture that is perfectly usable with a mouse — 28px rows, 24px icon buttons — is not available on a phone, so mobile layouts are usually tighter in their framing and looser in their controls than the desktop compact view of the same product. The nesting rule survives the reduction because the reduction is applied by level: when section gaps drop to 40, group gaps must drop below 40 with them, and if a reduced section gap ever lands at or below the group gap inside it, the page's structure inverts on exactly the screen with the least room to recover.

SpaceDesktopMobileRule
Page margin32–4816Shrinks — it frames, it does not separate.
Section gap64–9640–48Shrinks — but stays the largest gap on the page.
Container inset2416Shrinks one step; never below the gaps inside.
Group gap3224Shrinks with sections, staying below them.
Control inset & height36–4044+Holds or grows — the touch floor.
Gap between targets88+Holds — prevents mis-taps.
Label → field4–84–8Holds — already minimal.

XI. The Decision Sequence

A team repairing an inconsistent product — or starting a system from nothing — makes these decisions in order, because each constrains the next. The first four are structural and should be settled before anyone touches a component.

1. Base unit. 4px. State it plainly, allow 1px and 2px only for borders and optical detail, and stop debating 8 versus 4: the 8-point systems use 4 anyway.

2. Scale. Eight to twelve steps, linear to 16 and widening above it — 4, 8, 12, 16, 24, 32, 48, 64, 96 is a sound default. Named numerically. Anything not on the scale is a defect, and a linter can find it.

3. Roles. Inset, stack, inline, as role tokens that point at the scale. Components own their inset and nothing else; parents own every gap between their children.

4. Levels. Write the nesting rule down as a table of levels with a scale step assigned to each, at least one step apart. This is the rule reviews will cite.

5. Posture. Choose one — compact, default, or comfortable — for the product, or write a short mapping from surface kind to posture. Express it entirely as role-token values.

6. Mobile reductions. Decide which roles shrink at small widths and which hold, with the touch floor as a constraint no posture may cross.

Steps one through four are the spacing system. Steps five and six are how much of it you spend. Products that skip to five — “let's make it denser” — end up with a denser version of the same disorder.

What the Best Systems Avoid

Magic numbers. 13px, 15px, 22px, 30px. Each is a local fix that will never be found again by the next person, and each makes the next one easier to justify. Off-scale values should fail review, and ideally fail lint — stylelint can enforce that spacing properties use tokens.

Components with outer margins. The single largest source of inverted gaps. A component that pushes its neighbors away has made a layout decision it is not in a position to make.

Uniform spacing mistaken for consistency. “Sixteen everywhere” is consistent and meaningless. Consistency is the same relationship getting the same value, not every relationship getting the same value.

Density by screen. A compact table here, an airy form there, each tuned by whoever built it. Posture is a system decision or it is not a posture.

Density by multiplier. One knob that scales borders, icons, and type along with space produces a smaller product, not a denser one, and pushes every value off the grid.

Borders as a substitute for spacing. When gaps carry no meaning, enclosure takes over, and the product fills with boxes. Fix the gaps and many of the boxes can go.

A later part of this chapter takes density into the places it is hardest to get right: data tables, dense dashboards, and user-switchable density settings. Its foundation is everything above — a scale, a set of roles, and one inequality held at every level.

Part I of Spacing & Density. The scale meets the column grid in Grid & Layout.
Space is the only grouping device that costs no ink. Spend less inside than between, and spend it the same way everywhere.