Sonner
An opinionated toast component.
About
Cubix Sonner wraps the Sonner toast library by Emil Kowalski, themed with Cubix tokens.
Installation
pnpm dlx cubix@latest add sonner --base radixAdd the Toaster
Place Toaster in your root layout so toasts can render from anywhere.
import { Toaster } from "@/components/cubix/sonner"
export default function RootLayout({ children }) {
return (
<html lang="en">
<head />
<body>
<main>{children}</main>
<Toaster />
</body>
</html>
)
}Usage
import { toast } from "sonner"toast("Event has been created.")Types
Description
Position
Use the position prop to change where the toast appears.
API Reference
See also the Sonner API Reference for toast helpers and options.
Toaster
| Prop | Type | Default | Description |
|---|---|---|---|
| theme | "light" | "dark" | "system" | "system" | Toast theme. Cubix wires this to next-themes by default. |
| position | "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | "bottom-right" | Default position for toasts rendered by this toaster. |
| richColors | boolean | false | Use richer colors for success, info, warning, and error. |
| expand | boolean | false | Expand stacked toasts by default. |
| duration | number | - | Default duration in milliseconds before a toast auto-dismisses. |
| closeButton | boolean | false | Show a close button on toasts. |
| className | string | - | Additional Tailwind classes merged with the toaster styles (last one wins). |