UI/UX Design and Figma for Beginners / Chapter 1 — Train your eye for UI (lessons 1–4) / Lesson 1

Spacing and proximity (group what's related)

Time needed: about 6 min (estimate)

☆ Read later

You can try the opening of this lesson without an account.

Inconsistent spacing clutters your UI

If your spacing is all over the place — 7px, 13px, 22px — your UI looks cluttered.

Just aligning everything to multiples of 4px (or 8px) makes it surprisingly tidy.

Decide on a spacing scale first — 4, 8, 12, 16, 24, 32, and so on — and always pick your spacing values from it.

Spacing scale (space in lib/tokens.json)

"space": { "1": "4px", "2": "8px", "3": "12px", "4": "16px", "5": "24px", "6": "32px" }

This is part of the settings shared across all the samples in this course.

Setting it up so you can pick a spacing value by number — 1 for 4px, 4 for 16px — means you never have to wonder "how many pixels should this be?"

We'll cover this kind of settings file in detail in Lesson 13, on design tokens.

Proximity: put closely related things close together

Proximity is the principle that the more closely related two elements are, the closer together they should be — and the less related, the farther apart.

Keep a label close to its value, and put separate items further apart from each other.

People perceive nearby things as belonging together, so spacing alone can communicate grouping without adding a single line or border.

Lesson 01 — Spacing & Proximity: index.html (excerpt)

<div class="stack"> <!-- items: gap 16px (separate) --> <div class="group"> <!-- label and value: gap 4px (bring closer) --> <span class="label">Name</span><strong>Taro Yamada</strong> </div> <div class="group"> <span class="label">Email</span><strong>taro@example.com</strong> </div> </div>

.stack, which lines up the items, uses gap: 16px; .group, which pairs a label with its value, uses gap: 4px.

Both values come from the scale, and the difference in spacing size represents the difference in how closely related things are.

See the spacing in a live preview

This runs the sample HTML and CSS as-is.

The numbers shown below are the spacing measured from the rendered elements' positions (getBoundingClientRect).

Try changing the gap on .stack or .group and see how the grouping changes.

editor.html

Tab indents. To leave the editor, press Esc, then Tab.

Create a free account to keep reading

With an account you can read the rest of this lesson, take the quiz, and read every free lesson in this course. Lessons you answer correctly are recorded as complete.

Report a problem with this lesson

Log in to send a report.

Keyboard shortcuts

Keys available in a lesson
KeyAction
[ or Alt + ←Go to the previous lesson
] or Alt + →Go to the next lesson
?Open this list
EscClose this list

The keys do not work while the cursor is in a code editor or an input field.