Lesson 18 of 30
A toast that vanishes in four seconds is a race the user can lose. Picking the right notification pattern — toast, banner, or inline — is really a decision about how important and how actionable the message actually is.
10 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A toast says "Item deleted. Undo?" and auto-dismisses after 4 seconds. What's the actual problem with this design?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
There are three common ways to tell a user something happened, and they earn different placement and duration based on how important and how actionable the message is:
type Toast = { id: string; message: string; kind: "info" | "error"; durationMs?: number };
function pushToast(toast: Toast) {
queue.push({
...toast,
// errors and anything requiring a decision get no durationMs — they stay until the user
// dismisses them. Only low-stakes confirmations auto-dismiss.
durationMs: toast.kind === "error" ? undefined : 4000,
});
}
An auto-dismissing toast is the wrong pattern for anything that needs the user to act — "Item deleted. Undo?" that vanishes after four seconds is a race the user can lose. If they're not looking at that exact moment, or need a second longer to read and decide, the option to undo is just gone, with no way back. Anything with a real decision attached (undo, retry, an error requiring acknowledgment) shouldn't have a timer at all; it should sit until the user dismisses it.
aria-live), independent of its dismiss timing — getting the auto-dismiss decision right doesn't automatically make the toast accessible; that's a separate requirement."A user says a toast disappeared before they could hit undo" is a real, common bug report, and the strong answer isn't "make the timer longer" — it's recognizing that anything requiring a decision shouldn't auto-dismiss at all, and naming the difference between a toast, a banner, and an inline notification as three genuinely different tools, not three names for the same thing.