Interface Cheat Sheet

User Interface

  • When nesting elements, make their border radius concentric. The outer radius equals the inner radius plus the padding between the elements.
    Not recommended
    Recommended
  • Prioritize optical alignment over geometric alignment.
    Not recommended
    Recommended
  • A button with text and an icon gets slightly smaller padding on the side of the icon.
    Not recommended
    Recommended
  • Use a layered box-shadow to give elements depth instead of using borders.
  • Give images a 1px outline, offset by -1px: black at 8% opacity in light mode, white at 8% in dark mode.
    Sea at daytime
  • Match the icon’s stroke to the text next to it.
    Not recommended
    Recommended

Animation

  • Make elements animate from the trigger rather than the center. Set transform-origin based on the trigger’s position.
  • For menus people open often, skip the opening animation and only animate when they close.
    Right-click in each area
    Enter and exit
    Not recommended
    Exit only
    Recommended
  • Make exit animations more subtle than entrances. Move the element by a shorter distance as it fades out with opacity and a 4px blur.
    Not recommended
    Recommended
  • Name the exact properties you want to animate in a transition. Never use transition: all.
    Not recommendedtransition-all
    Recommendedtransition-colors
  • Make buttons scale down slightly when pressed. Use a scale between 0.95 and 0.98 with transition: scale 200ms ease-out.
    Not recommended
    Recommended
  • 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.
  • Use CSS transitions for interactions so the animation can change direction halfway through. Use keyframes for sequences that only run once.
    Not recommended
    Recommended
  • Disable all transitions when switching between light and dark mode.
    AppearanceSyncs with your system.
    Save
    Not recommended
    AppearanceSyncs with your system.
    Save
    Recommended
  • If an element randomly shifts by 1–2px while animating, add will-change: transform to it. This is especially useful in Safari on iOS.
    Hover me
  • When elements enter, animate them in small groups with a short delay between each group instead of animating one giant block.
    Build software that never breaks
    Interfere is the experience layer for modern product teams.
  • Prevent elements from animating on page load, unless it’s intentional.
    Changes saved
    Not recommended
    Changes saved
    Recommended
  • Keep frequent interactions instant or very fast, like an item changing color when you hover it.
    Not recommended
    Recommended

Typography

  • Always use .woff2 font files on the web, never .ttf or .otf.
    FormatNameUsage
    .woff2
    Web Open Font Format 2All modern browsers
    Use this
    .woff
    Web Open Font FormatLegacy fallback
    Fallback
    .ttf
    TrueTypeDesktop and old browsers
    Avoid
    .otf
    OpenTypeDesktop and old browsers
    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.
    1000
    Not recommended
    1000
    Recommended
  • Keep lines in articles and other long text to 60–75 characters. Long form text that is wider than that is difficult to read.
    Not recommended

    Lines that run the full width of a wide container, well past 75 characters.

    Recommended

    The same text with its measure capped, so each line stays between 60 and 75 characters.

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

    Designing interfaces that feel natural and intuitive

    Great design is invisible. It guides users without them ever noticing.

    Not recommended
    balance + pretty

    Designing interfaces that feel natural and intuitive

    Great design is invisible. It guides users without them ever noticing.

    Recommended
    Width220px
  • 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.
    break-word
    Not recommended

    Your API key ak_92hFqL7xVtN3mYc8RwJd5pZk is ready.

    Recommended

    Your API key ak_92hFqL7xVtN3mYc8RwJd5pZk is ready.

    nowrap
    Not recommended
    Last synced 2 min ago
    Recommended
    Last synced 2 min ago
  • Set -webkit-font-smoothing: antialiased and -moz-osx-font-smoothing: grayscale on the root layout to make text appear sharper.

    Subpixel rendering

    Default font smoothing uses subpixel antialiasing on macOS.

    Antialiased rendering

    Grayscale antialiasing produces thinner, crisper light text.

  • Write text with normal capitalization. Use text-transform when you want to display it in uppercase or lowercase.
    Typographic detailnone
    Typographic detailuppercase
    Typographic detaillowercase
    Typographic detailcapitalize
  • Use smart punctuation: curly quotes, an en dash (–) for ranges, an em dash (—) for asides and an ellipsis (…) instead of three dots.
    "web type"“web type”
    Quotes
    2010-20202010–2020
    En dash
    type - cleartype—clear
    Em dash
    loading...loading…
    Ellipsis
  • Keep underlines from crossing the tails of letters like g and y. Use text-underline-position: from-font with text-decoration-skip-ink: auto.
    Typography enjoys gravity
  • When you shorten text with an ellipsis, let people read the full text in a tooltip or an expanded view.

    Designing interfaces that feel natural and intuitive for everyone who uses them.

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.
    gray-100page background
    gray-200
    gray-300component hover
    gray-400
    gray-500border
    gray-600
    gray-700
    gray-800
    gray-900solid fill
    gray-1000
    gray-1100
    gray-1200body text
  • 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.
    --blue-500
    Not recommended
    --blue-500
    --color-accent-solid
    Recommended
  • Name color tokens by purpose: --color-accent-solid instead of --color-blue-button or --color-sidebar-gray.
    --color-accent-solid
    Recommended

    The name still makes sense when the color changes.

    --color-blue-button
    Not recommended

    It's called 'blue' even though the color is now violet.

    --color-sidebar-gray
    Not recommended

    Changing the sidebar color now changes it across the app.

  • Reserve accent for the brand color so primary never means both the brand and the main body text.
    heading
    --color-primary
    body
    --color-secondary
    button
    --color-primary
    Not recommended
    heading
    --color-text-primary
    body
    --color-text-secondary
    button
    --color-accent-solid
    Recommended
  • Measure contrast against the background directly behind an element.

    This text renders on the surface, not the page.

    page 1.3:1
    Not recommended
    surface 4.8:1
    Recommended
    Text lightness90%
  • Create a separate color palette for dark mode instead of inverting the light mode palette.
    Weekly digestFive links every Friday.
    Subscribe
    Not recommended
    Weekly digestFive links every Friday.
    Subscribe
    Recommended
  • Choose one way to switch themes: prefers-color-scheme or a .dark class. Don’t mix both.
    AccountSigned in as Ada.
    surface: .dark · text: media query
    Not recommended
    AccountSigned in as Ada.
    all tokens: .dark
    Recommended
  • 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.
    sRGB
    oklab
    oklch

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.
    Not recommended<div>

    This side is the same link built from a div with a click handler. Without an href the browser cannot open it in a new tab, offer it in the right-click menu, preview its address on hover or list it as a link.

    Recommended<a>
    Try a middle click, a right click and a Cmd-click on each one
  • Style :focus-visible instead of :focus. Don’t remove the outline without a replacement.
    Press Tab to move focus through the buttons
    Not recommendednone
    Recommendeddefault
    Recommendedcustom
  • Only use tabindex="0" and tabindex="-1". Positive values change the expected order of the elements.

    Tab through the buttons to record the order focus visits them.

    Not recommended

    Tab through the buttons to record the order focus visits them.

    Recommended
    Click in and press Tab to cycle through items
  • Give buttons that only have an icon a descriptive aria-label. Never put aria-hidden="true" on an element that can be focused.
    Not recommended
    Recommended
  • Write alternative text that explains the image’s purpose and what it shows. Give decorative images alt="".
    imagealt="image"
    Not recommended
    Close up of a focus ring curving around an element's rounded corneralt="Close up of a focus ring curving around an element's rounded corner"
    Recommended
  • Give every input a visible label using <label>. Set its type and inputmode to match what people should enter.

    This field only has a placeholder, which disappears as soon as you type and its text type brings up the generic keyboard on touch devices.

    Not recommended
    Recommended
  • Never block paste. People paste in things like passwords and one-time codes.
    Copy the code and paste it into both fields
    Not recommended
    Recommended
  • 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.

  • Make hit areas at least 24x24px. Aim for 44x44px on touch screens and 40x40px on desktop where possible. Make sure they never overlap.
    Not recommended
    Recommended
  • Use pointer-events: none on decorative elements like glows and gradients so events are never swallowed.

    Presses: 0

  • Put hover styles inside @media (hover: hover). On touch screens, :hover stays active after a tap and makes an item look selected.
    Not recommended
    Recommended
  • 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.
    Not recommended
    Recommended
  • Use role="status" to announce routine updates to screen readers. Save role="alert" for urgent errors.
  • Never use color alone to show a status change. Add an icon, a label or an underline too.

    Not recommended

    Enter a valid email address

    Recommended
  • Make the skip-to-content link the first stop when someone presses Tab.
    Skip to content

    Main content

