Skip to content
Writing
Design
· · 12 min

The things between the pixels

listen to this article from the Wonder Why? podcast
Listen

A design file is a set of photographs. It shows you where everything is when nothing is happening.

Most of what makes an interface feel good happens when something is: halfway between two states, under somebody's finger, behind a pane of frosted glass, at the exact moment a hand lets go. None of it fits in a frame.

I learnt most of what follows while building Insponent, a library of interactive components, usually by getting it wrong first. Some of it came from studying products I admire. The rest came from interfaces that irritated me enough to measure them.

It starts with the static things and gets less static as it goes.

Part one: between values

01. Give curvature room to breathe

Increase the radius of a button and its padding suddenly feels too tight.

A rectangular button and a pill can have identical dimensions and identical contents and still feel nothing alike. The curve eats the corners, and the label loses the space it seemed to have.

Radius 50 → 22 usedPadding 7px · cramped
Move the radius past 22px: the slider keeps going, the corner doesn't. Then give the label more padding, or try the more generous pill.

For a 44px-high button, anything past a 22px radius gives the same silhouette. Past that point you aren't fixing the button with its radius any more. You're fixing its proportions.

.button {
  min-height: 44px;
  padding-inline: 16px;
  border-radius: 8px;
}

.button-pill {
  padding-inline: 19px;
  border-radius: 999px;
}

Change the curve, and change the padding with it.

How much padding, though? I tried arithmetic first. A semicircle of radius r fills πr/4 of the r it spans, so on average a round end sits r × (1 − π/4) further in than the box says: almost 5px on a 44px pill. Add that to every pill on a site and they all come out wrong, with too much room after the label and nothing that scales together.

The average covers the pill's whole height, and the letters only use the middle of it, where the curve takes less than a pixel.

So I set every pill on this site by eye, then measured what I'd chosen. One number kept turning up: the label side's padding is about 0.44 × the pill's height, a little under the radius. The label starts about where the curve ends. A 37px pill got 16, a 42px pill 18, a 33px pill 14, a 22px badge 10.

Size the pill by its height and the top and bottom padding follow. The 2:1 ratio you'll see quoted is a side effect of one line-height, not a rule.

Anything in front has its own rule. A circle that nearly fills the pill belongs on the centre of the curve, the same distance from every edge: (h − size) ÷ 2. A 23px disc in a 37px pill sits 7px in, and that's exactly where my eye put it.

A small icon sits a couple of pixels further in than that, and a square or a hexagon further still, because its corners reach into the curve. Those last two I'd set by eye rather than by formula.

16px: the label starts 6px into the curve
Approve
Not recommended: A square button's padding
0.44 × 44 = 19px
Approve
Recommended: Padding from the height
Drawn at 2×. Switch between the cases: the label starts about where the curve ends, at 0.44 × the height, and a circle in front sits on the curve's centre.
.pill {
  --h: 44px;
  height: var(--h);
  border-radius: calc(var(--h) / 2);
  /* the label starts about where the curve ends */
  padding-inline: round(var(--h) * 0.44, 1px);
}

.pill:has(> .disc:first-child) {
  /* a circle that nearly fills the pill shares the end's centre */
  --disc: 32px;
  padding-inline-start: calc((var(--h) - var(--disc)) / 2);
}

02. Space is directional

I've never understood the religious attachment to an 8px grid.

A vocabulary of spacing values makes sense. Expecting every direction in a layout to express the same relationship doesn't.

Mobbin's desktop card grid uses 16px between columns and 48px between rows. Inside a card, the image sits 16px from its details, and the logo sits 8px from its name.

16 to its own picture, 16 to the next
Fieldnote

Productivity

Ledger

Finance

Orbit

Travel

Tally

Health

Not recommended: Uniform 16/16
16 to its own picture, 48 to the next
Fieldnote

Productivity

Ledger

Finance

Orbit

Travel

Tally

Health

