Overlay
Toast
Brief, stacked notifications, built on Sonner.
LiveRev. 01
Installation
CLI
$ npx shadcn@latest add https://konsa.rohitxyz.me/r/sonner.jsonManual
Install the dependencies
npm install sonner next-themesCopy the source into your project
components/ui/sonner.tsx
"use client";
import { useTheme } from "next-themes";
import { Toaster as Sonner, type ToasterProps } from "sonner";
function Toaster(props: ToasterProps) {
const { theme = "system" } = useTheme();
return (
<Sonner
theme={theme as ToasterProps["theme"]}
className="toaster group"
toastOptions={{
classNames: {
toast:
"!rounded-lg !border !border-border !bg-popover !text-popover-foreground !shadow-lg !shadow-black/5 !font-sans",
description: "!text-muted-foreground",
actionButton: "!bg-primary !text-primary-foreground !rounded-md",
cancelButton: "!bg-muted !text-muted-foreground !rounded-md",
},
}}
{...props}
/>
);
}
export { Toaster };Update the import paths to match your project
The file imports cn from @/lib/utils. See installation.
Usage
import { Toaster } from "@/components/ui/sonner";// app/layout.tsx
<Toaster />
// anywhere
import { toast } from "sonner";
toast("Saved", { description: "Your changes are live." });