---
title: "Interface cheat sheet"
issue: 18
date: 2026-08-01
author: "Jakub Krehel"
canonical: https://interfaces.dev/magazine/issues/cheat-sheet
access: free
---

# Interface cheat sheet

A mix of best practices and personal preferences that help build better interfaces.

## User Interface

When nesting elements, **make their border radius concentric**. The outer radius equals the inner radius plus the padding between the elements.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two nested cards with 8px padding and a 12px inner radius: the bad outer card also uses 12px while the good one uses 20px, with a Show values checkbox that draws the radii._

Prioritize **optical alignment** over **geometric alignment**.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Round button that swaps between play and pause on click, centered geometrically on the bad side and with the play icon shifted 6px right on the good side, with a Show margin checkbox._

A button with text and an icon gets **slightly smaller padding on the side of the icon**.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Button with a label and arrow icon shown with 24px padding on both sides next to 24px left and 20px right, with a Show padding checkbox that overlays the measurements._

Use a layered `box-shadow` to give elements **depth** instead of using borders.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two pill buttons side by side, Border with a 1px border and Shadow with a box-shadow that grows on hover, plus a Show background checkbox that puts a gray gradient behind both._

Give images a `1px` outline, offset by `-1px`: black at `8%` opacity in light mode, white at `8%` in dark mode.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Rounded square photo of the sea with a Show border checkbox that turns the 1px outline on and off._

Match the icon's **stroke to the text next to it**.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two New project buttons with a plus icon, drawn with a 1px stroke on the bad side and 1.5px on the good side, with a Show stroke width checkbox that labels each._

## Animation

Make elements **animate from the trigger** rather than the center. Set `transform-origin` based on the trigger's position.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Five menu buttons in the corners and center of the panel that each open a menu scaling out from its own trigger, with a Fast or Slow toggle that stretches the animation from 200ms to 1000ms._

For **menus people open often**, skip the opening animation and only animate when they close.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two dashed areas to right-click that open the same context menu: the one labelled Enter and exit scales and fades in over 300ms while the Exit only one appears instantly and fades out over 150ms._

Make **exit animations more subtle** than entrances. Move the element by a shorter distance as it fades out with `opacity` and a `4px` blur.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two drawers open and close together from one Open button: the bad one slides fully off screen on exit while the good one moves 70% of its width and fades out with a 4px blur._

Name the **exact properties** you want to animate in a transition. Never use `transition: all`.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Static figure of two pills, one labelled transition-all and marked bad and one labelled transition-colors and marked good._

Make buttons **scale down slightly when pressed**. Use a scale between `0.95` and `0.98` with `transition: scale 200ms ease-out`.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two primary Continue buttons to press: the bad one stays the same size while the good one scales down to 0.97 while held._

When icons swap, **fade one out as the other fades in**. Animate the new icon's scale from `0.25` to `1`, opacity from `0` to `1` and blur from `4px` to `0px`. Reverse these for the old icon.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Three copy buttons that swap to a check icon when clicked, the first with no animation, the second with opacity only and the third with opacity, blur and scale, each named in a tooltip legend below._

Use CSS transitions for interactions so the animation **can change direction halfway through**. Use keyframes for sequences that only run once.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two blue squares rotate 180 degrees over 600ms from a Rotate button that can be pressed again mid-turn, the bad one on a keyframe animation and the good one on a transition._

**Disable all transitions** when switching between light and dark mode.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two small Appearance cards with a Save button change theme from a Dark mode switch: the bad one fades each color at its own speed between 200ms and 1200ms while the good one changes at once._

If an element **randomly shifts by 1–2px while animating**, add `will-change: transform` to it. This is especially useful in Safari on iOS.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two pill buttons that scale to 1.05 over 200ms on hover, one labelled without will-change and marked bad and one labelled with will-change and marked good._

When elements enter, **animate them in small groups** with a short delay between each group instead of animating one giant block.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Hero with a title, description and two buttons that replays its enter animation as one block, in staggered sections or word by word, picked with Block, Sections and Individual buttons._

Prevent elements from **animating on page load**, unless it's intentional.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two Changes saved toasts with a Reload page button that remounts both: the bad one fades, scales and slides up on every load while the good one is already in place._

Keep frequent interactions **instant or very fast**, like an item changing color when you hover it.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two lists of Inbox, Drafts, Sent, Archive and Trash to sweep the pointer over: the bad one fades its hover background over 500ms while the good one changes instantly._

## Typography

Always use `.woff2` **font files** on the web, never `.ttf` or `.otf`.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Static table of four font formats with name, support, a relative size bar and a usage pill: .woff2 is Use this, .woff is Fallback while .ttf and .otf are Avoid._

Use `font-variant-numeric: tabular-nums` in timers, counters, prices and tables. It gives every digit the same width which prevents layout shifts when the values change. Skip it if you're already using a monospace font.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): A counter running between 1000 and 1099 shown in Inter with proportional figures on the bad side and tabular-nums on the good side, started and paused with a play button._

