Toast

A succinct message that appears temporarily to provide feedback.

Installation

pnpm dlx cubix@latest add toast --base radix

Add the Toaster

Place Toaster in your root layout so toasts can render from anywhere.

app/layout.tsx
import { Toaster } from "@/components/cubix/toast"

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <main>{children}</main>
        <Toaster />
      </body>
    </html>
  )
}

Usage

Import
import { toast } from "@/components/cubix/toast"
Example
toast.add({
  title: "Event created",
  description: "Sunday, December 3 at 9:00 AM",
})

Types

Set the type option to render a status icon. The built-in renderer recognizes success, info, warning, error, and loading.

Action

Pass button props with actionProps to render an action.

 
const id = toast.add({
  title: "Event created",
  actionProps: {
    children: "Undo",
    onClick() {
      toast.close(id)
    },
  },
})

Promise

Use toast.promise to update one toast as an asynchronous task moves through loading, success, and error states.

API Reference

See also the Base UI Toast documentation for manager options, stacking, swipe dismissal, and the primitive API.

toast manager

PropTypeDefaultDescription
toast.add(options) => string-Creates a toast. Pass title, description, type, actionProps, and priority.
toast.promise(promise, options) => string-Updates one toast through loading, success, and error states.
toast.close(id: string) => void-Closes a toast by id.
type"success" | "info" | "warning" | "error" | "loading"-Renders a status icon in the built-in toast list.
actionPropsButton HTML attributes-Props forwarded to ToastAction (for example children and onClick).
priority"low" | "high"-Controls stacking priority for important messages.

Toaster

PropTypeDefaultDescription
toastManagerToastManagertoastOptional custom manager from createToastManager().
childrenReact.ReactNode-App content wrapped by the toast provider.
classNamestring-Additional Tailwind classes merged with viewport styles when customizing parts.