Layout

  • Use scroll-margin-top to leave space above headings when people follow links to them.
    Click Pricing in each header

    Pricing

    Not recommended

    Pricing

    Recommended
  • 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.
    Notifications
    Email
    Push
    Privacy
    Profile
    Receipts
    Not recommended
    Notifications
    Email
    Push
    Privacy
    Profile
    Receipts
    Recommended

Writing

  • Start button labels with a verb: “Save draft” or “Delete project”, never “OK!” or a bare “Yes”.

    Save your changes?

    Your draft has edits that are not saved yet.

    Not recommended

    Save your changes?

    Your draft has edits that are not saved yet.

    Recommended
  • Make confirmation buttons say what will happen: “Delete project” next to “Cancel”.

    Delete this project?

    This removes the project and all of its files.

    Not recommended

    Delete this project?

    This removes the project and all of its files.

    Recommended
  • Use the same label to move to the next step throughout a flow. Choose “Continue” or “Next” and use it for every step.
    Step 1 of 3
    Step 2 of 3
    Step 3 of 3
    Not recommended
    Step 1 of 3
    Step 2 of 3
    Step 3 of 3
    Recommended
  • Describe where a link goes.

    Click here to learn more.

    Not recommended

    Read the docs to learn more.

    Recommended
  • Capitalize buttons, headings and labels the same way everywhere. Sentence case, like “Save changes”, is the safer default.

    SETTINGS

    Choose Where We Send Updates.

    Email Address
    Not recommended

    Settings

    Choose where we send updates.

    Email address
    Recommended
  • Label toggles with what happens when they’re on: “Send read receipts”, not “Disable read receipts”.
    Disable read receipts
    Not recommended
    Send read receipts
    Recommended
  • When a view is empty, explain what belongs there and give people one action to get started instead of nothing.

    No results.

    Not recommended

    No projects yet

    Projects keep your files, notes and tasks in one place.

    Recommended
  • Address the reader as “you”, not “the user”.

    The user will receive an email.

    Not recommended

    You'll receive an email.

    Recommended
interfaces.devinterface-cheat-sheet

Start building great interfaces today

Quality matters more than it ever has in software. If you care about craft, like to sweat the details and want to learn more about design engineering, I think you’ll enjoy the magazine.

Monthly
$7.99/ month
  • New issue every month

  • Resource library

  • Interactive demos

  • Source code

  • Agent skills

  • Private Discord community

Subscribe
Save 18%
Yearly
$79.99/ year
  • New issue every month

  • Resource library

  • Interactive demos

  • Source code

  • Agent skills

  • Private Discord community

Subscribe
Lifetime
$299/ one-time

Everything in Monthly and Yearly, plus:

  • Early access to new issues

  • Lifetime member badge

  • Vote on upcoming topics

Subscribe