Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

fix: toast dismissal (#1300)

__aadamw7db70f8987f3
diff --git a/packages/ui/src/components/toast.tsx b/packages/ui/src/components/toast.tsx
index 4cbfd506..29c8dcaa 100644
--- a/packages/ui/src/components/toast.tsx
+++ b/packages/ui/src/components/toast.tsx
@@ -13,7 +13,7 @@ const ToastViewport = React.forwardRef<
>(({ className, ...props }, ref) => (
<ToastPrimitives.Viewport
className={cn(
- 'fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]',
+ 'fixed top-10 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-14 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]',
className,
)}
ref={ref}
@@ -65,7 +65,7 @@ const Toast = React.forwardRef<
{...props}
>
<div className={cn(bgToastVariants({ variant }))} />
- {props.children}
+ <div className="z-50 inline-flex w-full gap-x-3">{props.children}</div>
</ToastPrimitives.Root>
);
});
diff --git a/packages/ui/src/components/toaster.tsx b/packages/ui/src/components/toaster.tsx
index 3fa885bd..02344d8f 100644
--- a/packages/ui/src/components/toaster.tsx
+++ b/packages/ui/src/components/toaster.tsx
@@ -38,8 +38,7 @@ export function Toaster() {
{title ? <ToastTitle>{title}</ToastTitle> : null}
{description ? <ToastDescription>{description}</ToastDescription> : null}
</div>
- {action}
- <ToastClose />
+ <div className="ml-auto inline-flex">{action ? action : <ToastClose />}</div>
</Toast>
);
})}