OpChan/app/src/components/ui/sonner.tsx

30 lines
887 B
TypeScript
Raw Normal View History

2025-08-30 18:34:50 +05:30
import { useTheme } from 'next-themes';
import { Toaster as Sonner } from 'sonner';
2025-04-15 16:28:03 +05:30
2025-08-30 18:34:50 +05:30
type ToasterProps = React.ComponentProps<typeof Sonner>;
2025-04-15 16:28:03 +05:30
const Toaster = ({ ...props }: ToasterProps) => {
2025-08-30 18:34:50 +05:30
const { theme = 'system' } = useTheme();
2025-04-15 16:28:03 +05:30
return (
<Sonner
2025-08-30 18:34:50 +05:30
theme={theme as ToasterProps['theme']}
2025-04-15 16:28:03 +05:30
className="toaster group"
toastOptions={{
classNames: {
toast:
2025-08-30 18:34:50 +05:30
'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',
description: 'group-[.toast]:text-muted-foreground',
2025-04-15 16:28:03 +05:30
actionButton:
2025-08-30 18:34:50 +05:30
'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',
2025-04-15 16:28:03 +05:30
cancelButton:
2025-08-30 18:34:50 +05:30
'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',
2025-04-15 16:28:03 +05:30
},
}}
{...props}
/>
2025-08-30 18:34:50 +05:30
);
};
2025-04-15 16:28:03 +05:30
2025-08-30 18:34:50 +05:30
export { Toaster };