Sonner

Toast notifications powered by Sonner.

Saved preference for elorm init --ui-library base-ui
PreviewCode
"use client"

import { toast, Toaster } from "@/components/ui/sonner"
import { Button } from "@/components/ui/button"

export function SonnerDemo() {
  return (
    <>
      <Toaster />
      <div className="flex flex-wrap gap-2">
      <Button variant="outline" onClick={() => toast("Event has been created")}>
        Default
      </Button>
      <Button
        variant="outline"
        onClick={() => toast.success("Profile updated successfully")}
      >
        Success
      </Button>
      <Button
        variant="outline"
        onClick={() => toast.error("Something went wrong")}
      >
        Error
      </Button>
      </div>
    </>
  )
}

Installation#

Usage#

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

Toast notifications powered by Sonner.

Mount <Toaster /> once in your root layout. Call toast() from anywhere.

Examples#

Success toast#

PreviewCode
import { Sonner } from "@/components/ui/sonner"

export function SonnerDemo() {
  return (
    toast.success("Saved successfully")
  )
}