Skip to content

Toast

Stable

A short message that appears at the edge of the screen and goes away by itself. Includes the provider and the useToast hook.

Also known as snackbar, notification, toast notification, flash message

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Each tone

    Neutral, success, info and danger. Every tone except neutral has an icon, and every toast has a title, so colour is never the only cue. A danger toast is announced straight away.

    When to use it

    Confirms a result without taking over the screen. It is for information the person can safely miss, so nothing important lives only in a toast.

    Made of: Region · Tone icon · Title · Description · Action button · Close button · Time-left bar (with an action)

    Use it for

    • Confirming a quick action: saved, copied, sent.
    • Offering Undo right after a delete.
    • Telling the person that something finished in the background.

    Not for

    • An error the person has to fix: use Callout.
    • An error that replaces a whole area: use ErrorState.
    • Asking the person to approve an AI action: use ApprovalPrompt.
    • Asking for permission before an AI uses a tool: use PermissionPrompt.
    • A choice that blocks the page until it is made: use Dialog.

    Do and avoid

    Trip saved

    Do. A quick note confirms the result and is safe to miss.

    Send 12 reminder emails?

    Avoid. An approval in a toast can vanish before anyone reads it.

    Do

    • Use it for results the person can safely miss.
    • Keep the title to a few words.
    • Leave duration out so it follows the content. Pass 0 for an action the person must not miss.
    • Use update to turn a Saving toast into Saved, instead of showing a second toast.
    • Mount ToastProvider once, near the root of the app.
    • Show an error on the page too when something failed.

    Avoid

    • Do not use a toast as the only place for an error or a needed decision.
    • Do not use it to ask for approval of an AI action.
    • Do not fire several toasts for one event.
    • Do not use it for long text. Use a Callout or a Dialog.
    • Do not use danger tone for ordinary results. Keep it for failures.

    On a phone

    • Toasts sit at the bottom edge, fill the width up to 384px, and stay above the bottom safe area.
    • Toasts pause their timer while the pointer is over them, while focus is inside, while a finger is held on the toast, and while the page is hidden, so touch the toast to keep a long message on screen.
    • The action and close buttons are 44px tall on a touch screen.
    • Up to three show at once, newest on top.

    Build your next AI screen with Tattva.

    Free and open, with the code. Start in one line.

    Get started