105k
New

Sonner

An opinionated toast component for React.

"use client"

import { Button } from "@/components/ui/button"

About

Sonner is built and maintained by emilkowalski.

Installation

Run the following command:

pnpm dlx shadcn@latest add sonner

Add the Toaster component

app/layout.tsx
import { Toaster } from "@/components/ui/sonner"
 
export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <head />
      <body>
        <main>{children}</main>
        <Toaster />
      </body>
    </html>
  )
}

Usage

import { toast } from "sonner"
toast("Event has been created.")

Examples

Types

"use client"

import { Button } from "@/components/ui/button"

Description

"use client"

import { Button } from "@/components/ui/button"

Position

Use the position prop to change the position of the toast.

"use client"

import { Button } from "@/components/ui/button"

API Reference

See the Sonner API Reference for more information.