buster/web/src/components/ui/toaster/Toaster.tsx

39 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-02-22 06:26:57 +08:00
'use client';
2025-02-22 07:05:50 +08:00
import React from 'react';
2025-02-22 06:26:57 +08:00
import { useTheme } from 'next-themes';
import { Toaster as SonnerToaster } from 'sonner';
import { CircleCheck, CircleXmark, CircleWarning } from '@/components/ui/icons';
2025-02-22 06:26:57 +08:00
type ToasterProps = React.ComponentProps<typeof SonnerToaster>;
2025-02-22 06:26:57 +08:00
export const Toaster = ({ ...props }: ToasterProps) => {
const { theme = 'light' } = useTheme();
2025-02-22 06:26:57 +08:00
return (
<Toaster
position="top-center"
2025-02-22 07:05:50 +08:00
expand={true}
visibleToasts={5}
icons={{
success: <CircleCheck />,
error: <CircleXmark />,
warning: <CircleWarning />
2025-02-22 07:05:50 +08:00
}}
swipeDirections={['right']}
2025-02-22 06:26:57 +08:00
theme={theme as ToasterProps['theme']}
className="toaster group"
toastOptions={{
classNames: {
toast:
'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-hard',
description: 'group-[.toast]:text-foreground',
2025-02-22 06:26:57 +08:00
actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',
2025-02-26 04:58:01 +08:00
cancelButton: 'group-[.toast]:bg-border group-[.toast]:text-foreground'
2025-02-22 06:26:57 +08:00
}
}}
{...props}
/>
);
};