Skip to content

Toast and status message patterns for shadcn

Rules / Feedback: 4 rules and 0 guidelines

After people press a button, they need to know what happened. Did it work? Did it fail, and why? In many shadcn apps the answer is a toast in the corner of the screen. shadcn’s toast component is a thin wrapper around Sonner, and it is quick to add and looks good. A toast is also easy to miss: by default Sonner closes it after four seconds, it appears far from where the person was looking, and someone using a screen magnifier may not have that corner in view at all. The rules here put each result where it belongs, so a toast can be an extra signal without being the only one.

Where feedback goes wrong

  • “Something went wrong” in a toast that disappears before it has been read, while the form that failed looks exactly as it did before. FBK-002
  • A success toast as the only sign that a save worked, with nothing in the view changed. FBK-003
  • A status message that is visible but silent to a screen reader, or one that grabs focus and pulls the person away from what they were doing. FBK-004
  • A toast with Undo, View and Retry that closes on a timer before anyone can choose. FBK-005

How the rules fit together

Two rules say where results go. A failure that is not about one field is shown as text in the area where the action started, and it stays until the person closes it, a retry succeeds or they leave the view (FBK-002). A success shows in the view itself: the renamed file has its new name, the archived row is gone or marked. If the result has no place on screen, leave a lasting sign that the person can come back to (FBK-003). An error about a single field belongs at that field, as the form patterns say (FRM-002a).

FBK-004 is about how messages reach people who cannot see them. A message that appears while focus stays where it is needs a role or property, such as a live region, so that assistive technology reads it out without moving focus.

FBK-005 sets limits for the toast itself: at most one action besides close, no timer while that action is offered, and the same action available somewhere that lasts. That is what makes an Undo in a toast safe to rely on, which the destructive action patterns do (DST-001a).

The words of each message follow TXT-001a: what went wrong, what it concerns and what to do next. While an action is still running, the loading state patterns apply; they also cover what a list says when it comes back empty. An animation, such as a shake or a bounce, may draw the eye to a result, but it is never the only sign of it (VIS-007).

A quick check for any screen: do the action, then look away for ten seconds. If you cannot tell from the screen what happened when you look back, the result needs a place in the view.

What WCAG requires and what the judges decide

FBK-004 restates a requirement of WCAG 2.2: 4.1.3 Status Messages. Its choice of a polite live region, with role="alert" kept for errors that need attention now, is marked on the rule as our own way of meeting it.

The other three are decided by the judges, and none of the judges who spoke opposed them. All three supported keeping a failure where it started and showing a success in the view, and both who spoke supported the limits on toasts. These rules also support 2.2.1 Timing Adjustable, since a message on a timer gives people a limited time to read it.

Rules and guidelines

Each one has its own page with the full rule, Do and Don't cases, exceptions and the verdict. A rule is decided by WCAG 2.2 or by the judges. A guideline is our own choice. How the method works

Required by WCAG 2.2

A WCAG 2.2 Level AA criterion requires the behaviour. Where a rule adds advice of its own, it says so.

  • FBK-004 Announce a status message without moving focusRule. Requirement. Decided.When a message about a result, a wait, progress or an error appears while focus stays where it is, give it a role or property that lets assistive technology announce it without it taking focus. Our own way, which WCAG does not prescribe, is a polite live region, with role="alert" kept for an error or warning that needs attention now.

Decided by the judges

No WCAG criterion requires these. The judges who spoke support them, all or most of them.

All rules · Is shadcn accessible? · Give the rules to an AI agent

Justified by Blackwood & Blake helps you work toward WCAG 2.2 AA. It is not a certification. Read more