Command Palette

Search for a command to run...

Sonner

shadcn/ui

An opinionated toast component for React. Supports promises, custom styling, and multiple types.

import { toast } from "@/registry/optics/sonner";<Button onClick={() => toast({ type: "success", title: "Success!", description: "Your action was completed." })}>	Show Toast</Button><Button onClick={() => toast({ 	type: "promise", 	promise: fetch("/api/data"),	loading: "Loading...",	success: "Data loaded!",	error: "Failed to load data"})}>	Promise Toast</Button>

Installation

pnpm dlx shadcn@latest add https://optics.agusmayol.com.ar/r/sonner.json

Props

toast()
Name
Type
type
"success" | "error" | "info" | "warning" | "promise"
title
string
description
string
button
{ label: string, onClick: () => void }
promise
Promise
loading
string (for promise type)
success
string (for promise type)
duration
number (default: 5500)