sonner.tsx
796 bytes
| 1 | 'use client'; |
|---|---|
| 2 | |
| 3 | import { useTheme } from 'next-themes'; |
| 4 | import { Toaster as Sonner } from 'sonner'; |
| 5 | |
| 6 | export function Toaster() { |
| 7 | const { theme = 'system' } = useTheme(); |
| 8 | return ( |
| 9 | <Sonner |
| 10 | theme={theme as 'light' | 'dark' | 'system'} |
| 11 | className="toaster group" |
| 12 | toastOptions={{ |
| 13 | classNames: { |
| 14 | toast: |
| 15 | 'group toast group-[.toaster]:bg-card group-[.toaster]:text-card-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg', |
| 16 | description: 'group-[.toast]:text-muted-foreground', |
| 17 | actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground', |
| 18 | cancelButton: 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground', |
| 19 | }, |
| 20 | }} |
| 21 | /> |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | export { toast } from 'sonner'; |
| 26 | |