Skip to content

fix: clip custom toast content overflow in stacked view#749

Open
iampankajghosh wants to merge 1 commit intoemilkowalski:mainfrom
iampankajghosh:fix/custom-toast-stacking-height
Open

fix: clip custom toast content overflow in stacked view#749
iampankajghosh wants to merge 1 commit intoemilkowalski:mainfrom
iampankajghosh:fix/custom-toast-stacking-height

Conversation

@iampankajghosh
Copy link
Copy Markdown

@iampankajghosh iampankajghosh commented Mar 4, 2026

What does this PR fix?

Fixes #748

Problem

When using toast.custom(), stacking a short toast in front of a tall toast
causes the bottom of the taller toast to bleed through the shorter front toast.
Default toasts are unaffected — the issue is isolated to custom/JSX toasts.

Root Cause

Sonner clips the stack using --front-toast-height on the list container. For
default toasts, overflow is handled implicitly by their internal structure. For
custom toasts, the [data-content] wrapper grows to its natural content height
and punches through the parent's clipped boundary because it never receives
overflow: hidden or height: 100%.

Fix

Added a CSS rule scoped to [data-front='false'] that constrains [data-content]
to the parent's height and clips the overflow:

[data-sonner-toast][data-front='false'] [data-content] {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

This is tightly scoped — it only applies to non-front toasts in the stack,
so it has zero impact on the front toast or any other state.

Testing

Manually verified with tall + short toast.custom() combinations in
Chrome, Firefox, and Safari.

Demo

Before

before-fix.mp4

After

after-fix.mp4

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sonner Error Error Mar 4, 2026 11:26am

Request Review

@iampankajghosh
Copy link
Copy Markdown
Author

Gentle ping! Happy to make any changes if needed. cc @emilkowalski

@mnsrv
Copy link
Copy Markdown

mnsrv commented Mar 23, 2026

hi, thank you for fix and nice video!

just wanted to say that for position="top-*" it cuts wrong

it's due to separate bug, that in position="top-*" children are growing from top, not the bottom. but still worth mentioning here, I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Custom toast bottom bleeds through shorter front toast in stacked view

2 participants