Recommended: Relational 16/48
Compare the gap between rows with the gap under each picture. Only the row gap differs, and with it which picture each name belongs to.
.collection {
  column-gap: 16px;
  row-gap: 48px;
}

.card-information {
  margin-block-start: 16px;
}

.app-identity {
  gap: 8px;
}

Every one of those numbers belongs to a scale. What makes them work is where each one is used.

A spacing system tells you which values exist. It doesn't tell you which one belongs.

03. Colour is relational

We spend a lot of time choosing individual colours and very little looking at what they do to each other.

Linear's muted text isn't one grey. The sidebar uses roughly #919294; raised surfaces use #98999c. The difference is tiny, and it's on purpose.

So I name colours by their job and let the job adapt to the surface:

.sidebar        { --text-muted: #919294; }
.raised-surface { --text-muted: #98999c; }
.metadata       { color: var(--text-muted); }

Properties

StatusPriorityAssigneeLabels#919294 · 5.0:1
In progressHighAdenekanMotion
Not recommended: Identical grey

Properties

StatusPriorityAssigneeLabels#98999c · 5.4:1
In progressHighAdenekanMotion
Recommended: Contextual grey
Compare the panel’s labels in the two apps. Both pass; on the right they are lifted a few steps so they don’t sink into the raised surface (the sidebar’s own grey measures 6.1:1).

The same thinking applies along a palette. Generated ramps usually keep a blue at the same hue from its lightest to its darkest step. Mobbin's doesn't. Its blue moves from 205° to 227° as it darkens, its greens move away from yellow towards a purer green (97° to 120°), and its yellows turn amber and then brown (53° to 21°).

53°
Not recommended: Fixed hue
21°, turned 32°
Recommended: Hue drifts
Press a step in either ramp. Yellow is where it shows: held at 53° its dark end goes olive; turned towards red it stays warm. Blue and green barely mind.

That's why a warning colour doesn't have to turn into muddy olive when you darken it. is a better place to start than , but I still want to see the colours next to each other before I trust them.

Getting the maths consistent isn't the same as getting the colours to work together.

04. Typography doesn't scale proportionally

56px isn't a big 14px. As text grows, the spacing between letters needs to change, the spacing between lines needs to change, and sometimes the weight does too.

Mobbin's scale shows it clearly:

Mobbin's type scale
SizeLine heightRatioTracking
12161.33+.2px
14201.43+.2px
16221.38+.2px
24301.250
32361.130
44481.09−.4px
56561.00−.6px
80801.00−.6px

Tracking flips from positive to negative as the text grows, and the relative line height falls from 1.43 to 1.

Linear separates interface text from reading text: most of the interface is 13px, while descriptions and comments are 15px on a 24px line. You don't read a label the way you read a paragraph. They shouldn't share a rhythm.

Goodmorning

Line 69px · tracking +0.7px
Not recommended: 14px scaled up

Goodmorning

Line 51px · tracking −0.5px
Recommended: Mobbin's pair
Drag the size. One slider sizes both; watch the line boxes on the left stay airy while Mobbin's close in as the text grows.

Pick a size, a line height and a tracking together, as one decision. That's what Mobbin's tokens do, and it's the argument I made in Aesthetic debt.

The hinge: a gradient has a rhythm

05. Give your gradients an easing function

We'll spend an hour choosing the for a 200ms animation, then let a gradient progress linearly across 400px of image.

A linear opacity fade leaves a visible edge exactly where the image is meant to disappear. The endpoints are right. The distribution between them isn't.

A river at sunset
Not recommended: Linear
A river at sunset
Recommended: S-curve
Look at where each photograph meets the page. Both fades use 25 stops from 0 to 100% over the same length; only the curve between them differs.

Andreas Larsen called these easing gradients years ago, and they're still underused. Smoothstep is a good start:

const smoothstep = (t: number) => t * t * (3 - 2 * t);

const stops = Array.from({ length: 25 }, (_, i) => {
  const t = i / 24;
  return `rgb(240 238 232 / ${smoothstep(t)}) ${t * 100}%`;
});

const fade = `linear-gradient(to bottom, ${stops.join(",")})`;

The fade starts and finishes gently, so the middle gets steeper to make up for it. Judge it against the image, not the curve.

A gradient doesn't move, but it still has timing. Everything from here on actually moves.

Part two: between states

06. Inspect the colours between states

Two beautiful states don't guarantee a beautiful transition.

In one of Insponent's sliders, the track and its label swapped colours as you dragged: the surface went from light to dark while the ink went from dark to light. Both reached the same grey at the same moment, halfway along. The label disappeared into its own background.

The button is rgb(194 194 196) and its label rgb(70 70 72).

5.35 : 1
Not recommended: Both colours interpolate

The button is rgb(194 194 196) and its label rgb(28 28 30).

9.61 : 1
Recommended: Contrast-aware ink
Scrub both buttons from rest to active and watch the contrast under each. Then inspect the midpoint.

The fix is either to separate the two transitions, or to switch the ink at once based on the surface's current luminance. A sudden change has its own cost, so neither is free.

Check every stop and check the middle. A static design file will happily hide this from you, because it only ever shows the ends.

07. Not everything that settles is a spring

When I started studying Bencho's components, I measured them from the outside: recorded the motion, sampled the frames, fitted curves. Their carousel matched a critically damped to within ten percent. That felt like confirmation.

Then I read their code. It wasn't a spring. It was a quart-out over a fixed duration.

// what I fitted
vel += (target - pos) * k * dt;
vel *= d ** dt;
pos += vel * dt;

// what it was
const ease = (t: number) => 1 - (1 - t) ** 4; // over 620ms

Ten percent of error was hiding an entirely different idea of time. A spring has no duration. It inherits whatever velocity came before and can be redirected halfway. An easing curve has a beginning and an end, and it lands exactly when it was told to.

Recommended: Critically damped spring
Not recommended: Quart-out, 620 ms
Send them across, then click either track while they're moving. Watch the lean: the spring turns with its speed, the curve flips and starts its 620ms again.

So I choose by meaning. Anything the hand caused, and anything that can be interrupted, gets a spring. Something that needs to feel arrived, with no overshoot, can get a curve. Colour and opacity can be linear. I haven't found a use for ease-in-out.

A motion spec that just says "300ms ease-out" hasn't decided which of these it is.

08. A state machine adds behaviour, not appearance

The first version of Insponent's music island looked right and couldn't be paused.

So I gave it real states: playing, paused, a call, a timer, a download. The rewrite worked, and it ruined how the island looked. Every new state had brought a little bit of new interface with it.

What I do now is write the table first: every phase, how you get into it, the control that sends you there, and how you get out. A phase with no way out is a bug. A finished download needs "Try again". An ended call needs "Call back".

And then the rule that saved the island: new states reach through controls already in the layout, and "off" is shown with the smallest possible change. Swap a glyph, change a word, dim to 50%. Anything that was ticking keeps ticking exactly as before. If a screenshot changes somewhere that no state changed, that's a regression.

Two more rules from Insponent belong next to that one:

  • A change of view crossfades; a change of value never does. Switching from the player to a timer can dissolve. A clock counting down should just count.
  • The shape is one spring, the content is a crossfade. When a surface like the island grows, its width, height and radius move together on one spring. The old layout leaves first, the new one arrives about 60ms later from a slight scale and blur (opacity 0, scale .92, blur 6px, around 220ms). Never stretch one layout into the other.
Midnight DrivePaused
Not recommended: Stretch
Midnight DrivePaused
Recommended: Crossfade
Start a timer, then take a call. One press reaches both islands; watch the song title mid-morph, and slow it down if it's too quick.

Part three: under the hand

09. The handle is rigid; the material lags

Anything under your finger should follow it exactly. One to one, no lag, no overshoot. If the thumb of a slider is on a spring, the slider feels like it's being dragged through honey.

The softness belongs to whatever follows the hand: the fill, the label, the shadow catching up a frame later. In Insponent I give a dragged object two springs: a tight one for the thing you drag, which never wobbles once your thumb stops, and a loose one only where the personality lives, like a token rocking past level as it settles.

There's a smaller detail inside this one. Take the grab offset at the first move, not at the press. If you calculate it on pointer-down, pressing a few pixels beside the handle makes it jump to your finger. Record it on the first movement instead, and only start moving on the next one.

let offset: number | null = null;

function onMove(x: number) {
  if (offset === null) {
    offset = x - handleX; // first move: remember, don't move
    return;
  }
  handleX = x - offset;
}
Volume30%
Not recommended: Thumb on a spring
Volume30%
Recommended: Rigid thumb
Arrow keys work on either slider too.
Drag each slider quickly, then press just beside each thumb. Watch the dashed finger line: one thumb trails it and jumps, the other stays on it.

The handle is rigid. The material lags.

10. A limit should feel like a material

A draggable thing that hits a hard wall feels like a bug. One that slides forever feels like nothing.

What I use is direct movement for most of the pull, then a curve that keeps giving but never runs out:

const soft = (d: number) => 160 * Math.tanh(d / 160);

The first stretch is almost exactly 1:1, so the drag feels direct. The tail is where the limit lives. The edge stops being a wall and becomes something with give.

Pull to refresh in Insponent uses a rubber curve, R * x / (R + x), and taught me the other half: commit while the finger is still down. The pull arms at a distance, while you're holding it, and tells you so. By the time anything bounces back, the decision has already been made. The spring and the spinner are reports.

Elasticity is feedback. It should never be latency.

Tobi AdeyemiSunday's ride, still on?9:41
Field NotesIssue 14: the coast road8:02
Ada OkaforPhotos from the marketTue
Not recommended: Wall
Tobi AdeyemiSunday's ride, still on?9:41
Field NotesIssue 14: the coast road8:02
Ada OkaforPhotos from the marketTue
Not recommended: Linear
Pull to refresh
Tobi AdeyemiSunday's ride, still on?9:41
Field NotesIssue 14: the coast road8:02
Ada OkaforPhotos from the marketTue
Recommended: Rubber
Pull each inbox down and watch the dashed finger line. Rubber arms while your finger is still down, before anything bounces.

11. Decide at release

Letting go is the most important moment of a drag, and it usually gets the least design.

When the hand lets go, I work out where the thing would coast to (x + v * carry, rounded to the nearest step) and send it there on a single spring that starts with about 60% of the hand's speed. All of it, on top of a landing that already includes the throw, overshoots and swings back.

A flick coasts. A slow release settles. Because they're the same motion, there's no seam between them.

And one rule I'm fond of: a hand that stopped for 80ms before letting go threw nothing. Otherwise somebody carefully places a thing, lifts their finger, and watches it slide away on velocity left over from before they stopped.

01Lagos
02Accra
03Nairobi
04Lisbon
05Kyoto
06Oslo
07Lima
08Quito
Arrow keys work too
Flick it, drag and release slowly, then drag, hold still and release. Watch the dashed outline: it's where the throw will land.

12. Quiet is expensive

Sound is the most literal "between" in this list: it exists only while something is happening.

My first sounds were harsh and cheap, especially the clicks. The cause wasn't one thing. The palette sat an octave too high, the attacks were 3ms (fast enough to click on their own), and the struck sounds stacked inharmonic partials that read as metal.

What fixed them, as rules:

  • Drop everything an octave.
  • No attack faster than about 6ms.
  • At most three partials, harmonic (1, 2) rather than metallic (1, 2.76, 5.4).
  • Ticks last 60 to 100ms. Shorter sounds like a glitch.
  • A control that moves through values should sound like it's going somewhere. Map the value to a note on a pentatonic scale and play only when it enters a new one, so up sounds like up, and holding still is silent.

The average spectral centroid went from 857Hz to 431Hz. Energy above 3kHz went from 2% to 0.6%.

Not recommended: Metal tick every step
Recommended: Pentatonic note per zone
Sound on: headphones help.
Drag each slider slowly, then fast. Count the ticks on the left; on the right, up climbs the scale and holding still is silent.

Expensive things are rarely loud.

Part four: between layers

13. Glass isn't a backdrop filter

Blur removes detail from whatever sits behind an object. That alone doesn't make it look like glass.

Glass gets interesting when you think about what each layer contributes: the diffusion of the background, the tint of the material, the definition of its edge and how light falls across it.

A city tower lit up at night
TonightRooftop, 9pmBring a jacket. It gets windy up there.
Turn each layer off to see what it was doing. Blur alone removes detail; it doesn't make glass.
.glass {
  position: relative;
  isolation: isolate;
  border-radius: 28px;
  background: rgb(255 255 255 / 8%);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}

.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 25%);
  background: linear-gradient(145deg, rgb(255 255 255 / 18%), transparent 65%);
}

