Skip to content

Commit bb07326

Browse files
authored
extend toast to allow passing props to toast root and allow customization (#625)
1 parent 04092c7 commit bb07326

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/components/Toast/Toast.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ export const ToastContext = createContext<ToastContextProps>({
1313

1414
export type ToastAlignment = "start" | "end";
1515
export type ToastType = "danger" | "warning" | "default" | "success";
16-
export interface ToastProps {
16+
export interface ToastProps extends Omit<RadixUIToast.ToastProps, "type"> {
1717
id?: string;
1818
type?: ToastType;
19+
toastType?: "foreground" | "background";
1920
title: string;
2021
description?: ReactNode;
2122
/** Time in milliseconds the toast will be visible */
@@ -128,11 +129,14 @@ const Title = styled.div`
128129

129130
export const Toast = ({
130131
type,
132+
toastType = "foreground",
131133
title,
132134
description,
133135
actions = [],
134136
duration,
135137
onClose,
138+
139+
...props
136140
}: ToastProps & { onClose: (open: boolean) => void }) => {
137141
let iconName = "";
138142
if (type === "default") {
@@ -146,6 +150,8 @@ export const Toast = ({
146150
<ToastRoot
147151
onOpenChange={onClose}
148152
duration={duration}
153+
type={toastType}
154+
{...props}
149155
>
150156
<ToastHeader>
151157
{iconName.length > 0 && (

0 commit comments

Comments
 (0)