Feedback

Toast, inline message or dialog: where a result is said depends on whether people have to do something about it.

Say a result where people will act on it. A toast for something done that needs nothing more, an inline message beside whatever needs fixing, and a dialog only when nothing may go on until it is answered.

Notes for the retry write-up

Like name@example.com.

Couldn't refresh the checks — showing saved data.
  • CI / Lintpassed
  • CI / Buildpassed
  • CI / Testfailed

Copy link, from a Mail conversation's menu, succeeds and asks for nothing, so a toast says so and goes away. Press Save profile: the email from the Settings demo's profile form is missing its domain, which is said under the field and stays until the field is fixed. The pull request's checks failed to refresh, so the warning sits above the list it could not update, with the one control that can fix it.

Do and don't#

Enter an email address, like alice@example.com.

Do

Put a validation error under its field, mark the field aria-invalid, and point aria-describedby at the message.

Don't

Send a validation error as a toast: it disappears before the field is fixed, and never says which field.

3 selected
Do

Toast "3 conversations archived" with an Undo action after a bulk change that can be reversed.

3 selected
Don't

Open a dialog to say that something worked. A dialog stops everything; success should not.

Which one#

What happenedNeeds people toUse
An action finished as expectedNothing; maybe undo ittoast(), toast.success(), with an action to undo
A control shows its own result where it was pressedNothingNo toast: CopyButton turns into a check; writeClipboard toasts only a failure
A copy came too late for the press that asked for itPress once moreThe copy offer: offerCopy, which writeClipboard and copyToClipboard raise themselves
Something finished in the background, out of viewKnow, maybe open ittoast() with an action that opens it
A field or a form is wrongFix that fieldAn inline message under the field
A surface failed to load and has nothing to showRetryLoadFailure in its place
A refresh failed but older data is still shownKnow the data is stale, retryRefreshFailure above the data
An action failed and the work is not savedDecide what to do with ittoast.error() with a retry, or inline if the place is on screen
A question waits in the flow of the page, or a run there endedAnswer it, or see how it endedA Frame with an intent, its lid saying the status, see Surfaces
Nothing may continue until a question is answeredChooseDialog, see Overlays

Each button ends in a toast, in the demos' words. Archive can be undone from it. Re-run failed jobs finishes out of view, and its error toast opens the run.

Couldn't load the conversations.

Mail's list failed to load and has nothing to show, so LoadFailure takes its place until Retry brings the conversations.

A message that stays has to be removable by fixing its cause, not by a close button; one that leaves by itself must not carry the only copy of something people need to read.

A control that shows its own result needs no toast as well.

T-6Dialog traps focus twice

Press Copy link: a CopyButton turns its icon into a check for a moment, and says "Link copied" to a screen reader. The eyes are already on the button, and a toast in the corner would only pull them away. Its failure still toasts, since the button cannot say why it failed.

  • Copy from a button on screen with CopyButton: a code block's Copy, a new token's Copy token, an install line's icon. Alone, the icon is named by aria-label, which its tooltip shows; give it words where the icon would not say what is copied.
  • Copy from a menu or a shortcut with copyToClipboard, which toasts the success: nothing on screen changes, and the menu is gone. A CopyButton that a toolbar moves into its ⋯ menu toasts there for the same reason.
  • A control of another kind that answers itself copies with writeClipboard from @orz/ui/lib/clipboard, which toasts only a failure. A component that reports the copy to its caller, as HexView's onCopy does, copies with writeClipboardQuietly, which says nothing.
  • Copy in the press itself. Text still on its way, such as bytes being read, goes to any of these as a promise, handed over inside the press. A page served over plain http from another machine has no Clipboard API, and the browser's copy command these fall back to works only for a moment after the press, about a second in WebKit.
  • A copy whose text came too late for its press is offered instead of failing: a toast, "Ready to copy", whose Copy button makes the copy in a press of its own. writeClipboard and copyToClipboard offer it themselves. A component that reports the copy calls offerCopy when writeClipboardQuietly answers "needs-press", and reports the offer's outcome; one closed unpressed was the reader's choice and reports nothing.

Writing the message#

  • Say what happened in the past tense, naming the thing: "Profile saved", "Couldn't load the conversations". Do not open with "Success!" or "Error:"; the icon already says which.
  • An error says what failed and, when it is known, the server's own words: LoadFailure and RefreshFailure take them as detail, which stays out of the sentence.
  • A message for one item names the item; a message for several counts them.

On each platform#

Desktop & pointer#

  • Toasts stack in a corner, out of the way of the work. Hovering one pauses its timer, so it can be read and its action taken.
  • A toast shows over every overlay and takes the pointer there too: pressing it, or its action, closes nothing beneath it.
  • A toast's action is reachable from the keyboard. Alt+T moves the focus to the toasts, from inside an open Dialog, Sheet, Popover or menu as well, and Tab past them, Escape or the action itself takes it back where it was. Still, anything that matters is also reachable where it happened, since a toast may be gone before focus reaches it.

Touch#

  • A toast covers part of a small screen. Keep it to one line, and swipe it away to dismiss.
  • An inline error must stay visible above the on-screen keyboard: put it directly under the field, not at the top of the form.

In the demos