feat: add shadcn/originui sonner component

This commit is contained in:
ngc2207 2025-02-03 11:53:39 +08:00
parent 2a8c99b7dd
commit e102418c50
3 changed files with 33 additions and 0 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -31,6 +31,7 @@
"react-hook-form": "^7.54.2",
"react-icons": "^5.4.0",
"server-only": "^0.0.1",
"sonner": "^1.7.4",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.24.1"

View File

@ -0,0 +1,32 @@
"use client";
import { useTheme } from "next-themes";
import { Toaster as Sonner } from "sonner";
type ToasterProps = React.ComponentProps<typeof Sonner>;
const Toaster = ({ ...props }: ToasterProps) => {
const { theme = "system" } = useTheme();
return (
<Sonner
theme={theme as ToasterProps["theme"]}
position="top-right"
className="toaster group"
toastOptions={{
classNames: {
toast:
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:shadow-black/5",
description: "group-[.toast]:text-muted-foreground",
actionButton:
"group-[.toast]:data-[button]:h-8 group-[.toast]:data-[button]:rounded-lg group-[.toast]:data-[button]:px-3 group-[.toast]:data-[button]:text-xs group-[.toast]:data-[button]:font-medium",
cancelButton:
"group-[.toast]:data-[button]:h-8 group-[.toast]:data-[button]:rounded-lg group-[.toast]:data-[button]:px-3 group-[.toast]:data-[button]:text-xs group-[.toast]:data-[button]:font-medium",
},
}}
{...props}
/>
);
};
export { Toaster };