Four kinds of space: padding, inner gap, outer gap and the layout's own gap. They come off one scale and they belong to two different owners, and almost every spacing argument is really an argument about which owner is responsible.
Rui is applying the spacing scale across a courier's driver app in Porto. It has three products sharing a kit: the driver's phone app, the depot's tablet screen and a customer tracking page.
The rule that makes a component reusable
A component owns its padding and its inner gaps and no outer margin. Inside itself it is in charge: 16 of padding, 8 between the icon and the label, 12 between the two lines of an address.
One kit, three products
Four kinds of space, two owners, and one cell that has to stay empty
Every override in a codebase starts in the top right cell, where a component decided something about the space around itself.
the component sets it
- 16, 8, 12
- the component's own
- nothing belongs here
- and it is where overrides start
the layout sets it
- 8 or 16
- set by whoever supplied the children
- 24, 16
- the layout's own
Three cells hold values and one holds a rule. The empty cell is the whole of what makes a component reusable, and it is the only one of the four that cannot be seen in a screenshot.
Modular Type Scale & CSS Flex/Grid Motion Lab
Test harmonic typography ratios and live Flexbox/Grid layouts with 1-click CSS export.
Outside itself it owns nothing, because the parent's gap provides the space around a component. A stack with a gap of 24 spaces its children; a grid with a gap of 16 spaces its cells; neither needs the child to bring anything.
The reason is concrete rather than theoretical: a component with a bottom margin cannot be put in a row. It carries a vertical assumption into a horizontal arrangement, the margin does the wrong thing, and somebody writes an override, and the override is the first value off the scale.
One scale, two densities
A compact mode is the same scale times 0.75, not a second set of values. Four becomes 3, eight becomes 6, sixteen becomes 12, and the whole depot screen fits a third more rows without anybody choosing a single number.
Building compact as its own list of hand picked values is the failure that follows a year later, when the main scale changes and the compact one does not, and the two drift apart in a way nobody can see in either product alone.
Two adjustments that are not exceptions
Space above a heading is twice the space below it: 24 and 12. That is not a spacing preference, it is what makes a heading belong to what follows it rather than floating between two blocks.
Not exceptions
Heading pairing uses scale steps, while optical misalignment is fixed in the icon asset
Neither case gives permission to invent a rogue pixel value in layout code.
Two spacing adjustments that keep the scale intact
- Heading rhythm: 24 above, 12 belowTwice as much space above ties the heading to the block it introduces
- Uses two existing steps from the scale
- Prevents headings from floating equidistantly between blocks
- Optical icon gap: keep 8, trim the fileTransparent padding inside an icon box can make 8 look like 10
- Trim the transparent air inside the icon asset
- Never hide an unexplained 6 in layout styles
Putting a workaround 6 into CSS solves an asset defect in the wrong place and creates a number nobody can justify later.
Then the optical case, which looks like a reason to leave the scale and is not. An icon beside a label at a gap of 8 often looks like 10, because the icon file carries transparent air inside its own box. Trim the icon rather than changing the gap: the fault is in the asset, and fixing it in the layout puts a 6 into the codebase that nobody will ever be able to explain.
The audit is one command
Count the distinct spacing values in the built stylesheet. Not in the design file, not in the token file: in what shipped, which is the only place the answer is true.
What actually shipped
Counting distinct spacing values in the compiled stylesheet
Design files and token definitions say what was planned; the built CSS says what reached users.
- 46Distinct values beforeaccumulated across three products, four contributors and two years
- 8Distinct values afterthe seven-step scale plus zero
- 16Must match across all threeidentical distance on phone, depot tablet and tracking page
If the same 16 produces different distances across products, the kit is three separate kits sharing a palette.
On this kit it was 46 distinct values before and 8 after, which is the scale plus zero. The 46 were not carelessness, they were three products, four contributors and two years, each addition made by somebody solving a real problem in front of them.
And the number matters across products, not only within one: the same 16 has to mean the same distance in three products, or the kit is three kits with a shared colour palette.
What to open
A regular expression over the built CSS is the audit, free, and one command prints every distinct pixel value in the file. It replaces trusting that the scale was applied because it was agreed, which is what everybody does, and the gap between agreed and applied is where the 46 came from.
From intention to proof
Closing the gap between the agreed scale and the compiled CSS
A scale documented only in a design tool has no enforcement once components are built.
- 01CSS custom propertiesTurns each step into a named token that can be searched and changed in one place
- 02Regex over built CSSPrints every distinct pixel value in the shipped bundle with one command
- 03Zero ambiguitySeparates intentional scale tokens from raw undocumented numbers
The gap between what a team agreed and what it applied is where all 46 stray values came from.
CSS custom properties are how the scale exists in the code, part of the language and free. A gap written as a named value can be searched for, changed in one place and audited; a gap written as a number cannot be told apart from any other number, which is why a scale expressed only in a design file has no enforcement at all.
Where it stalls: a scale dies by addition
Nobody removes a scale. It dies by addition, one reasonable request at a time: this card needs 20, this row needs 14, this modal needs 36 because 32 is tight and 48 is loose.
Why scales erode
Three checks that stop a spacing scale from dying by addition
Nobody deletes a scale; it disappears one reasonable one-off request at a time.
- Two-screen proof+Single-card requests for 20, 14 or 36→Needs confirmed on at least two separate screens
- Neighbour test+Adding 36 just because 32 feels tight and 48 feels loose→Genuine gaps where neither existing neighbour works
- Kit-wide adoption+Private values added for one layout→New steps added for everybody across the kit
Without a rule on who may add a step, seven steps quietly grow to eight, eleven and fourteen until the scale is only a log of habits.
Each request is made by somebody looking at a real screen with a real problem, and each is right about the screen. Granting it costs nothing visible and takes the scale from seven steps to eight, then eleven, then fourteen, at which point it is a list of the values in use rather than a constraint on them.
The defence is a rule about who may add a step and what has to be shown: a new value arrives only when two separate screens need it and neither existing neighbour works, and it arrives for everybody rather than for one card. Most requests do not survive that, and the ones that do are genuine gaps in the scale.
What it looks like when it goes wrong
The depot screen's compact mode was built as its own set of values, chosen by eye in an afternoon and shipped. Eighteen months later the main scale gained a step and lost another, the compact list was not touched, and a row measured 44 px on the phone and 41 px on the depot tablet. Nobody could see it, because nobody ever holds the two devices side by side, and it surfaced when a driver's list and a depot list were printed on the same sheet for an audit and did not line up.
Two devices, one printout
How an unlinked compact list drifted apart over eighteen months
Nobody noticed the mismatch while the phone and tablet stayed in separate rooms.
- Day oneCompact list chosen by eyeBuilt as its own set of pixel values in an afternoon and shipped
- Eighteen monthsMain scale evolves aloneThe main scale gains a step and drops another while compact stays untouched
- Audit printout44 px phone row vs 41 px tablet rowDriver list and depot list fail to line up when printed on the same sheet
Visual drift between two products rarely appears in single-screen reviews and surfaces only when outputs are laid side by side.
Where these four kinds of space sit on a screen that resizes is structure on a screen that resizes. A scale that exists as named values in three products is a token problem before it is a spacing one, which is values named once and used everywhere. And the reason the outer gap must beat the inner one is the arithmetic in proximity, and the relationships it implies. What else the surface is made of is one level up, in making an interface look considered.