# Grid Relation: How Components Snap to the Layout Grid

> Learn how a design system sizes and places components in columns and base units so every screen lines up.

**In short:** Grid relation is how a design system sizes and places components in columns and base units, so every screen lines up with the layout grid.

From "Design systems", a free course by Venkat R. Murty: https://designervenkat.online/learn/design-systems/grid-relation

## What You Will Learn

Open any well-made app or website and you will see an invisible structure underneath. Text starts at the same left edge as images. Cards line up in neat rows. Buttons sit at predictable distances from each other. Designers do not get this by luck. In a design system, each component is tied to a shared layout grid so that it fits that structure every time. This lesson calls that link grid relation.

By the end, you will be able to explain how a component's width is set in columns, how its height and inner spacing follow a base unit, when it is acceptable to step outside the grid, and how to write down the rules so that a designer and a developer place the component the same way.

- **Grid:** A set of vertical columns, with gaps and side edges, that content lines up to.
- **Column:** One vertical strip of the grid where content sits.
- **Gutter:** The gap between two neighbouring columns.
- **Margin:** The empty band at the left and right sides of the page, between the content and the screen edge.
- **Span:** How many columns a component covers, for example 3 of 12.
- **Base unit:** One small measure, such as 4px or 8px, that other sizes are built from.
- **Baseline:** The imaginary line that letters sit on. A baseline grid is a set of evenly spaced lines like this.
- **Line height:** The vertical space given to one line of text, measured from one baseline to the next.
- **Padding:** The space inside a component, between its edge and its content.
- **Snap:** When an element lines up with the nearest grid edge or line instead of sitting at a random position.

## Why Span Whole Columns?

The main idea of grid relation is that a component does not get a random width. Its width is a count of columns. On a 12-column grid, a product card might cover 3 columns, a page header might cover all 12, and a centred article block might cover 8. Because every size counts the same columns, the card, the header and the article all share one set of edges.

Design systems set limits on those counts. The Atlassian guidance gives example spans of 12, 6 or 4 columns, and centred blocks of 8, 10 or 12 columns. A block can sit on a smaller set of columns and still be centred on the grid. Limits like these are design decisions, so write them down with the component.

- **Start and stop on column edges:** A component's left and right edges should land on the outer edges of its columns. They should not stop in the middle of a column or drift into a gutter. The UCLA system makes this point directly, and the Nielsen Norman Group says content belongs within columns, not in the gaps.
- **Use full width for big blocks:** Page headers, hero images and wide tables usually cover all 12 columns. Their edges then match the outermost column edges on the page, the same as every other block.
- **Leave small items at their natural width:** Tags, pill buttons and icons get their size from their content. Stretching them to fill a span makes them look wrong. Keep them at their own width and align their container or position instead.

### Why Keep Gutters and Margins Consistent?

Columns only help if the space between them never changes. The gutter should be the same across the page. The margin, the band at each side, should stay fixed too. The Ontario system uses 16px gutters and 16px side margins at its smaller breakpoints.

Be careful with a shortcut. Some teams push content inward by treating a column as if it were a margin. The Sainsbury's guidance warns against this and asks teams to use real margins instead. Real margins keep the page edge in the same place as the content changes.

Consistency also keeps a layout in shape at any width. In a fluid grid, the columns and gutters get narrower as the screen shrinks, and the number of columns can change at each breakpoint. Each component keeps its column count, so the layout stays aligned.

## Why Use a Baseline and a Base Unit?

Columns handle the side-to-side layout. Heights and vertical spacing need their own rule. Many design systems pick a base unit, a small measure such as 8px or 4px, and build most sizes from it. Padding, gaps, icon sizes, component heights and line heights become multiples of that unit. Because they all come from one number, they line up with each other.

A baseline grid is a set of evenly spaced horizontal lines that text sits on. The Sainsbury's system notes that most of its components align to an 8px and 16px square baseline grid across mobile, tablet and desktop. A 4px step is a useful half-step for tight spaces.

> **Tip:** Pick the base unit first, and write it on the page as a rule. Choose 8px for most teams. Use 4px only for small, tight details, so the design keeps one set of sizes.

