Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

sonner.tsx

38 lines1.0 KB

1import {
2 CircleCheckIcon,
3 InfoIcon,
4 Loader2Icon,
5 OctagonXIcon,
6 TriangleAlertIcon,
7} from "lucide-react";
8import { useTheme } from "next-themes";
9import { Toaster as Sonner, type ToasterProps } from "sonner";
10​
11const Toaster = ({ ...props }: ToasterProps) => {
12 const { theme = "system" } = useTheme();
13​
14 return (
15 <Sonner
16 theme={theme as ToasterProps["theme"]}
17 className="toaster group"
18 icons={{
19 success: <CircleCheckIcon className="size-4" />,
20 info: <InfoIcon className="size-4" />,
21 warning: <TriangleAlertIcon className="size-4" />,
22 error: <OctagonXIcon className="size-4 text-red-400" />,
23 loading: <Loader2Icon className="size-4 animate-spin" />,
24 }}
25 style={
26 {
27 "--normal-bg": "var(--popover)",
28 "--normal-text": "var(--popover-foreground)",
29 "--normal-border": "var(--border)",
30 "--border-radius": "var(--radius)",
31 } as React.CSSProperties
32 }
33 {...props}
34 />
35 );
36};
37​
38export { Toaster };