sonner.tsx 894 B

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