Docs
Sonner

Sonner

一个 React 的自定提示组件。

关于

¥About

Sonner 由 emilkowalski_ 构建和维护。

¥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.")