Spacing: Build One Shared Scale So Related Things Group Together
Learn how a small set of gap, padding, and margin values keeps screens ordered and shows which items belong together.
In short
Spacing is one shared scale of gap, padding and margin values built from a base unit, which keeps screens ordered and shows which items belong together.
12 min readFree
What You Will Learn
Spacing is the set of empty areas that sit between screen parts and inside them. Those empty areas are gaps, padding, and margins. In a design system, teams do not pick these values by eye each time. They agree on a small set of values and reuse them on every screen. This lesson shows you how to build that set, how to use it to show which items belong together, and how to name each step so designers and builders pick the same values.
Key words
- Spacing
- The empty room between and inside interface parts. A design system fixes which values of this room are allowed.
- Gap
- The empty room between two items that sit side by side or one above the other.
- Padding
- The empty room inside a box, between the box edge and the content in it.
- Margin
- The empty room outside a box, between that box and the next thing.
- Pixel (px)
- One tiny dot on a screen. Most design tools measure gaps in pixels. The Units lesson covers other measures.
- Base unit
- The smallest number that the rest of a spacing scale is built from, such as 8 pixels.
- Scale
- A short, ordered list of allowed values, such as 8, 16, 24, and 32 pixels.
- Proximity
- The idea that items placed close together look like one group, and items placed far apart look separate.
- Gestalt
- A school of psychology that studies how people group what they see. Proximity is one of its rules.
- Half-step
- A value between two main steps, such as 4 pixels, used for small fine tuning.
Why Does Spacing Need a Scale?
Imagine two cards on one page. One card has 13 pixels of inner room. The other has 15. Each card looks fine alone. Side by side, the difference feels slightly wrong, even when the reader cannot say why. Small random values make a layout feel untidy. A scale stops this, because every gap comes from the same short list.
Hidden disorder
Many near-identical numbers, such as 14, 17, and 15, make a page feel off even when each piece looks fine on its own.
Slow choices
Without a list, each designer must decide every gap from nothing. Answers drift apart, and the team argues over tiny differences.
Easy reuse
A short list means a builder can use the exact value the designer picked, so the two sides match without extra talk.
The fix is a rule, not a better eye. Teams call this kind of rule a scale. It says which values are allowed, and everyone works inside it.
Why Do Random Numbers Look Wrong?
The layout feels subtly off, even when users cannot say why. The fix is to limit every spacing choice to values from one list, such as multiples of 8.
How Do You Build the Scale From One Base Unit?
You do not need to invent a scale from scratch. You start with one base unit and build the steps from it. Here is the usual method.
- 1
Pick one base unit
Choose one number. Most teams choose 8 pixels. Teams with dense screens may choose 4 pixels. Pick one, and do not switch later.
- 2
Multiply to make the main steps
Multiply the base by 1, 2, 3, 4, and so on. With 8 pixels you get 8, 16, 24, 32, 40, 48, and 64.
- 3
Add a half-step only where you need it
Some small parts need less than 8 pixels. Add a 4-pixel half-step for those cases, and keep it rare.
- 4
Write the full list
Write the allowed values in one place. Give each one a name, such as small, medium, or large. The naming section below shows how.
- 5
Write one use for each step
Say where each step belongs. For example, the smallest step is for items that belong together, and the largest is for separate sections.
- 6
Stop using off-list values
If a value seems to be missing, first check the list. If the list really needs a new step, change it in one place for the whole team.
The formula below says the same thing as the steps. Each gap equals a step number times 8 pixels.
In words: take the step number, multiply it by 8, and you get the gap in pixels. So step 2 is 16 pixels, and step 4 is 32 pixels.
Why Do Teams Often Pick 8?
The number 8 divides evenly by 2 and by 4, so you can still make halves and quarters when you need them.
Add a 4px Half-Step for Fine Control
Use the 8-point steps between components and for component size. Material Design says iconography in toolbars aligns to a 4dp grid, and that all components align to an 8dp baseline grid. Keep the half-step for the small inner parts so the main rhythm stays clear.
How Do Gaps Show What Belongs Together?
Spacing does more than make a screen tidy. It shows structure. Designers rely on proximity to show that items are related, without extra lines, boxes, or colors. Designary states the rule plainly: related objects get smaller spacing, and unrelated objects or separate sections get bigger spacing.
Tight: same item
Use the smallest step for things that form one unit, such as a label and its field, or an icon and its text.
Medium: same section
Use a middle step, such as 16 pixels, for items in one group. Fields in one address block fit here, and they still feel like parts of a whole.
Large: separate sections
Use a big step, such as 32 pixels or more, between blocks that are unrelated.
The Proximity Idea
Proximity comes from the Gestalt study of how people group what they see. Gapsy gives the same rule for interfaces: proximity says items are a group because they are close. When your gaps follow this rule, the reader sees the groups before reading a single word.
Why Do Equal Gaps Hide Structure?
If every gap is the same size, the eye cannot tell which items form a group. Clear structure comes from contrast, meaning tight gaps inside groups and looser gaps between them.
Tip
Cover the labels on a screen with your hand. If you can still see the groups from the gaps alone, your spacing is doing its job. If not, widen the gaps between groups or tighten the gaps inside them.
Keep Inner and Outer Space Distinct
Padding and margin are easy to mix up. ConceptFusion draws the line clearly: padding is the space inside a component, and margin is the space outside it that separates it from others. A gap is the room between sibling items, such as two cards in a row. Keeping these three apart makes your spacing predictable.
Padding (inside)
Space between a box's edge and the content inside it. It stops text from touching the border of a card or button.
Margin (outside)
Space around a box that pushes it away from its neighbors. It keeps one component from crowding the next.
Gap (between siblings)
Space between items that sit in the same row or column, such as a list of cards or a set of form fields.
Outside Space Should Be Larger
The most useful practical rule is that outside space should be larger than inside space. ConceptFusion says external spacing should be equal to or greater than internal spacing, otherwise the cards visually merge and their grouping becomes confusing. The same logic applies to headings: a heading should have less space below it than above it, so it stays with the text it introduces.
Tip
Check your card in pairs. Measure the inside padding first, then the gap between two cards. If the gap is not larger, the cards will blur together on a busy screen.
Why Name the Steps and Reuse Them?
A number like 16 is easy to forget and easy to mistype. A name like medium is easier to say in a review, and it tells the reader what the step is for. Name each step by its job, then use the same name in design files and in the product code the builders write. This keeps both sides using the same values.
Tight (4 px)
For items that are almost one unit, such as an icon and its label, or a label and its input.
Small (8 px)
For related items in one group, such as a short row of options or the parts of one small alert.
Medium (16 px)
For fields inside one section, and the usual padding inside a card or list item.
Large (24 to 32 px)
For separate groups on one page, such as Shipping and Payment blocks in a checkout.
Extra large (48 px or more)
For big gaps between major blocks, such as the space around a hero area or the edges of a page.
Tip
Keep the list short. Naming conventions for these values are covered in the Defining Design Tokens lesson.
Worked Example: A Checkout Screen
Here is a checkout screen of the kind found in many online shops. It has two sections, Shipping and Payment. Each section has a heading and a few labeled fields. The team wants the grouping to be clear without any divider lines. They use one scale with an 8-pixel base and a 4-pixel half-step.
- 1
Set the label gap
Each label sits 4 pixels above its input. The label belongs to its own field, so the tightest step is correct here. Users read the label and the field as one unit.
- 2
Set the field gap
The fields inside a section are 16 pixels apart. That is the medium step. The fields feel related, but each one still has room to be read and tapped.
- 3
Set the section gap
The Shipping section and the Payment section are 32 pixels apart. That is the large step. The bigger gap tells the eye that these are two separate blocks, so no divider line is needed.
- 4
Check the contrast
The label gap is smaller than the field gap, and the field gap is smaller than the section gap. Each step is bigger than the one before it, so the three levels of grouping are easy to read.
- 5
Run the squint test
Step back from the screen and look only at the shape of the spacing. If the two sections blur into one block, the section gap is too small. If a label seems closer to the field above than its own, the label gap is too large.
The result is a clean page with three clear levels of grouping and no lines at all. Every gap comes from the same short list, so a builder can copy the values exactly and the page keeps its rhythm.
Common Mistakes to Avoid
Mixing arbitrary numbers
Using 14 in one place and 17 in another breaks the rhythm. Pick every value from the scale, even when a near value looks fine.
Equal gaps everywhere
Using one gap for every relationship hides the structure. Use tight gaps inside groups and larger gaps between them.
Outer space smaller than inner
When the space between cards is smaller than the padding inside them, the cards merge. Keep outer space at least as large as inner space.
Labels floating in the middle
A label placed halfway between two fields is equally close to both, so the user cannot tell which field it names. Keep each label closer to its own field.
Check Your Understanding
Try these two short scenarios. Each one needs the ideas from this lesson to answer.
Quick check
Your app's card has 13 pixels of padding. Its title sits 22 pixels above the body text, and its button is 9 pixels below the text. A teammate's card uses 15, 20, and 10 pixels. Which approach should change, and what should replace the values so both cards match?
Quick check
A sign-up form has each label 16 pixels above its own field. The gap between one field and the next is also 16 pixels. Users keep typing their last name into the wrong box. What is the best fix?
Key Takeaways
Spacing works best as a system. Pick one base unit, build a short scale of steps, and name each step by its job. Use tight gaps to join related items, and larger gaps to separate sections. Keep padding inside a box and margin outside it, and make the outside space larger than the inside. When every screen draws its gaps from the same list, the layout feels ordered, and the grouping works without extra lines.
Sources
- Material Design: Spacing methods
- Material Design: Understanding layout
- Material Design: Metrics and keylines
- Designary: Basics of spacing systems and scales in UI design
- Gapsy: Proximity design principle guide
- ConceptFusion: Web design spacing and sizing best practices
- Glow: Proximity principle of design guide
- ScienceInsights: The principle of proximity
- Breakdance: The 8-point grid system, a practical guide
- Timgraf: Mastering the 8-point grid for spacing systems
- Better Design: Spacing and layout principles
- MUI v4 documentation: Grid spacing
- Rejuvenate: The 8pt grid system for consistent UI spacing
- ioDroplet: Sizing, spacing and grids guide for UI/UX
Last updated on 17 November 2026
Related lessons
- Machine Learning FoundationsOverlapping clustering: shared groups
- Machine Learning FoundationsHierarchical clustering: groups in groups
- Design systemsCreating Design Language: Turn Shared Look, Feel, and Behavior Into Clear Choices
- Design systemsGrid: The Shared Column Structure Behind Every Aligned Screen
Learn with me
Every lesson is free. I add new ones as I learn. Have a question, or want help with your own work? Book a short call.