Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

Feedback after an action

Confirm every action where it happened, briefly, and offer Undo instead of asking for confirmation first.

  • Payslip for September
  • Team offsite agenda

The problem

When nothing visible changes after a press, people press again, and now there are two requests. When everything changes at once, they can't tell what their action did. And modal “Success!” dialogs interrupt for no reason.

When to use it

Use it for

  • Actions whose result isn't obvious on screen: sending, saving, archiving, copying.
  • Reversible actions: pair the toast with Undo.

Not for

  • The result is visible already, like a toggle switching on: no toast needed.
  • Errors the person must fix: use an inline Alert or a field error, which don't time out.
  • Anything that needs a decision: use a Dialog.

Anatomy

  1. Toast regionOne per app, rendered by ToastProvider. It stacks up to three toasts.
  2. TitleWhat happened, in the past tense: “Message archived”.
  3. Tonesuccess, danger, info or loading. The icon carries it, the text says it.
  4. ActionOne button, usually Undo. Keeps the toast up for at least 8 seconds.

How to build it

  1. Wrap your app in ToastProvider once, and call useToast() wherever you act.
  2. Do the action straight away, then add a toast saying what happened.
  3. For reversible actions, add action: { label: "Undo", onAction } and keep what you need to restore.
  4. For slow work, add a loading toast and replace it with the result.
  5. Keep titles short; add a description only when there is more to say.
app.tsx
import { Button, ToastProvider, useToast } from "@nexera-ui/react";

// once, near the root
<ToastProvider>
  <App />
</ToastProvider>;

// anywhere below
function ArchiveButton({ message }: Props) {
  const toasts = useToast();
  return (
    <Button
      onPress={() => {
        archive(message.id);
        toasts.add({
          title: "Message archived",
          action: { label: "Undo", onAction: () => restore(message.id) },
        });
      }}
    >
      Archive
    </Button>
  );
}

Accessibility

Keyboard support
KeyAction
F6Moves focus to the toast region and back.
TabMoves between a toast's action and close button.
EscapeCloses the focused toast.
  • Toasts are announced through a live region: polite by default, assertive for danger.
  • Timers pause while the toast is hovered or focused, and are never shorter than 5 seconds (WCAG 2.2.1).
  • Toasts with an action stay at least 8 seconds, so there's time to reach Undo.
  • Never put the only path to something important in a toast: it disappears.

Do and don't

DoAct immediately and offer Undo.

Don'tAsk “Archive this message?” first.

DoSay what happened: “3 requests approved”.

Don'tSay “Success!”.

DoShow errors that need fixing inline, next to the cause.

Don'tReport a failed save in a toast that vanishes after 5 seconds.