Skip to content

extend toast to allow passing props to toast root and allow customization #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/Toast/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export const ToastContext = createContext<ToastContextProps>({

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

export const Toast = ({
type,
toastType = "foreground",
title,
description,
actions = [],
duration,
onClose,

...props
}: ToastProps & { onClose: (open: boolean) => void }) => {
let iconName = "";
if (type === "default") {
Expand All @@ -146,6 +150,8 @@ export const Toast = ({
<ToastRoot
onOpenChange={onClose}
duration={duration}
type={toastType}
{...props}
>
<ToastHeader>
{iconName.length > 0 && (
Expand Down