Book a callGitHub224

Craft02/05

UX patterns, compared

Updated · Suggest a change

Each pattern is shown twice: once working against people, once working for them. Many drawings are live, so hover, press or tab through them.

Every rule here is an OpenDesigner house standard or accessibility floor, applied in every project. Most come from Emil Kowalski's writing on Sonner, his toast library, and Vaul, his drawer library, and from his emilkowalski/skills repo. OpenDesigner is not affiliated with him.

Toasts: where they sit and how long they stay

A toast is a short message that appears for a moment and goes away on its own, such as "Link copied".

ToastThe ruleStandard
WhereOne corner, bottom-right by default; only the four corners or the top or bottom centerSTD-components-toasts-drawers-29
Edge distance32 px, or 16 px on screens under 600 px wideSTD-components-toasts-drawers-30
How manyThree at most. Each one behind sits 14 px higher and 5% smaller; on hover the stack spreads with 14 px gaps that stay part of the hover areaSTD-components-toasts-drawers-14, STD-components-toasts-drawers-10, STD-components-toasts-drawers-12, STD-components-toasts-drawers-13
Stack motionSonner's transform 400ms ease: longer than the 300 ms limit, allowed for this componentSTD-easing-duration-13
How long4 seconds, paused while the pointer is over it or the tab is hidden, so people don't lose a message they're readingSTD-components-toasts-drawers-15, STD-components-toasts-drawers-16, STD-components-toasts-drawers-17
With an action, such as UndoStays until it's used or closed, so the action has no time limit (OpenDesigner's inference from WCAG's Timing Adjustable rule)STD-components-toasts-drawers-15

Every toast on screen, and an Undo on a timer

Five messages cover the page. The one with an action closes itself, so a slow reader loses the chance to undo.

Message archivedUndocloses in 4 s
Draft saved
2 files uploaded
Invite sent
Settings updated

Three at most, stacked, and Undo waits for you

Toasts stack in one corner with depth. Hover or focus the stack to spread it out. The toast with an action stays until you use it or close it.

Message archived
bottom-right · 32 px from the edges, 16 px under 600 px widegap 14 px · 400 ms ease, Sonner's timing
Two ways to show five quick messages. On the left, every toast is on screen and the one with Undo closes after 4 seconds. On the right, at most three stack in the bottom-right corner, each one behind lifted 14 px and scaled down by 0.05, and the toast with an action stays until the person acts.

Source: the Sonner docs and Emil Kowalski's essay Building a toast component.

Swipe to dismiss: speed counts, not only distance

Dismiss when the swipe goes far enough or fast enough. Speed is the distance moved divided by the milliseconds since the drag began; above 0.11 the element goes, however short the swipe. (STD-springs-gestures-21) Let people swipe it back toward the edge it came from. (STD-components-toasts-drawers-18, STD-enter-exit-origin-06)

Only distance counts

A quick, short flick never reaches the line, so the toast springs back. People have to drag all the way past the line.

quick flick, short of the linesprings back
const d = Math.abs(swipeAmount);
if (d >= SWIPE_THRESHOLD)
  dismiss();

Distance or speed

The same quick flick is fast enough, so the toast leaves along the way it was pushed. Dragging past the line still works too.

the same quick flickdismissed
const d = Math.abs(swipeAmount);
const v = d / timeTaken;
if (d >= SWIPE_THRESHOLD
    || v > 0.11) dismiss();
Two toasts flicked to the right, quickly and only a short way. Judged by distance alone, the flick falls short of the dashed line and the toast springs back. Judged by distance or speed, where speed is the distance divided by the milliseconds since the drag began, a speed over 0.11 dismisses it.

Source: Emil Kowalski's Building a toast component and Building a drawer component.

No animation on keyboard actions

Never animate an action started from the keyboard: shortcuts, opening a command menu (a search box of actions, often Cmd K) or moving a highlight with the arrow keys. People repeat these hundreds of times a day, and any motion lags behind their fingers. (STD-when-to-animate-06) The same goes for anything used 100 or more times a day (Should it move at all?). (STD-when-to-animate-05) When a review finds one animated, delete the animation before trying to tune it. (STD-when-to-animate-17)

The highlight glides after each key

Watch the key and the highlight. Every press starts a 200 ms slide, so the highlight trails behind your fingers.

transition: transform 200ms on each key

The highlight moves with the key

No transition at all. The highlight is on the next row in the same frame as the key press.

no transition: 0 ms
The ring on the arrow key marks each press, four presses 300 ms apart.Reduced motion is on, so both highlights rest on the last row.
A command menu moved through with the arrow key. With a short slide on each press, the highlight lags behind the keys; with no transition it lands on the next row in the same frame. Anything started from the keyboard, and anything used a hundred times a day, should not animate.

Source: Emil Kowalski's You don't need animations and the animate and review-animations skills in emilkowalski/skills.

Tooltips: only the first one waits

Delay the first tooltip, then open its neighbors at once, with no delay and no animation; the toolbar feels faster. In Base UI that is transition-duration: 0ms on tooltips marked [data-instant]. (STD-enter-exit-origin-10) A tooltip scales out of its trigger from scale(0.97) and opacity 0, over 125 ms on the house ease-out curve. (STD-enter-exit-origin-09)

