Skip to content

Allow stacking sheets with the iOS modal effect - #242

Merged
Temzasse merged 1 commit into
Temzasse:mainfrom
alesmraz:feat/stacked-sheets
Nov 7, 2026
Merged

Temzasse merged 1 commit into
Temzasse:mainfrom
alesmraz:feat/stacked-sheets

Conversation

@alesmraz

@alesmraz alesmraz commented Oct 13, 2026 •

Copy link
Copy Markdown

Fixes #150

Issue

Opening a sheet on top of another sheet had no way to push the underlying sheet back the way the app root is pushed back by modalEffectRootId. Pointing the second sheet's modalEffectRootId at the first sheet didn't work since the effect writes transform directly on the element and the sheet container's transform is controlled by Motion.

Solution

modalEffectRootId can now also be the id of another sheet. When it resolves to a sheet, the effect is applied to that sheet's container with the standalone scale and translate CSS properties, so Motion keeps transform for itself. The underlying sheet ends up in the same position as the app root does after its own modal effect (top edge, width and horizontal inset match), lifted by at most 10px so sheets with a smaller height don't jump to the top. There is no CSS transition for the underlying sheet since it follows the y value of the sheet on top frame by frame, which keeps both in sync while dragging and closing. Cleanup only removes what the effect added, so the body background and overflow owned by the root effect are untouched.

Sheets can be stacked any number of levels deep by always pointing modalEffectRootId to the sheet directly underneath.

Also changed useMeasure to offsetSize: true so a scaled sheet still measures its layout height.

  • README: props table + new "Stacking sheets" section
  • Example: new "Stacked sheets" playground example (4 levels)
  • Test: SSR test asserting id lands on the sheet root element

Tested in Chromium at phone and desktop sizes: opening/closing each level, dragging the top sheet, closing the underlying sheet while a stacked one is open, and the existing modal effect examples (snap-points, apple-music, slack-message) still clean up as before.

stacked-sheets-demo.mov

@alesmraz

Copy link
Copy Markdown
Author

@Temzasse 🙏

@Temzasse

Copy link
Copy Markdown
Owner

Hey @alesmraz 👋🏻 Thank you for this awesome PR! I'm a bit swamped at work currently but I will review this as soon as I have a bit more capacity and free time 🙂

@Temzasse Temzasse left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10/10, absolutely perfect 👏🏻

Thank you so much! 🤝

@Temzasse
Temzasse merged commit a0230a5 into Temzasse:main Nov 7, 2026
@Temzasse

Temzasse commented Nov 7, 2026

Copy link
Copy Markdown
Owner

@alesmraz stacked sheets feature is released in v5.7.0.

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.

Stacking sheets

2 participants