1 "use client"
2
3 import * as React from "react"
4 import { Toaster as Primitive } from "sonner"
5
6 import { clx } from "@/utils/clx"
7
8 interface ToasterProps
9 extends Omit<
10 React.ComponentPropsWithoutRef<typeof Primitive>,
11 | "richColors"
12 | "closeButton"
13 | "icons"
14 | "theme"
15 | "invert"
16 | "loadingIcon"
17 | "cn"
18 | "toastOptions"
19 > {}
20
21 /**
22 * This component is based on the [Toaster component of the Sonner library](https://sonner.emilkowal.ski/toaster).
23 */
24 const Toaster = ({
25 /**
26 * The position of the created toasts.
27 */
28 position = "bottom-right",
29 /**
30 * The gap between the toast components.
31 */
32 gap = 12,
33 /**
34 * The space from the edges of the screen.
35 */
36 offset = 24,
37 /**
38 * The time in milliseconds that a toast is shown before it's
39 * automatically dismissed.
40 *
41 * @defaultValue 4000
42 */
43 duration,
44 ...props
45 }: ToasterProps) => {
46 const primitiveProps = {
47 ...props,
48 position,
49 gap,
50 offset,
51 cn: clx,
52 toastOptions: {
53 duration,
54 },
55 } as React.ComponentPropsWithoutRef<typeof Primitive>
56
57 return <Primitive {...primitiveProps} />
58 }
59
60 export { Toaster }