components
Wrap your application with the
app/layout.tsx
/components/ui/sonner.tsx
/components/ui/sonner.tsx
Installation
Install the following dependencies:
Wrap your application with the Toaster component from sonner.
import { Toaster } from "sonner"
export default function RootLayout({ children }) {
return (
<html lang="en">
<head />
<body>
<main>{children}</main>
<Toaster />
</body>
</html>
)
}Update the import paths as per your project structure.
Usage
Imports
import { toast } from "sonner"Code
<Button
variant="outline"
onClick={() =>
toast("Toast Title", {
description: "Toast Description Message",
action: {
label: "Upgrade",
onClick: () => console.log("Upgrade clicked!"),
},
})
}>
Show Toast
</Button>