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

Add the Toaster

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

app/layout.tsx
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
import { toast } from "sonner"
Example
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

PropTypeDefaultDescription
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.
richColorsbooleanfalseUse richer colors for success, info, warning, and error.
expandbooleanfalseExpand stacked toasts by default.
durationnumber-Default duration in milliseconds before a toast auto-dismisses.
closeButtonbooleanfalseShow a close button on toasts.
classNamestring-Additional Tailwind classes merged with the toaster styles (last one wins).