Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(Toast): drop the trailing gap below the last toast (#5460)

Cindy Zhang5c9316e2345c
diff --git a/.changeset/toast-viewport-trailing-gap.md b/.changeset/toast-viewport-trailing-gap.md
new file mode 100644
index 0000000000..eca63dec46
--- /dev/null
+++ b/.changeset/toast-viewport-trailing-gap.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] ToastViewport: the space below the bottom-most toast is the viewport's own padding again, not the viewport's padding plus the toast's. Each toast carries a trailing `--spacing-3` as the inter-toast gap, and the one at the visual bottom of the stack added it on top of the viewport's `--spacing-4` — 28px there against 16px on every other edge. That toast now drops its trailing gap. The flex direction flips with `position`, so it is the last toast for `bottomEnd`/`bottomStart` and the first for `topEnd`/`topStart`; all four are corrected. The gap is still padding, so entry and exit animate as before.
+
+@cixzhang
diff --git a/packages/core/src/Toast/ToastViewport.tsx b/packages/core/src/Toast/ToastViewport.tsx
index 4ec695eb94..4789e43cc6 100644
--- a/packages/core/src/Toast/ToastViewport.tsx
+++ b/packages/core/src/Toast/ToastViewport.tsx
@@ -58,7 +58,6 @@ const styles = stylex.create({
pointerEvents: 'auto',
display: 'grid',
gridTemplateRows: '1fr',
- paddingBlockEnd: spacingVars['--spacing-3'],
transitionProperty: 'grid-template-rows, padding',
transitionDuration: {
default: durationVars['--duration-fast'],
@@ -70,6 +69,18 @@ const styles = stylex.create({
paddingBlockEnd: 0,
},
},
+ // The inter-toast gap is padding on each toast rather than `gap` on the
+ // viewport so it can animate alongside gridTemplateRows on entry and exit.
+ // That makes it the toast's own trailing space, so the toast at the visual
+ // bottom of the stack has to give it up — otherwise it stacks on top of the
+ // viewport's own padding. Which child that is flips with the flex direction
+ // the position sets.
+ toastWrapperGap: {
+ paddingBlockEnd: {default: spacingVars['--spacing-3'], ':last-child': 0},
+ },
+ toastWrapperGapReversed: {
+ paddingBlockEnd: {default: spacingVars['--spacing-3'], ':first-child': 0},
+ },
toastWrapperExiting: {
gridTemplateRows: '0fr',
paddingBlockEnd: 0,
@@ -417,6 +428,10 @@ export function ToastViewport({
: position === 'bottomStart'
? styles.bottomStart
: styles.bottomEnd;
+ const isReversed = position === 'topEnd' || position === 'topStart';
+ const gapStyle = isReversed
+ ? styles.toastWrapperGapReversed
+ : styles.toastWrapperGap;
return (
<ToastContext value={contextValue}>
@@ -444,6 +459,7 @@ export function ToastViewport({
data-toast-id={entry.id}
{...stylex.props(
styles.toastWrapper,
+ gapStyle,
isExiting && styles.toastWrapperExiting,
)}
onTransitionEnd={