UI/UX Design · Tutorial 7 of 8
Layout and Spacing in UI Design
By the FUTEAC Team · 26 November 2026 · 15 min read · Beginner
In short
Layout is where things sit on a screen, and spacing is how much room sits between them. Use one spacing scale, steps like 8, 16 and 24 pixels, everywhere: between sections, inside cards, around text. Line things up on shared edges, group related things close together, and leave enough empty space for the eye to rest.
- One spacing scale, used everywhere. Pick steps of 8 (8, 16, 24, 32) and stop inventing new gaps. If a gap is not on the scale, the layout is wrong, not the scale.
- Alignment is a decision, not an accident. Elements that share an edge look related. Elements that almost share an edge look like a mistake.
- Near means together. Things placed close together read as one group. Things placed far apart read as separate groups, even if they have nothing else in common.
- Whitespace is working, not wasted. Empty space separates groups, points at what matters, and keeps a screen readable. A packed screen is not a rich screen.
- This tutorial feeds the UI Design Fundamentals course (/course/ui-design-fundamentals) and the Layout & Spacing skill (/skill/layout-spacing).
Before you start
What layout and spacing actually do
Open a food delivery app and look at one dish card. The photo sits at the top. The dish name sits below it, then a line of description, then the price, then a button. Nothing overlaps. Nothing floats in the middle of nowhere. Your eye moves down the card in order, without thinking about it. That is layout doing its job, and you only notice it when it is missing.
Now picture the same card with the price jammed against the description, the button touching the card edge, and the second card starting two pixels after the first one ends. Same words, same colours, same button, but it feels cheap and hard to read. The gaps between things carry as much meaning as the things themselves.
Layout and spacing are two halves of one job. Layout decides where things sit: in a column, in a row, in a grid. Spacing decides how much room sits between them: inside a card, between cards, between a heading and the text under it. Get both right and a screen feels calm. Get either wrong and the screen feels off, even when every element on its own looks fine.
Think of a dining table. Plates, glasses and cutlery all have a place, and the gaps between them are part of the setting. Push everything into the middle and the table looks like a pile. Spread everything to the edges and it looks like nobody is eating together. A good layout is a well-set table: everything has a place, and the spaces between things are deliberate.
The 8-point scale: one ruler for the whole screen
Beginners space things by eye. A gap looks about right, so it goes in. The next gap looks about right too, but it is 14 pixels while the first was 11. The third is 19. Nothing matches, and the screen feels uneven in a way nobody can name. The fix is to stop choosing gaps one at a time and use a scale instead.
The scale this tutorial uses is the 8-point scale: 8, 16, 24, 32, 40, 48. Every gap on the screen is one of those numbers. Small gaps inside a component, 8. Gaps between elements in a card, 8 or 16. Gaps between cards or sections, 16 or 24. Space around the whole screen, 16. That is the whole scale for a phone screen, and it is enough.
Why 8? It divides cleanly, and it is small enough for tight gaps and big enough to step up in visible jumps. A 4-point scale works too, but 8 keeps the choices fewer, and fewer choices mean fewer chances to drift. The FUTEAC site's own design tokens use 8, 16 and 24, and the Design Systems (/tutorials/ui-ux/design-systems) tutorial (item 72) builds its token set from those three steps.
The rule is simple: if a gap is not on the scale, change the layout, not the scale. A gap of 12 between a heading and a paragraph usually means the heading is too big or the paragraph starts too early. A gap of 20 between two cards usually means one card has extra padding hiding inside it. The scale is a diagnostic tool too: a gap that will not fit it is telling you something else is wrong.
Alignment: line things up on purpose
Alignment is the cheapest way to make a screen look organised. Pick an edge and line things up on it. The left edges of the heading, the cards and the buttons in this tutorial's worked example all sit on the same line, 16 pixels from the screen edge. That one shared edge holds the whole screen together.
The mistake is almost aligning. Two cards whose left edges are 3 pixels apart look worse than two cards whose edges are 30 pixels apart, because 3 pixels reads as an error and 30 reads as a choice. Figma's red guide lines exist for this: when you drag an element, the guides snap to the edges of its neighbours. Use them. If two things are meant to line up, make them line up exactly. If they are meant to be different, make the difference obvious.
Alignment also works vertically. In a row of three small items, an icon, a label and a price, centre them on the same line and the row reads as one thing. Let one item sit 4 pixels higher and the row reads as three things that happen to be near each other.
One opinion worth stating plainly: left alignment beats centred alignment for almost everything that is not a single short line. Left-aligned text has a straight edge the eye can follow down the page, while centred text has a ragged edge on both sides. Centre a heading over a card if you like, but keep the body text left-aligned.
Grouping: near means together
Proximity is the oldest rule in layout: things close together are read as a group, and things far apart are read as separate groups. You already use it without thinking. On a shop screen, a dish name sits 8 pixels below its photo and 16 pixels above the next card, so your eye groups the name with its own photo, not with the card below. Swap those two gaps and the name suddenly belongs to the wrong card.
The practical version of the rule is a ratio, not a number. The gap inside a group should be about half the gap between groups. In this tutorial's worked example, the gaps inside a card are 8 pixels and the gap between cards is 16. That 1 to 2 ratio is what makes the card read as one unit. If the inside gap and the between gap were both 16, the cards would dissolve into one long list. If both were 8, the screen would read as one dense block.
Grouping also applies to forms, where beginners feel it most. A label sits 4 or 8 pixels above its own input, and the next label sits 16 or 24 below. A form with even spacing throughout feels confusing, because every label is equally close to the input above it and the input below it.
Whitespace is not empty space
Whitespace is the space with nothing in it, and beginners treat it as wasted space. It is not: it does the separating, the pointing and the resting. A screen with no whitespace is a wall of text. A screen with generous whitespace tells you what matters, because the thing with space around it is the thing you look at first.
The test is simple: take a finished screen and add 8 pixels of space between every section. If it looks better, the screen was too tight. Most first screens look better with more space, because beginners pack things in, worried the screen will look empty. It will not: an empty-looking screen with clear groups beats a full-looking screen with none.
Whitespace has one more job: it is what makes a button tappable and a card readable on a phone. Fingers are wider than mouse pointers, and a button needs space around it so the finger lands on the button and not on the thing next to it. The 16-pixel gaps in this tutorial's example are not decoration. They are the space a thumb needs.
Worked example: a shop screen, laid out in Figma
The worked example is a dish list for a practice shop, "Amna's Corner Shop", the same shop used in the Design Systems (/tutorials/ui-ux/design-systems) tutorial. One screen, 360 pixels wide, with a header and two dish cards. The whole screen uses only three spacing values: 8, 16 and 24.
Build it in Figma like this:
- Create a frame 360 pixels wide and 640 tall. Name it
Shop - dish list. Set the fill to warm paper,#fbf7ed, the same page colour the FUTEAC site uses. - Turn on a layout grid: in the right panel, under Layout grid, add a columns grid with a 16-pixel margin and an 8-pixel gutter. The grid is the ruler you will align everything to.
- Add the header. Type the shop name, "Amna's Corner Shop", at 20 pixels bold in ink
#0c2b29. Place it 16 pixels from the top and 16 from the left edge. Add a small basket button on the same row, at the right edge. Select both, and check the right panel: their tops should share one line. - Add the first card: a rectangle 328 pixels wide (360 minus 16 on each side), 12-pixel corner radius, white fill. Set auto layout padding to 16 on all sides and internal spacing to 8. Inside it, in order: a photo block 120 pixels tall, the dish name at 18 pixels, one line of description, the price in amber
#d97706at 18 pixels bold, and a full-width button. - Duplicate the card for the second dish. Select both cards and set the gap between them to 16. That gap is the same 16 as the screen padding, which is what makes the whole screen feel even.
The same screen was built in code and rendered in headless Chromium 141, and the browser reported these real measurements: the screen is 360 pixels wide with 16 pixels of padding, so each card measures 328 pixels across. The gap from the header to the first card is 16 pixels, and the gap between the two cards is 16 pixels. Inside a card, the dish name sits 8 pixels below the photo, the description 8 below the name, and the button 16 below the price. The button is 38 pixels tall: the text line measures about 18 pixels, with 10 pixels of padding top and bottom. Both cards measure exactly the same height, 313 pixels, because both use the same spacing values.
Notice what the numbers say. Three spacing values, 8, 16 and 24, cover the whole screen. Nothing on it uses 10, 12 or 20. The two cards are the same height not because anyone measured them, but because the same values went into both: consistency is a side effect of using the scale, not something you check afterwards.
The same scale in code
A spacing scale that lives only in Figma drifts the moment a developer builds the screen, because the developer has no scale to read from. It needs to exist in code too, with the same names and values. In CSS, that is a small set of custom properties, kept with the other tokens from the Design Systems (/tutorials/ui-ux/design-systems) tutorial:
:root {
--space-1: 8px;
--space-2: 16px;
--space-3: 24px;
--space-4: 32px;
}
.card {
background: #ffffff;
border: 1px solid #e5dbc7;
border-radius: 12px;
padding: var(--space-2);
}
.card h2 {
margin: var(--space-1) 0 0;
}
.card .price {
margin: var(--space-1) 0 0;
}
.card .btn {
margin-top: var(--space-2);
}
.cards {
display: flex;
flex-direction: column;
gap: var(--space-2);
margin-top: var(--space-2);
}Every gap on the page is one of the four tokens: no bare 10px or 14px anywhere. Search the stylesheet for px and every match should be a token definition or a font size. A gap value that appears only once, outside the tokens, is a gap someone invented on the spot, and it is the first thing to fix in a review.
The wrong turn: padding copied by eye
Here is the wrong turn, reproduced live. Two small cards with identical content were placed side by side. The first uses the scale: 16 pixels of padding. The second was copied and its padding changed by eye to 12, because 12 "looked about the same". The browser says otherwise:
card with 16px padding: 90px tall
card with 12px padding: 82px tallEight pixels of difference, from four pixels of padding on each side. Put those two cards in a row and the row is uneven: one card is taller, its text sits lower, and the whole row looks like a mistake. A developer handed the second card would copy the 12 forward, and within a week the screen would have three different card paddings.
The fix is not a better eye. It is never typing a padding value into a card at all. The card reads its padding from the scale, and the scale has no 12 in it. When a card needs to be tighter, the answer is the next step down on the scale, 8, not a number invented between the steps. That discipline is what the scale is for.
How to verify it worked
Three checks, all of them by looking, and none of them need a tool.
First, the squint test. Hold the screen at arm's length, or squint until the text blurs. You should still see the groups: header, card, card. If they blur into one block, the gaps between groups are too small. If the header floats alone, they are too big.
Second, the edge test. Draw an imaginary line down the left edge of the screen: the header text, the card edges and the button edges should all touch it. Any element a few pixels off it is misaligned, and a few pixels is exactly the amount that reads as a mistake.
Third, the scale test. List every gap on the screen and check it against the scale: 8, 16, 24, 32. A gap of 12, 20 or 28 is one someone invented, and it goes back on the scale. Run this check on the finished screen and on the code.
Try it yourself
1. Open Figma and rebuild the Corner Shop screen from section 6, using only 8, 16 and 24 for every gap. Turn on the layout grid and check that the header, the cards and the buttons all share the left edge. 2. Deliberately break it: change one card's padding from 16 to 12 and one gap from 16 to 20. Squint at the screen and write down what feels wrong before you look at the numbers. That feeling is what the scale prevents. 3. Take a screen you made before this tutorial, list every gap on it, and check each one against the 8-point scale. Change the ones that are not on it, and compare the before and after. Keep the after. 4. Build the spacing tokens from section 7 into a small page of your own, and search the stylesheet for bare pixel values. Every gap should be a token.
Common mistakes
- Spacing by eye, one gap at a time. The gaps end up 11, 14 and 19, and the screen feels uneven in a way nobody can name. Use the scale, and let the scale choose the gaps.
- Almost aligning. Two edges 3 pixels apart read as an error, not as a choice. Line things up exactly, or separate them clearly.
- Even spacing everywhere. A form with 16 pixels between every element is confusing, because each label is equally close to the input above and below it. Inside a group should be about half the gap between groups.
- Treating whitespace as wasted space. Packing a screen full makes it harder to read, not richer. Space around a thing is what makes the eye stop on it.
- Centring body text. Centred text has a ragged edge on both sides, and the eye has to find the start of every line. Centre a short heading if you like, and keep the body left-aligned.
- A scale that lives only in Figma. Developers build from code. If the spacing tokens do not exist in the stylesheet with the same values, the Figma file and the website will drift apart within a week.
Frequently asked questions
Do I have to use 8? What about 4?
No, 8 is a choice, not a law. A 4-point scale (4, 8, 12, 16, 20, 24) is common and gives finer steps. We use 8 here because fewer choices mean fewer chances to drift, and three steps cover a phone screen. Pick one scale, write it down, and use it everywhere: the scale matters less than the discipline of having one.
How much space should a phone screen have at the edges?
16 pixels is a good default, and it is what this tutorial uses. It leaves room for the thumb at the screen edge and keeps content from touching the frame. On a wider desktop layout the margin grows, usually to 24 or 32, but the rule is the same: one value, used on both sides, on every screen.
Is whitespace really doing anything, or is it just empty?
It is doing the separating. Without it, groups merge into one block and the eye has nowhere to rest. The squint test in section 9 shows it: blur the text and the groups should still be visible, and only the space between them makes them so.
What if my design genuinely needs a gap that is not on the scale?
Then the layout is usually wrong, not the scale. A 12-pixel gap between a heading and a paragraph often means the heading is too big, and a 20-pixel gap between cards often means one card has padding hiding inside it. Fix the layout first. If the gap is still needed after that, add a step to the scale, write it down, and use it everywhere the same situation appears.
Does spacing matter on a desktop screen too, or only on phones?
It matters more on desktop, because there is more room to get wrong. A desktop page with 16-pixel gaps everywhere looks cramped in a wide window, and the fix is the same scale stepped up: 24 between sections, 32 around the page. The numbers change with the screen size. The scale does not.
Follow the UI/UX Designer Roadmap
Design clean, user-friendly interfaces and prototypes with modern design tools. Free, step by step, at your pace.
View the Roadmap