Skip to content

Toast

Call toast() from anywhere. The newest sits in front with the rest peeking behind; hover or focus fans them out and pauses every timer, as does leaving the tab. Swipe one away and the spring keeps the swipe's speed. toast.promise shows nothing for a request that settles inside 400ms, so a fast save never flashes a loading toast. Each is announced through a live region, errors assertively, and F8 reaches them from the keyboard. Toasts with an action wait to be dismissed.

  • aria-live
  • Popover API
  • Spring Physics
  • Latency states

A fast save shows only “Saved”: nothing flashes for a request that finishes in under 400ms. Hover the stack to fan it out and pause every timer. Swipe one sideways to dismiss it. Press F8 to reach the toasts from the keyboard.

    Usage

    Drop it in

    import
    import { Toaster } from "@/app/lib/components/toast";
    example 1
    <Toaster />
    toast.success("Saved");
    toast("Moved to archive", { action: { label: "Undo", onClick: restore } });
    toast.promise(save(), { loading: "Saving…", success: "Saved", error: "Could not save" });

    API

    Props

    PropTypeDefault
    position

    The corner it stacks in. Default: "bottom-right"

    "bottom-right" | "bottom-left" | "top-right" | "top-left""bottom-right"
    visible

    How many show in the collapsed stack. Default: 3

    number3
    hotkey

    Key that moves focus to the notifications, so keyboard users can reach an action. Default: "F8"

    string"F8"
    label

    Accessible name of the region. Default: "Notifications"

    string"Notifications"

    Read from the component's source at build time. * required.

    Accessibility

    Works with

    Cursor
    Reacts to where the pointer is, not just whether it's over the element.
    Touch
    Follows your finger while it's down, then settles a moment after you lift.
    Keyboard
    Focus lights it up the way the cursor does. Every action has a key.
    Reduced motion
    Nothing moves or springs. Colour still answers, without drifting.