Skip to content

Toast

Short notifications in the corner. Several stack up with the newest in front and spread out on hover or focus. A swipe sideways dismisses one; they pause while hovered, can carry one action, and are read out politely.

On this page
Used for
  • Saved confirmation
  • Undo a delete
  • Run finished
  • Copy done

Examples

Installation

npx knowns-ui@latest add toast
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

title
ReactNode
Main line.
description
ReactNode
Muted second line.
tone
"neutral" | "success" | "warning" | "danger"
Default"neutral"
Colour of the leading dot.
action
{ label, onClick }
One button; clicking it also dismisses the toast.
duration
number
Default4500
ms before it hides; hovering pauses.

What it handles

  1. 01Mounts one ToastProvider and gives every component a toast function through useToast, which throws if the provider is missing.
  2. 02Takes a title, a description, a tone of neutral, success, warning or danger, and one action such as Undo that runs and then removes the toast.
  3. 03Hides each toast after duration (4.5 seconds by default), and pauses the timer while the pointer is over it, then re-arms it for a short grace after leaving.
  4. 04Keeps at most four on screen in a stack at the bottom right, dropping the oldest when a new one arrives.
  5. 05Announces through an aria-live polite list, with a Dismiss button on each toast.
  6. 06Plays an exit before removing a toast, so it leaves the stack instead of vanishing.

States

First render
Nothing. The stack is empty until a toast is raised
none
Toast arrives
It fades in rising from 4px below
180ms, ease out
Toast leaves
It fades and sinks 4px, then leaves the list
120ms, ease out
Hover
The hide timer pauses and nothing moves
none
Reduced motion
It appears and leaves at once
0ms

Works with

When to use

When to use

  • Brief confirmations and background results such as Saved or Run finished, with an optional action.

When not to use

  • Errors the user must fix in a form: show them by the field: use Input.
  • Decisions: use Dialog.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Toast to my app and wire it to my own data.
  • I need brief confirmations and background results such as Saved or Run finished, with an optional action. Set that up with the Knowns UI Toast.
  • Which Toast props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "toast" }) and search_docs({ query: "toast" }).

Need help?

Stuck on Toast, or found something off? We read every message.