组件
"use client"
import { Button } from "@/components/ui/button"关于
🌐 About
Sonner 由 emilkowalski 构建和维护。
🌐 Sonner is built and maintained by emilkowalski.
安装
🌐 Installation
运行以下命令:
pnpm dlx shadcn@latest add sonner
添加烤面包机组件
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
使用 position 属性来更改提示框的位置。
🌐 Use the position prop to change the position of the toast.
"use client"
import { Button } from "@/components/ui/button"API参考
🌐 API Reference
有关更多信息,请参阅 Sonner API 参考。
🌐 See the Sonner API Reference for more information.