Keep lines in articles and other long text to **60–75 characters**. Long form text that is wider than that is difficult to read.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Static figure of two placeholder paragraphs drawn as gray bars, the bad one running the full width of the card and the good one capped at 60% of it._

Use `text-wrap: balance` to **even out headings** and `text-wrap: pretty` on descriptions to prevent orphaned words. Use neither for long form text.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Default wrap next to a balanced title over a pretty description, starting at 220px wide, with a width slider from 140px to 300px and a toggle that hides the edge guides._

Keep **long words, links and IDs inside their container** with `overflow-wrap: break-word`. Use `white-space: nowrap` to prevent labels and badges from wrapping.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Static figure in two 160px pairs: a card where a long API key overflows above one that breaks it with break-word and a Last synced 2 min ago pill that wraps above one held on a line with nowrap._

Set `-webkit-font-smoothing: antialiased` and `-moz-osx-font-smoothing: grayscale` **on the root layout** to make text appear sharper.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Static side by side figure of a heading and paragraph rendered with subpixel antialiasing on the bad side and with antialiased smoothing on the good side._

Write text with **normal capitalization**. Use `text-transform` when you want to display it in uppercase or lowercase.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Static list of the phrase Typographic detail set four times with text-transform none, uppercase, lowercase and capitalize, each row labelled with its value._

Use **smart punctuation**: curly quotes, an en dash (–) for ranges, an em dash (—) for asides and an ellipsis (…) instead of three dots.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Static list of four rows, Quotes, En dash, Em dash and Ellipsis, each showing the typed characters on the left and the proper typographic mark on the right._

Keep **underlines from crossing the tails of letters** like g and y. Use `text-underline-position: from-font` with `text-decoration-skip-ink: auto`.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): The underlined phrase Typography enjoys gravity with a button that switches text-decoration-skip-ink between auto and none, which makes the line skip the descenders or run through them._

When you **shorten text with an ellipsis**, let people read the full text in a tooltip or an expanded view.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): A sentence clamped to two lines in a 200px column that shows its full text in a tooltip on hover, with a More button that expands it and turns into Less._

## Colors

**Every step** in a color palette should have a purpose: page background, component hover, border, solid fill, body text. Don't add steps that nothing uses.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Static list of gray-100 to gray-1200 where five steps carry a role, page background, component hover, border, solid fill and body text, with the other seven struck through._

Components should use **semantic tokens** (`--color-text-secondary`), never primitives (`--blue-500`). The primitive is the raw value, the token is how the value is used.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two static chains of token chips ending in a Subscribe button: the bad one goes straight from --blue-500 to the button while the good one passes through --color-accent-solid first._

Name color tokens by **purpose**: `--color-accent-solid` instead of `--color-blue-button` or `--color-sidebar-gray`.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Static table of three token chips with a verdict and a reason each: --color-accent-solid is good while --color-sidebar-gray and --color-blue-button with its violet swatch are bad._

Reserve `accent` **for the brand color** so `primary` never means both the brand and the main body text.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two static token lists for heading, body and button: the bad one gives heading and button the same sky --color-primary while the good one uses gray text tokens and keeps sky for --color-accent-solid._

Measure contrast against the background **directly behind an element**.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Gray text on a mid-gray card with a Text lightness slider from 0% to 100% that starts at 90% and live contrast ratios against the page and the surface, each marked pass or fail at 4.5:1._

Create a separate color palette **for dark mode** instead of inverting the light mode palette.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two static dark Weekly digest cards with a Subscribe button: the bad one puts white text and a white button on pure black while the good one uses a #1e1e1e card on #121212 with off-white text._

Choose **one way to switch themes**: `prefers-color-scheme` or a `.dark` class. Don't mix both.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two Account cards with a Dark theme switch that starts on: the left one darkens its surface but keeps its light theme text colors while the right one switches every token together._

You can define **how colors blend** in a gradient. Use `in oklab` for even brightness, `in oklch` for more vivid colors in the middle or `in srgb` for more muted midtones.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Three static tiles of the same pink to pale blue gradient interpolated in sRGB, oklab and oklch, each labelled with its color space._

## Accessibility

Use **native HTML elements**: `<button>` for buttons and `<a>` for links, for example. Native elements already have a lot of accessibility and other expected behavior built in.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two identical Link pills with an arrow icon, one built from a div with a click handler and one from an anchor, with a hint to try a middle click, a right click and a Cmd-click on each._

Style `:focus-visible` instead of `:focus`. Don't **remove the outline** without a replacement.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Three Outline buttons to tab through, labelled none, default and custom: the first shows no focus ring, the second the browser default and the third a 2px sky outline offset by 3px._

Only use `tabindex="0"` and `tabindex="-1"`. **Positive values change the expected order** of the elements.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two rows of buttons A to D that number each button in the order Tab reaches it: the bad row's focus order is C, A, B, D while the good row goes left to right._

