ComponentsOverlays & feedback

Toast

Reports the result of an action without interrupting: "Post published · View", "Moved to trash · Undo". Six tones with a thin status edge, actions, in-place updates by id, promise tracking, and a stack where only the front toast blurs.

sonner (wrapped — import only from the kit) components/toast.tsx, styles/overlays.csstheme · material · accent · density · font

Installation

$ pnpm add @vamos-ui/react

The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";

Usage

import { toast, Toaster } from "@vamos-ui/react";

// once, near the app root (App shell already includes it)
<Toaster />

toast.success("Post published", { action: { label: "View", onClick: openPost } });

Critical information ("Couldn't save") must not live only in a toast — show an inline Alert too.

Only the first mounted Toaster renders, so a page-level one next to the App shell's never doubles toasts.

Import toast from @vamos-ui/react, never from the engine package, so it can be swapped later.

Examples

Undo (CRM)

A toast with an action stays at least 6 seconds. Undo should fully reverse the change.

  • Elif Demir
  • Can Yıldız
  • Ayşe Kaya
  • Mert Aksoy

Promise

toast.promise shows loading, then success or danger in the same toast, and returns the original promise.

Progress by id

Reuse the id to update one toast in place — a long export ends in a Download action.

API

toast(title, options) · toast.success · .info · .warning · .danger · .loading

PropTypeDefault
title
Short past-tense result ("Leave approved").
ReactNode—
description
One line of detail.
ReactNode—
action
One follow-up ("Undo", "View").
{ label: ReactNode; onClick: () => void }—
cancel
A secondary, dismissing button.
{ label: ReactNode; onClick?: () => void }—
duration
neutral, success, info 4 s · warning 6 s · danger 8 s · loading until updated. Infinity keeps it.
number4000 / 6000 / 8000 / ∞
id
Same id updates the toast in place.
string—
important
Announce assertively (role="alert"). Danger toasts always are.
booleanfalse
closeButton
× on this toast.
booleanfalse
onDismiss / onAutoClose
Lifecycle callbacks.
() => void—
→ returns
The toast id.
string—

toast.promise(promise, messages)

PropTypeDefault
loading
Shown while pending.
ReactNode—
success
Shown on resolve.
ReactNode | (data) => ReactNode—
error
Shown on reject.
ReactNode | (error) => ReactNode—
→ returns
The original promise (handle its rejection).
Promise<T>—

toast.dismiss(id?)

PropTypeDefault
id
Dismiss one toast, or all without an id.
string—

Toaster

PropTypeDefault
position
Logical — end is the left edge in RTL.
"bottom-end" | "bottom-start" | "bottom-center" | "top-end" | "top-start" | "top-center""bottom-end"
mobilePosition
Below 640px, away from the keyboard and bottom bars.
same"top-center"
max
Visible toasts before they stack.
number3
expand
Always show the stack expanded.
booleanfalse
closeButton
× on every toast.
booleanfalse
hotkey
Focuses the toast region.
string[]["altKey", "KeyT"]
offset
Distance from the viewport edge.
number | string24px
labels
Dictionary namespace "toast".
{ region?: string; close?: string }—