### Line Height and Vertical Rhythm

Line height is the vertical room given to one line of text. Font sizes can vary, but line heights should land on the grid. Headings and margins can then use multiples of 24, so the text stays on the same vertical steps.

Real life is less neat. One typography guide notes that steps of 8 can sit too far apart for some text sizes, so teams sometimes use steps of 4 instead. Another guide says that on the web, strict baseline alignment is hard, because line height changes with the font and the size. Treat the baseline as a rule of thumb you check, not a promise to hit exactly.

The even spacing this creates is called vertical rhythm. When line heights, padding and gaps all come from one base unit, text blocks, images and buttons seem to step down the page together.

### When Is It Fine to Break the Grid?

Sometimes stepping off the grid is right. The rule is not never. The rule is: break on purpose, write the reason down, and keep to the base unit. Some common cases are acceptable.

- **Small intrinsic items:** Tags, pills and icons can sit at their natural size. The Atlassian examples place buttons and icons with spacing tokens instead of column edges, and they flag buttons forced onto column edges as an error.
- **Navigation and side panels:** The grid is meant for the main content area. Atlassian says the grid is for the main content area, and that navigation and panels are covered by a separate layout component.
- **Spacing inside a component:** A card can sit on columns while its own padding and gaps follow the base unit. Its text does not need to match a column edge.

> **Tip:** Before you break the grid, ask whether the item looks wrong when it is lined up with the columns. If it looks fine on the grid, keep it there. If not, record the reason next to the component.

## How Do You Document Each Component's Grid Behavior?

A grid rule that lives only in one designer's head will get broken. Write each component's grid behaviour into its entry in the design system, so designers and developers place it the same way.

- **Allowed spans:** List every column count the component may use, for example 3, 4 or 6 of 12 for a card. Also say which counts are never allowed.
- **Snapping:** Say what the component locks to: column edges, the base unit, or the baseline. Say what happens when the chosen span does not fit the space available.
- **Reflow:** Say how the span changes at each breakpoint, which is a screen width where the layout changes. Note whether the component wraps to a new row or shrinks when a row is full.

1. **Name the component and its type:** Say whether it is a container that snaps to columns, or a small intrinsic item that keeps its natural width.
2. **List the allowed spans:** Write the allowed column counts at each screen width, and mark one as the default.
3. **Set the base unit rules:** Give the base unit for padding, gaps and height, and the line height of any text inside.
4. **Describe what happens when space runs out:** State whether the component wraps to the next row or shrinks to fit.
5. **List the exceptions:** Name each allowed break and its reason, so the next person does not have to guess.

> **Tip:** Keep the grid entry in the same place as the component's other rules. Then test it on a real screen. A rule nobody can find is a rule nobody follows.

## Worked Example: A Product Listing Page

Here is how the ideas fit together on an online shop's product listing page. The numbers are teaching choices for this lesson, not figures from a real shop. The page uses one 12-column grid, with the same gutters and margins at every width.

1. **Desktop: 3 columns per card:** Each product card spans 3 of the 12 columns. Four cards fit in one row, because 4 times 3 makes 12. The gutters sit between the cards, and the margins sit at the page edges.
2. **Tablet: 4 columns per card:** Each card spans 4 columns. Three cards fit in a row, because 3 times 4 makes 12.
3. **Mobile: 6 columns per card:** Each card spans 6 columns. Two cards fit in a row, because 2 times 6 makes 12.
4. **Align the page edges:** The page header, the filter bar and the card grid all start and stop on the same outer column edges. The card edges therefore line up with the header text at every screen width.
5. **Use the base unit inside each card:** Inner padding follows an 8px base unit. For example, 16px of padding is two units. The product image's height and the title's line height are also multiples of 8, so the text and the image follow the same vertical steps.
6. **Reflow when the screen narrows:** As the screen gets narrower, each card moves from 3 columns to 4 to 6. The grid entry tells the developer which span to use at each width, so the card is placed the same way every time.

> **Tip:** To check a layout, turn on a column overlay in a design tool such as Figma. Then look at each card edge at every width you test, and confirm it sits on a column edge.

