Show a brief notice in the corner. Additional toasts stack behind the first, expand on hover, and dismiss with a downward or rightward swipe.
tsx
"use client"import { Button } from "@/components/ui/button"import { toast } from "@/components/ui/toast"export function Example() { return ( <Button variant="outline" onClick={() => { const id = toast.add({ title: "Event created", description: "Sunday, December 3 at 9:00 AM", actionProps: { children: "Undo", onClick() { toast.close(id) }, }, }) }} > Show Toast </Button> )}Installation
npx @arctis-sh/@arctis-sh/ui@latest add toastAdd Toaster near the root of your app.
import { Toaster } from "@/components/ui/toast"export default function Layout({ children }) { return ( <html lang="en"> <body> <Toaster>{children}</Toaster> </body> </html> )}Usage
import { toast } from "@/components/ui/toast"toast.add({ title: "Event created", description: "Sunday, December 3 at 9:00 AM",})Types
Set type to show a success, info, warning, or error icon. The loading type is used by toast.promise.
tsx
"use client"import { Button } from "@/components/ui/button"import { toast } from "@/components/ui/toast"export function Example() { return ( <> <Button variant="outline" onClick={() => toast.add({ description: "Event has been created." }) } > Default </Button> <Button variant="outline" onClick={() => toast.add({ type: "success", description: "Event has been created.", }) } > Success </Button> <Button variant="outline" onClick={() => toast.add({ type: "info", description: "Arrive 10 minutes before the event.", }) } > Info </Button> <Button variant="outline" onClick={() => toast.add({ type: "warning", description: "The event cannot start before 8:00 AM.", }) } > Warning </Button> <Button variant="outline" onClick={() => toast.add({ type: "error", description: "The event could not be created.", priority: "high", }) } > Error </Button> </> )}Action
Pass actionProps to add a small outline button that matches the close control's height.
tsx
"use client"import { Button } from "@/components/ui/button"import { toast } from "@/components/ui/toast"export function Example() { return ( <Button variant="outline" onClick={() => { const id = toast.add({ title: "Event created", actionProps: { children: "Undo", onClick() { toast.close(id) }, }, }) }} > Show Toast </Button> )}const id = toast.add({ title: "Event created", actionProps: { children: "Undo", onClick() { toast.close(id) }, },})Promise
Use toast.promise to move one toast from loading to success or error.
tsx
"use client"import { Button } from "@/components/ui/button"import { toast } from "@/components/ui/toast"export function Example() { return ( <Button variant="outline" onClick={() => { toast.promise( new Promise<{ name: string }>((resolve) => { window.setTimeout(() => resolve({ name: "Event" }), 2000) }), { loading: "Creating event…", success: (data) => `${data.name} created.`, error: "Could not create event.", }, ) }} > Create Event </Button> )}API Reference
toast
| Method | Type | Description |
|---|---|---|
| add | (options) => string | Create a toast and return its id |
| close | (id?: string) => void | Dismiss one toast, or all if no id |
| update | (id, options) => void | Patch an existing toast |
| promise | (promise, options) => Promise | Drive loading → success/error |
toast.add({ title: "Saved" })toast.add options
| Prop | Type | Default |
|---|---|---|
| title | ReactNode | — |
| description | ReactNode | — |
| type | "success" | "info" | "warning" | "error" | "loading" | string | — |
| timeout | number | 5000 |
| priority | "low" | "high" | "low" |
| actionProps | button props | — |
| onClose | () => void | — |
| onRemove | () => void | — |
toast.add({ title: "Saved", description: "Your changes were stored.", type: "success",})toast.promise options
| Prop | Type | Default |
|---|---|---|
| loading | string | options | — |
| success | string | options | (data) => … | — |
| error | string | options | (error) => … | — |
toast.promise(save(), { loading: "Saving…", success: "Saved", error: "Something went wrong",})Toaster
| Prop | Type | Default |
|---|---|---|
| timeout | number | 5000 |
| limit | number | 3 |
| toastManager | ToastManager | shared manager |
| children | ReactNode | — |
Hover or focus the viewport to expand the stack. Toasts beyond limit stay mounted with data-limited, allowing them to fade instead of disappearing at once.
<Toaster timeout={5000} limit={3} />