FactuGES_ERP/packages/shadcn-ui/src/components/sonner.tsx

48 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-10-21 09:30:45 +00:00
import { useTheme } from "next-themes"
2026-03-17 17:49:54 +00:00
import { Toaster as Sonner, type ToasterProps } from "sonner"
import { CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from "lucide-react"
2025-05-05 17:11:44 +00:00
const Toaster = ({ ...props }: ToasterProps) => {
2025-10-21 09:30:45 +00:00
const { theme = "system" } = useTheme()
2025-05-05 17:11:44 +00:00
return (
<Sonner
theme={theme as ToasterProps["theme"]}
2025-10-21 09:30:45 +00:00
className="toaster group"
icons={{
2026-03-17 17:49:54 +00:00
success: (
<CircleCheckIcon className="size-4" />
),
info: (
<InfoIcon className="size-4" />
),
warning: (
<TriangleAlertIcon className="size-4" />
),
error: (
<OctagonXIcon className="size-4" />
),
loading: (
<Loader2Icon className="size-4 animate-spin" />
),
2025-10-21 09:30:45 +00:00
}}
2025-05-05 17:11:44 +00:00
style={
{
"--normal-bg": "var(--popover)",
"--normal-text": "var(--popover-foreground)",
"--normal-border": "var(--border)",
2025-10-21 09:30:45 +00:00
"--border-radius": "var(--radius)",
2025-05-05 17:11:44 +00:00
} as React.CSSProperties
}
2026-03-17 17:49:54 +00:00
toastOptions={{
classNames: {
toast: "cn-toast",
},
}}
2025-05-05 17:11:44 +00:00
{...props}
/>
2025-10-21 09:30:45 +00:00
)
}
2025-05-05 17:11:44 +00:00
2026-03-17 17:49:54 +00:00
export { Toaster }