Glass is also the area that's cost me the most afternoons. Three traps:

  • Never fade the parent of a backdrop filter. A faded parent becomes a new backdrop root, and the blur inside it stops seeing what you meant it to. Fade the layers, or move the group with a transform.
  • Frosted layers inside a rounded box blur square at the corners unless the box has clip-path: inset(0 round 28px). Round the clip, not the thing being blurred.
  • Glass hides whatever is drawn before it, whatever the z-order seems to say. A progress ring or a label that sits "on" the glass needs to be painted after it, with its own z-index.

More layers cost more to render and can hurt legibility. More glass isn't better glass.

14. An edge without a border

Mobbin puts a translucent inset edge on its screenshots and logos.

It matters most when the content is white. Without some definition, the edge of an image dissolves into the surface around it. A translucent line mixes with whatever is beneath it; a solid border adds the same flat colour regardless of what's there.

No edge
InboxDraftsSentArchive
Inbox
AmakaProofs for the spring issue
TundeRe: printer quote
StudioInvoice 0412
LolaLunch on Friday?
KemiPhotos from the shoot
Not recommended: None
1px solid, flat grey
InboxDraftsSentArchive
Inbox
AmakaProofs for the spring issue
TundeRe: printer quote
StudioInvoice 0412
LolaLunch on Friday?
KemiPhotos from the shoot
Not recommended: Solid border
0.5px inset, black at 10%
InboxDraftsSentArchive
Inbox
AmakaProofs for the spring issue
TundeRe: printer quote
StudioInvoice 0412
LolaLunch on Friday?
KemiPhotos from the shoot
Recommended: Inset hairline
Look into each magnifier, then switch to the dark card. The hairline keeps the outline without drawing a line you notice.
.image-surface {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}