## Check Your Understanding

**Quick check:** A designer's new promo banner is 1000px wide on a 12-column layout where the 12 columns total 1100px. Its edges do not line up with the cards below it. What is wrong, and how would you fix it using grid relation?

A. The banner is too tall, so move it higher on the page.
B. The banner's width does not match the grid's width, so its edges miss the column edges. Make it span all 12 columns so its edges meet the outer column edges.
C. The cards are too narrow, so widen every card to 1000px.
D. The gutters are missing, so delete them to let the banner grow wider.

**Answer:** B. The problem is width, not height. The banner should be set as a span of whole columns, so its edges come from the grid instead of a fixed number that the grid does not match.

**Quick check:** A designer stretches a small pill-shaped tag across four columns so that its left edge lines up with a card below. Is this a good use of grid relation?

A. Yes, every element should fill the span it is placed in.
B. No, the tag should keep its natural width, and only its position or container should follow the columns.
C. Yes, but only if the tag is also set to 3 columns.
D. No, because tags can never sit near the grid at all.

**Answer:** B. Small intrinsic items keep their natural width. Stretching them to fill a span makes them look wrong, even when their position lines up with a column.

**Quick check:** A team sets body text to 16px with a 22px line height. Every padding value in the card is a multiple of 8. Does the text stay on the vertical grid?

A. Yes, because the padding is on the grid, so the text follows it.
B. No, because 22px is not a multiple of 8 or 4, so each line drifts off the vertical rhythm.
C. Yes, as long as the font size is a multiple of 8.
D. No, because text should never sit inside a card.

**Answer:** B. Line height sets the vertical rhythm of text. Correct padding cannot fix it. A 24px line height, a multiple of 8, would keep the text on the grid.

## Key Takeaways

- **Width comes from columns:** Components span whole columns and start and stop on column edges.
- **Height comes from a base unit:** Padding, gaps, heights and line heights use one base unit, such as 8px, so the vertical rhythm holds.
- **Rules are written down:** Each component's allowed spans, snapping and reflow are documented, and any break from the grid is explained.

## Sources

- [Atlassian Design: Grid overview](https://atlassian.design/foundations/grid)
- [Atlassian Design: Grid beta overview](https://atlassian.design/foundations/grid-beta)
- [Sainsbury's Design System: Layout](https://design-systems.sainsburys.co.uk/foundations/layout/)
- [Ontario Design System: Grid](https://designsystem.ontario.ca/components/detail/grid.html)
- [UCLA Design System: Grid](https://designsystem.brand.ucla.edu/build/v2.7.0/docs/layout/grid.html)
- [Nielsen Norman Group: Using Grids in Interface Designs](https://www.nngroup.com/articles/using-grids-in-interface-designs/)
- [Paste (Twilio) Design System: Grid](https://paste.twilio.design/components/grid)
- [Base Design System (zeroheight): Layout grids](https://zeroheight.com/6d2425e9f/p/785d5f-layout-grids)
- [Intelligence Community Design System: Layout grid](https://design.sis.gov.uk/components/layout/layout-grid)
- [GridMaker Pro: Baseline grid and vertical rhythm](https://gridmakerpro.com/grids/typography-grids/baseline-grid/)
- [GridMaker Pro: Typography grid systems](https://gridmakerpro.com/grids/typography-grids/)
- [GridMaker Pro: 8pt spacing grid](https://gridmakerpro.com/grids/typography-grids/8pt-spacing-grid/)
- [freeCodeCamp: 8-Point Grid, Typography on the Web](https://www.freecodecamp.org/news/8-point-grid-typography-on-the-web-be5dc97db6bc/)
- [Cieden: Spacing best practices (8pt grid)](https://cieden.com/book/sub-atomic/spacing/spacing-best-practices)
- [WP Dean: What Is the 8-Point Grid System](https://wpdean.com/what-is-the-8-point-grid-system/)
- [Squarehead: Grid Systems for Web Design](https://squarehead.co.uk/articles/grid-systems-for-web-design-the-invisible-structure-behind-every-good-layout)
