Toast
macOS notifications: glass banners at the top right that slide in and stack.
"use client"
import { Button } from "@/components/ui/button"
import { toast, Toaster } from "@/components/ui/toast"
// Notifications slide in at the top right and stack; hover one to see all.
export default function ToastDemo() {
return (
<Toaster>
<div className="flex flex-wrap justify-center gap-2">
<Button
variant="secondary"
onClick={() => toast.add({ title: "AirDrop", description: "John Appleseed would like to share “Roadmap.key”.", type: "info" })}
>
Show Notification
</Button>
<Button
variant="secondary"
onClick={() => toast.add({ title: "Backup Complete", description: "Time Machine finished backing up to Archive.", type: "success" })}
>
Success
</Button>
<Button
variant="secondary"
onClick={() =>
toast.promise(new Promise((resolve) => setTimeout(resolve, 2000)), {
loading: { title: "Downloading macOS 27.1…", description: "About 8 minutes remaining." },
success: { title: "macOS 27.1 is ready", description: "Restart to install the update." },
error: { title: "Download failed" },
})
}
>
Download
</Button>
</div>
</Toaster>
)
}Installation
pnpm dlx shadcn@latest add @cupertinoui/toastThe first install also adds the macOS theme. See Installation to set up the registry.
Usage
import { toast, Toaster } from "@/components/ui/toast"
// Once, around your app:
<Toaster>{children}</Toaster>
toast.add({ title: "Backup Complete", description: "…", type: "success" })Built on Base UI's Toast: hover the stack to expand it, swipe a notification away, and use toast.promise for work that finishes later. type picks the symbol: success, info, warning, error or loading.
API Reference
Every part forwards the props of the underlying Base UI Toast part. The props below are the ones CupertinoUI adds or changes.
Toaster
| Prop | Type | Description |
|---|---|---|
toastManager | ToastManagerDefault: toast | The manager that toast.add talks to; make more with createToastManager. |
limit / timeout | number | How many show at once, and how long each stays. |
className | string | Extra classes, merged with the component's own. |