.image-surface::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 10%);
}

.dark .image-surface::after {
  box-shadow: inset 0 0 0 0.5px rgb(255 255 255 / 16%);
}

Half a pixel is lovely on a high-density screen and unreliable on a 1x one, where it rounds up to a full pixel or disappears. If that matters, a 1px outline does the same job: outline: 1px solid rgb(0 0 0 / 10%); outline-offset: -1px.

The point isn't depth. It's letting the object keep its outline without asking for attention.

15. Every setting needs an honest zero

One last one, which is really about systems.

Almost every component in Insponent has settings: how sticky, how springy, how much it leans. The rule I ended up with is that every one of them has a real zero. Viscosity 0 on the liquid slider is an ordinary slider. If a setting produces something broken at any value, the setting goes.

It's the same question I asked in Aesthetic debt: if a variation is genuinely better, why isn't it the original? A setting that can't go back to the plain version is a fork, not a setting.

A design file shows you where things are. It can't show you how they get there, what they do when you hold them, or what happens when two states meet halfway.

That's where most of the quality is. It's also where most of the debt hides, because nobody reviews what they can't see in a frame.

Adenekan

— Adenekan

Thoughts on this one?

Tell me what it made you think, or where you think I got it wrong.

Still working on the last 10%.0:00pm in london