Craft02/05
UX patterns, compared
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".
| Toast | The rule | Standard |
|---|---|---|
| Where | One corner, bottom-right by default; only the four corners or the top or bottom center | STD-components-toasts-drawers-29 |
| Edge distance | 32 px, or 16 px on screens under 600 px wide | STD-components-toasts-drawers-30 |
| How many | Three 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 area | STD-components-toasts-drawers-14, STD-components-toasts-drawers-10, STD-components-toasts-drawers-12, STD-components-toasts-drawers-13 |
| Stack motion | Sonner's transform 400ms ease: longer than the 300 ms limit, allowed for this component | STD-easing-duration-13 |
| How long | 4 seconds, paused while the pointer is over it or the tab is hidden, so people don't lose a message they're reading | STD-components-toasts-drawers-15, STD-components-toasts-drawers-16, STD-components-toasts-drawers-17 |
| With an action, such as Undo | Stays 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.
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.
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.
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.
const d = Math.abs(swipeAmount);
const v = d / timeTaken;
if (d >= SWIPE_THRESHOLD
|| v > 0.11) dismiss();
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.
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.
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.
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.
Try it with a mouse, or with the Tab key.
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.
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.
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.
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.
.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);
}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.