Toast
A succinct message displayed temporarily.
Installation
Usage
Mount Toaster once near the root of your application.
import { Toaster } from "@/components/redpanda-ui/toast"
export function App({ children }: { children: React.ReactNode }) {
return (
<>
{children}
<Toaster />
</>
)
}Add a toast from any client component through the shared manager.
import { toast } from "@/components/redpanda-ui/toast"
toast.add({
title: "Event created",
description: "Sunday, December 3 at 9:00 AM",
})Anatomy
<Toaster>
└── <ToastProvider>
└── <ToastPortal>
└── <ToastViewport>
└── <Toast>
└── <ToastContent>
├── Status icon
├── <ToastTitle>
├── <ToastDescription>
├── <ToastAction>
└── <ToastClose>Types
Set type to render a status icon. Supported built-in types are success, info, warning, error, and loading.
toast.add({
type: "success",
title: "Settings saved",
})Action
Pass button props through actionProps to render an inline 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.
toast.promise(createEvent(), {
loading: "Creating event…",
success: "Event created.",
error: "Could not create event.",
})Custom manager
Use createToastManager when a subtree needs an isolated toast queue.
import { createToastManager, Toaster } from "@/components/redpanda-ui/toast"
const localToast = createToastManager()
export function LocalToaster() {
return <Toaster toastManager={localToast} />
}Toast or Sonner
Toast is an additive Base UI option. The existing Sonner component remains supported and unchanged. Use Toast for composable primitives and isolated managers. Use Sonner when an application already relies on Sonner's API or the RedpandaProvider integration.
Credits
- We use Base UI for accessible toast primitives.
- We take inspiration from Shadcn UI for the component API and styling.
Recent changes
- v1.2.0Pin shipped dependency floors to the version we develop against. Registry items now declare ranges like `^5.1.9` (the actual installed version) instead of collapsing to `^5.0.0`, so consumers start on the known-tested baseline while caret semantics still allow any compatible release within the same major.#133
- v1.1.0Theme docs refresh, readability pass on semantic foregrounds, and consumer-facing Base UI regression fixes.#121
- v1.0.0Post-Base-UI polish. Public API unchanged.#116
- v1.0.0Migrate every Radix-based primitive to `@base-ui/react@^1.4.0` (Base UI).#114
- v0.3.0Add theme-provider component to the registry with documentation and tests. Includes playground type improvements (export RegistryItem, remove as-const boilerplate) and docs site dark mode border color fix.#109