Every tooltip waits

Point at one button, wait, then slide along the row. Each tooltip makes you wait again, so reading the toolbar is slow.

each: waits, then 125 ms in

Try it with a mouse, or with the Tab key.

Only the first one waits

Point at one button, wait, then slide along the row. Once one tooltip is open, the next opens with no delay and no animation.

first: waits, then 125 ms in · next: 0 ms

Try it with a mouse, or with the Tab key.

Two real toolbars. In the first, every tooltip waits before it appears. In the second, only the first one waits, to avoid opening by accident; after that, neighboring tooltips open with no delay and no animation, so the whole toolbar feels faster.

The demo waits 500 ms before the first tooltip; the standards don't fix that delay.

Source: Emil Kowalski's 7 practical animation tips and the animate recipes in emilkowalski/skills.

Errors: next to the field, before submit

Check form input inline, not on submit, so the interface feels like it is listening. (STD-visual-details-49) Never show an error with color alone: add an icon or words, so people who can't tell the colors apart still see it. This is an accessibility floor.

An alert after you press the button

The mistake shows up only on submit, in a dialog that covers the form and does not say which field is wrong.

A message under the field, as you go

The field is checked inline, not on submit. The message sits next to the problem and uses an icon as well as color.

The same sign-up mistake shown two ways. An alert after submit hides the form and names no field. An inline check before submit puts the message right under the problem, with an icon so it does not rely on color alone.

Source: Emil Kowalski's 7 practical animation tips and the apple-design skill in emilkowalski/skills.

Undo instead of "Are you sure?"

Offer Undo for slips, and confirm only destructive actions that can't be undone. Dialogs shown too often train people to click straight through them. (STD-visual-details-40) For a destructive action, a hold-to-confirm button is one option. (STD-components-toasts-drawers-77)

“Are you sure?” for something you can undo

Archiving can be reversed, yet it asks every time. Asked that often, people learn to click through without reading.

Do it, then offer Undo

The conversation is archived at once. A toast offers Undo and stays until the person uses it or closes it.

Archiving a conversation, a slip that can be reversed. A confirmation dialog every time trains people to click through it. Doing it at once and offering Undo in a toast that waits for the person is faster and safer; keep confirmation for actions that cannot be undone.

Source: the apple-design skill in emilkowalski/skills.

Drawers on phones

On a phone, show secondary content in a drawer from the bottom edge (a bottom sheet) instead of a centered dialog. (STD-components-toasts-drawers-37) It moves from translateY(100%) over 500 ms on cubic-bezier(0.32, 0.72, 0, 1), a curve from the Ionic Framework close to the iOS sheet, and a spring takes over once a finger drags it. (STD-enter-exit-origin-41, STD-components-toasts-drawers-40)

Never trap people. A drawer closes with a drag down, a tap outside or Escape; one that must stay open gets a visible close button. (STD-accessibility-motion-24, STD-components-toasts-drawers-39)

A desktop dialog on a phone

A small box floats in the middle of the screen, the way it would on a desktop. On a phone it does not feel native.

A drawer from the bottom edge

It rises from the bottom edge on the iOS-like drawer curve. A drag down, a tap outside or Escape closes it.

500 ms · cubic-bezier(0.32, 0.72, 0, 1)
Reduced motion is on, so the drawer stays open.
Secondary content on a phone, shown two ways. A centered desktop-style dialog feels out of place. A bottom drawer rises from the edge in 500 ms on the drawer curve, which closely matches the iOS sheet, and can be closed by dragging, tapping outside or pressing Escape.

Source: Emil Kowalski's Building a drawer component and the Vaul docs. Vaul's README says it is no longer maintained, so OpenDesigner says so before suggesting it as a dependency.

Hover only where there is a mouse

Put every hover style inside @media (hover: hover) and (pointer: fine). Touch screens fake hover: the first tap applies the hover style and leaves it there. :active is a real press on touch, so it stays outside the query. (STD-accessibility-motion-15) Detect touch by what the device can do, not its name or screen width: laptops have touch screens and tablets have trackpads. (STD-mobile-touch-02)

Hover styles for every device

Phones have no hover, so the browser fakes one: the first tap applies the hover style and leaves it there until you tap somewhere else.

tapped once: the row stays lit
.row:hover {
  background: var(--accent-soft);
}

Hover only where there is a fine pointer

The hover style applies only when the main input can hover and point precisely. The press style is a real press on touch, so it stays ungated.

@media (hover: hover)
   and (pointer: fine) {
  .row:hover {
    background: var(--accent-soft);
  }
}

.row:active {
  transform: scale(0.97);
}
A hover style on a phone sticks after the first tap, because touch screens fake a hover. Gating every hover rule behind hover: hover and pointer: fine keeps it for mice and trackpads, while the :active press style stays for everyone.

Source: the mobile-native and animate skills in emilkowalski/skills.

Loading spinners

No house standard chooses between skeleton screens and spinners, so this guide doesn't either. Spinners spin fast and at a constant speed (Keep it short). (STD-easing-duration-15, STD-easing-duration-01)

Where these rules come from

The standards file lists each standard with its sources, and Who OpenDesigner learns from describes every source.