Spacing
One 8px base unit, and a short scale for the space between things.
Terra's spacing is built on a base unit of 8px. A limited set of sizes keeps layouts consistent and removes the guesswork about how far apart things should be.
Tokens
Tokens are named by their size as a percentage of the 8px base unit. space/100 is 100% of 8px, so it's 8px. space/200 is 200%, so it's 16px.
Token | Pixels | REM | Base unit |
|---|---|---|---|
space/0 | 0px | 0rem | 0× |
space/25 | 2px | 0.125rem | 0.25× |
space/50 | 4px | 0.25rem | 0.5× |
space/75 | 6px | 0.375rem | 0.75× |
space/100 | 8px | 0.5rem | 1× |
space/150 | 12px | 0.75rem | 1.5× |
space/200 | 16px | 1rem | 2× |
space/250 | 20px | 1.25rem | 2.5× |
space/300 | 24px | 1.5rem | 3× |
space/400 | 32px | 2rem | 4× |
space/500 | 40px | 2.5rem | 5× |
space/600 | 48px | 3rem | 6× |
space/800 | 64px | 4rem | 8× |
space/1000 | 80px | 5rem | 10× |

Choosing a size
The scale falls into three ranges. Smaller space groups things together, and larger space separates them.
Small: 0px to 8px
For compact, closely related things.
Gap between an icon and its text
Padding inside badges and small controls
Space between a title and its description
Gap between a button and the menu it opens

Medium: 12px to 24px
For larger components and breathing room inside them.
Padding inside cards and buttons
Space between an avatar and its content
Space between form fields

Large: 32px to 80px
For the layout itself.
Space between sections of a page
Space between the top of a page and its header

Layout guidelines
Related things sit close together. Distance tells people what belongs together.
Similar things get similar spacing. A list of items should have the same gap between each one.
Use space to show importance. Give important elements more room, and don't give everything the same weight.
Adjust by eye when needed. If something looks off, move it one step on the scale instead of using a custom number.
Accessibility
Keep tap targets easy to hit. On mobile, aim for 44px for anything tappable, with at least space/100 (8px) between neighboring targets.
Spacing is given in rem, so layouts can scale if someone changes their browser's text size.
