Skip to content
Primitives

Toast (Sonner)

Toast notifications themed to the okibi tokens.

● LIVE

[ interactive — use the trigger to open ]

npx shadcn@latest add https://okibi.cndr.dev/r/sonner.json

Installation

Install the theme first, then add the component:

npx shadcn@latest add https://okibi.cndr.dev/r/sonner.json

Install the required dependencies:

npm install lucide-react sonner

Copy the source from the Code tab above into components/ui/sonner.tsx. It uses the cn helper and the okibi theme tokens — install the theme first if you haven't.

Usage

import { toast } from "sonner"

import { Toaster } from "@/components/ui/sonner"

// Mount once near the root:
<Toaster />

// Then fire toasts from anywhere:
toast.success("SEC // 0x4A2 — PURGED")

Anatomy

// Mount once near the app root:
<Toaster />

// Then fire toasts from anywhere:
toast.success("SEC // 0x4A2 — PURGED")

Examples

Types

toast.success, toast.error, toast.warning, and toast.info each carry their own semantic accent; the bare toast is neutral.

● LIVE

[ interactive — use the trigger to open ]

With action

Attach an action button to a toast for an inline undo or retry.

● LIVE

[ interactive — use the trigger to open ]

Promise

toast.promise tracks an async task, swapping loading → success / error copy as it settles.

● LIVE

[ interactive — use the trigger to open ]

Accessibility

  • Sonner owns the aria-live region and toast roles — mount Toaster once and it announces new toasts automatically.
  • Toasts are transient and not a replacement for blocking errors — surface anything that must be acted on in-flow.
  • Semantic type icons are swapped to okibi glyphs tinted with the per-mode *-spark tokens so success / error / warning / info meet WCAG AA on the popover surface.
  • The surface stays neutral (popover bg/fg, border-strong); color rides the icon, not the whole toast.
  • Pass closeButton or a duration for important toasts so they don't auto-dismiss before they can be read.

Guidelines

Do

  • Mount a single Toaster near the root; fire toasts with toast() from anywhere.
  • Use the semantic helpers (toast.success, toast.error, …) so the on-brand *-spark icon is applied.
  • Give a toast a closeButton or longer duration when the message matters and shouldn't auto-dismiss.

Don't

  • Don't pass richColors expecting the okibi palette — the surface is deliberately neutral; tint rides the type icon.
  • Don't use a toast for errors the user must resolve — keep blocking failures inline.
  • Don't mount more than one Toaster.

On this page