Sub topic 9
Describing responsive behavior across breakpoints
This chapter assumes you can build frames and components in a design tool and that you know basic CSS, including media queries and flexbox or grid. It builds on the layout, spacing, and token chapters. By the end you should be able to hand a developer a responsive spec that covers the sizes you did not draw, and not only the ones you did.
Why a few mockups are not a responsive spec
A designer usually draws a desktop frame and a mobile frame. A browser window can be any width between and beyond them. If the handoff says nothing about those in-between widths, the developer has to guess. Different developers guess differently, and the guesses surface later as bug reports.
A responsive spec answers four questions for every section of a page:
- At which widths does the layout change?
- What changes at each of those widths?
- What stays fluid between the changes?
- What are the limits, such as the narrowest and widest supported widths?
Define the breakpoints once
A breakpoint is a viewport width at which the layout switches to a different arrangement. Define breakpoints once, name them, and use only those names in the file. Treat them like any other token.
| Name | Range | Typical device | Columns | Gutter | Side margin |
|---|---|---|---|---|---|
| `bp-sm` | 0 to 599 px | Phones | 4 | `space-3` (16 px) | `space-3` (16 px) |
| `bp-md` | 600 to 959 px | Large phones, small tablets | 8 | `space-3` (16 px) | `space-4` (24 px) |
| `bp-lg` | 960 to 1279 px | Tablets, small laptops | 12 | `space-4` (24 px) | `space-5` (32 px) |
| `bp-xl` | 1280 px and up | Laptops, desktops | 12 | `space-4` (24 px) | Centered, max width 1200 px |
The table is an example, not a standard. Your project may already have breakpoints in its CSS. If it does, copy those values, because inventing new ones creates a mismatch the developer has to resolve.
State each breakpoint as the width where the layout starts to apply. "From 960 px" is clear. "Desktop" is not, because it does not say whether a 1000 px laptop window counts.
Mobile-first or desktop-first
Ask the developer which direction the code is written in. In a mobile-first codebase the base styles are the smallest layout, and each breakpoint adds rules with min-width. In a desktop-first codebase the base is the largest layout and max-width queries remove or rearrange things. Either works, but your spec should be written in the order the developer will build it. Mobile-first is the more common choice, so the examples here use it.
Say what changes and what stays fluid
Between two breakpoints, a layout should stretch and shrink smoothly. At a breakpoint, it changes structure. Your spec should make that split explicit. For each region, list the behavior in one of these categories:
- Fluid: the element resizes with the container. Example: "Card images fill the card width and keep a 16:9 ratio."
- Fixed: the element keeps a set size. Example: "Icons stay 24 px at every width."
- Reflowing: the element moves to a new position. Example: "The sidebar moves below the main content under 960 px."
- Swapping: a different component or variant replaces the first. Example: "The full navigation becomes a menu button under 960 px."
- Hidden or shown: content exists at one size and not at another.
> Use the hidden category with care. Hidden content still downloads, and a screen reader may still read it, depending on how it is hidden.
The callout below covers a common source of that problem.
Show the behavior in the file
Draw one frame per breakpoint for every page template, using the real grid for that breakpoint. Place the frames side by side with identical content so differences are easy to see. Label each frame with the breakpoint token and the exact width, for example Home / bp-md / 768.
Add the frames that the usual pair misses:
- A width just above each breakpoint, such as 960 px, to show the layout at its tightest.
- A width just below each breakpoint, such as 959 px, to show the layout at its widest before it changes.
- The widest supported width, to show what happens to the empty space.
If a design tool supports constraints or auto layout, set them so the frames resize believably. Constraints in a design tool do not translate one-to-one into CSS, so annotate the intent in words as well.
Write per-component rules
Rules written per component are easier to implement than a page-level description. A short structured note works well:
Component: Product card grid
Container: max-width 1200px, centered, side margin space-3 below bp-lg
bp-sm: 1 column, gap space-3
bp-md: 2 columns, gap space-3
bp-lg: 3 columns, gap space-4
bp-xl: 4 columns, gap space-4
Between breakpoints: columns share width equally (fluid).
Card min-width: 240px. Image ratio 4:3, never cropped below 4:3.The "Between breakpoints" line carries the key information. It tells the developer that no intermediate widths need special handling.
What the developer builds from it
The note above maps almost directly to CSS. A mobile-first version looks like this:
:root {
--space-3: 16px;
--space-4: 24px;
--bp-md: 600px;
--bp-lg: 960px;
--bp-xl: 1280px;
}
.card-grid {
display: grid;
grid-template-columns: 1fr;
gap: var(--space-3);
max-width: 1200px;
margin-inline: auto;
padding-inline: var(--space-3);
}
@media (min-width: 600px) {
.card-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 960px) {
.card-grid {
grid-template-columns: repeat(3, 1fr);
gap: var(--space-4);
}
}
@media (min-width: 1280px) {
.card-grid {
grid-template-columns: repeat(4, 1fr);
}
}Custom properties cannot be used inside a media query condition. That is why the @media rules above contain the literal pixel values, and the --bp-* variables serve only as documentation. If your spec lists breakpoint tokens, tell the developer the values must be repeated, or that a build tool will substitute them. Without that note, a developer may try @media (min-width: var(--bp-md)), which does not work.
Specify fluid type and spacing
Some values should change continuously and not in steps. The most common case is type size. You can describe this as a range with a minimum, a maximum, and the widths between which it scales.
| Token | At 360 px | At 1280 px | Behavior |
|---|---|---|---|
| `font-size-h1` | 28 px | 44 px | Scales linearly between the two widths |
| `font-size-body` | 16 px | 18 px | Scales linearly between the two widths |
| `space-section` | 32 px | 80 px | Scales linearly between the two widths |
The developer can implement this with clamp():
:root {
--font-size-h1: clamp(1.75rem, 1.2rem + 2.4vw, 2.75rem);
--font-size-body: clamp(1rem, 0.95rem + 0.2vw, 1.125rem);
}
h1 {
font-size: var(--font-size-h1);
line-height: 1.15;
}clamp(min, preferred, max) returns the preferred value but never goes below the minimum or above the maximum. Because the minimum and maximum are in rem, they still respect the user's browser font size. A purely vw-based size does not, which is an accessibility problem covered in a later chapter.
You do not need to write the clamp() formula yourself. State the two end values and the two widths. If you give only the endpoints and no widths, the developer must guess where the scaling starts and stops.
Cover the edge cases
Edge cases are where handoffs fail. Address these explicitly:
- Minimum width. Pick the narrowest width you support, commonly 320 px, and confirm that nothing overflows horizontally. Long words, URLs, and buttons with long labels are the usual offenders.
- Maximum width. State what happens above your largest frame. Options are a centered container with a max width, a background that continues full bleed, or content that keeps growing. Pick one.
- Content length. Show a headline with two words and one with twelve. Say whether text truncates with an ellipsis, wraps, or grows the container.
- Touch targets. On small screens, interactive elements should be large enough to tap, commonly at least 44 by 44 px. If a desktop icon button is 32 px, say how it grows on touch devices.
- Orientation. A phone in landscape is wider than
bp-sm. State whether landscape uses thebp-mdlayout, which it will by default under width-based queries. - Images. Say whether images are cropped, scaled, or swapped at breakpoints, and give the aspect ratio at each. The export chapter covers file scales and the
srcsetattribute. - Tables and wide data. Choose one: horizontal scroll inside the container, stacked rows with labels, or hidden columns with a detail view.
- Sticky and fixed elements. A sticky header that is 80 px tall on desktop may consume too much of a short phone screen. Give its mobile height.
Show the flow of decisions
The diagram below shows the order of decisions a spec should capture for each region.
Common errors
- Describing breakpoints by device name. "iPad" changes every year. Use pixel ranges and token names.
- Drawing only the extremes. The in-between widths are where layouts break. Draw at least the widths just above and below each breakpoint.
- Mixing units. A frame labeled in pixels and a spec in
remforces the developer to convert. State the base, usually 16 px = 1 rem, once. - Leaving desktop-only features unmentioned. Hover tooltips have no touch equivalent. Say what touch users get.
- Inconsistent spacing. Using 18 px at one breakpoint and 20 px at another, when no token has either value, adds new values the system never defined. Use existing spacing tokens, or add a token.
- Treating the breakpoint as the only trigger. Sometimes a component should adapt to its container width, not the viewport width. A card in a narrow sidebar on a wide screen needs a compact layout. If you want this, say so, and the developer can use container queries.
Exercise
A designer delivers frames for 375 px and 1440 px, with the note "tablet is a mix of the two." The team's breakpoints are 600, 960, and 1280 px, and the code is mobile-first. List four things missing from this spec, and write the product-grid rule for a 768 px viewport using min-width media queries.
Show answer
Missing items: (1) named breakpoint tokens with ranges, since "tablet" is undefined; (2) frames or rules for each breakpoint, including widths just above and below 600, 960, and 1280 px; (3) a statement of what stays fluid and what changes structure, such as column counts and gutters; (4) edge cases, namely the minimum width, the maximum width, and long or short content. For 768 px, the viewport is at or above 600 px and below 960 px, so only the 600 px query applies: @media (min-width: 600px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }. The 960 px rule does not match, so the grid has two columns.