Give **buttons that only have an icon** a descriptive `aria-label`. Never put `aria-hidden="true"` on an element that can be focused.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two identical magnifying glass icon buttons that speak their screen reader announcement aloud when clicked and print it below: the unlabeled one says button while the labeled one says Search, button._

Write **alternative text that explains the image's purpose and what it shows**. Give decorative images `alt=""`.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): The same close-up photo of a focus ring twice with its alt attribute printed over it: the bad one reads image while the good one describes the picture in a full sentence._

Give **every input a visible label** using `<label>`. Set its `type` and `inputmode` to match what people should enter.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two email fields above a strip of keyboard keys: the bad one has only an Email placeholder and letter keys while the good one has a visible label and keys that include @ and a dot._

**Never block paste.** People paste in things like passwords and one-time codes.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two One-time password fields and a Copy code button that copies 123456: the bad field rejects the paste and shows pasting is disabled while the good one accepts it._

**Keep the submit button enabled** until the request starts. Check for errors when people submit. Mark invalid fields with `aria-invalid="true"`, connect each error message with `aria-describedby` and move focus to the first invalid field.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): A Create account form with Name and Email address fields that validates only on submit, shows an error under each invalid field, focuses the first one and confirms Account created after 900ms when valid._

Make **hit areas** at least `24x24px`. Aim for `44x44px` on touch screens and `40x40px` on desktop where possible. Make sure they never overlap.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two 24px bell icon buttons side by side, the bad one clickable only on itself and the good one with a 44px hit area drawn as a dashed blue square around it._

Use `pointer-events: none` on **decorative elements** like glows and gradients so events are never swallowed.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): A Save changes button with a press counter under a decorative glow that overlaps its right side and swallows clicks there until a checkbox sets pointer-events: none on the glow._

Put hover styles inside `@media (hover: hover)`. On touch screens, `:hover` **stays active after a tap** and makes an item look selected.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two Bookmark buttons and a Simulate click button that plays a 400ms tap on both: the bad one keeps its hover background afterwards while the good one clears it when the press ends._

**Respect people's reduced motion setting.** Put animations inside `@media (prefers-reduced-motion: no-preference)` so they only play for people who don't have motion reduced.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two Options menus with New folder, Get info, Sort by and Show view options plus a Reduced motion switch: the bad one always scales and slides in while the good one only fades when the switch is on._

Use `role="status"` to **announce routine updates to screen readers**. Save `role="alert"` for urgent errors.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): A Copy link button that copies the page address, swaps its icon to a check, shows a Link copied pill above it and speaks the same words aloud._

**Never use color alone** to show a status change. Add an icon, a label or an underline too.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two Email address fields share one editable value that starts as hello@: the bad one only turns its outline red while the good one adds an icon and the message Enter a valid email address._

## Layout

Use `scroll-margin-top` to **leave space above headings** when people follow links to them.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two scrollable mock pages with a sticky 40px header and a Pricing link that scrolls to its heading: the bad one hides the heading under the header while the good one clears it with a 56px scroll margin._

Leave **at least twice as much space between groups** as between items in a group. For example, use `8px` between items and `16px` or more between groups.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two settings cards with Notifications and Privacy groups of switches: the bad one spaces every row 8px apart while the good one keeps 8px inside a group and 20px between groups._

## Writing

Start button labels with a **verb**: "Save draft" or "Delete project", never "OK!" or a bare "Yes".

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two Save your changes? dialogs with the same body text: the bad one offers OK! and Yes while the good one offers Cancel and Save draft._

Make confirmation buttons **say what will happen**: "Delete project" next to "Cancel".

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two Delete this project? confirmations with the same body text: the bad one offers No and Yes while the good one offers Cancel and a red Delete project button._

Use **the same label to move to the next step** throughout a flow. Choose "Continue" or "Next" and use it for every step.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two three-step wizards with a button per step: the bad one labels them Continue, Next and Proceed while the good one says Continue on all three._

**Describe where a link goes**.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two sentences that end in to learn more: the bad one underlines Click here as the link while the good one underlines Read the docs._

Capitalize buttons, headings and labels **the same way everywhere**. Sentence case, like "Save changes", is the safer default.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two settings cards with a heading, subtitle, email field and two buttons: the bad one mixes SETTINGS, Title Case labels and a lowercase delete project while the good one uses sentence case throughout._

Label toggles with **what happens when they're on**: "Send read receipts", not "Disable read receipts".

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two switches that are both on: the bad one is labelled Disable read receipts while the good one is labelled Send read receipts._

When a view is empty, **explain what belongs there** and give people one action to get started instead of nothing.

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two empty states: the bad one is the line No results alone while the good one has an icon, the title No projects yet, a line on what projects are for and a Create a project button._

Address the reader as **"you"**, not "the user".

_[Interactive demo](https://interfaces.dev/magazine/issues/cheat-sheet): Two info notes: the bad one reads The user will receive an email while the good one reads You'll receive an email._
