Skip to content
SevenOne

Search documentation

Search pages and components

Toast

Short messages that appear for a moment and go away on their own. Built on Sonner, with 16px text, status icons and 44px action buttons.

Installation

npx shadcn@latest add @sevenone/sonner

Usage

import { toast } from "sonner"

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

Examples

With an action

Add <Toaster /> once, near the root of your app. Then call toast() from anywhere.

// app/layout.tsx
<body>
  {children}
  <Toaster />
</body>

// any component
<Button
  variant="outline"
  onClick={() =>
    toast("Event has been created", {
      description: "Sunday, December 3 at 9:00 AM",
      action: { label: "Undo", onClick: () => {} },
    })
  }
>
  Show toast
</Button>

Types

toast("Event has been created")
toast.success("Changes saved", { description: "Your profile is up to date." })
toast.info("New version available")
toast.warning("Storage almost full")
toast.error("Payment failed")
toast.promise(upload(), {
  loading: "Uploading file…",
  success: "File uploaded",
  error: "Upload failed",
})

Accessibility

  • Screen readers announce toasts without moving focus.
  • Status icons always come with text, so the meaning never depends on color alone.
  • Toasts close on their own, so never put the only way to do something in one.
  • The loading spinner stops spinning when people ask for reduced motion.