Skip to content

[drawer] Create new Drawer / Sheet component - #3680

Merged
michaldudak merged 7 commits into
mui:masterfrom
atomiks:feat/drawer
Feb 12, 2026
Merged

michaldudak merged 7 commits into
mui:masterfrom
atomiks:feat/drawer

Conversation

@atomiks

@atomiks atomiks commented Jan 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #38

  • Nested drawer demo/logic/styling
  • Background indent provider
  • Handle text selection with swiping interaction
  • Fix momentum when swipe dismissing
  • Snap points

Preview: https://deploy-preview-3680--base-ui.netlify.app/react/components/drawer

@atomiks atomiks added type: new feature Expand the scope of the product to solve a new problem. component: drawer Changes related to the drawer component. labels Jan 5, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jan 5, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/@base-ui/react@3680
    
    pnpm add https://pkg.pr.new/@base-ui/utils@3680
    

commit: 77e807e

@mui-bot

mui-bot commented Jan 5, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+33.4KB(+7.96%) 🔺+11.1KB(+8.25%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jan 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 77e807e
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/698de6fec11db30008814bf1
😎 Deploy Preview https://deploy-preview-3680--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks force-pushed the feat/drawer branch 6 times, most recently from 8e7cd0d to 38aae58 Compare January 5, 2026 13:04
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 14, 2026
@piehouserat

Copy link
Copy Markdown

any idea when this will ship? I need a drawer component fairly soon but I can always use vaul in the meantime

@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 15, 2026
@atomiks

atomiks commented Jan 15, 2026

Copy link
Copy Markdown
Contributor Author

@piehouserat probably in v1.2.0 release around mid-February

@philwolstenholme

Copy link
Copy Markdown

A neat feature would be to use a CloseWatcher to allow closing the drawer with the Android 'back' swipe gesture. This can make drawers and modals feel much more native. The browser support is Chromium only at the moment (I think?) but I usually feature detect it and fall back to an Esc key listener instead on unsupported browsers.

@atomiks
atomiks force-pushed the feat/drawer branch 4 times, most recently from 7f95c7b to 534f9c0 Compare January 16, 2026 12:37
@oliviertassinari oliviertassinari changed the title [drawer] Create new Drawer component [drawer] Create new Drawer / Sheet component Jan 17, 2026

@oliviertassinari oliviertassinari left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@atomiks Really cool!

I don't know if you already need feedback, maybe not, but since I'm the only one? on Android, I thought I could have a quick play on my phone, and compare with Material UI:

  1. It's impossible to close the drawer, starting outside of the Popup:
VID_20260117_152111.mp4

Vaul has the same problem. But on Android, all the native apps, e.g., Google Drive supports it. It works "correctly" with Material UI. I'm used to it at this point. The value for end-users is not having to put any mental energy in think where to place your finger to start the dismissal interaction.

  1. It's possible to extend the drawer to infinity, it shouldn't:
VID_20260117_151449.mp4

I guess it's an Android-only issue, that we are good on iOS, we only have this issue because we want to have resistance when going in the wrong direction, and it's a bit trickier in Android to make it work.

  1. The close interaction feels too sensitive. I felt I had "cancelled" my interaction, I barely retracted the drawer, but still, it closed it:
VID_20260117_182008.mp4

We could have short interactions like this to close the drawer, but then it should take into account the velocity of the movement; this is the approach used in Material UI.

Otherwise:

@atomiks

atomiks commented Jan 19, 2026

Copy link
Copy Markdown
Contributor Author

@oliviertassinari thanks for all those points, very helpful - they should be addressed in the latest update

@atomiks
atomiks force-pushed the feat/drawer branch 4 times, most recently from 115dc22 to 71cca0e Compare January 19, 2026 11:54
@atomiks
atomiks force-pushed the feat/drawer branch 3 times, most recently from 0ad326c to 09ee4ed Compare February 9, 2026 11:53
@greptile-apps

greptile-apps Bot commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR introduces a complete Drawer/Sheet component to Base UI with comprehensive swipe gesture support, snap points, nested drawer handling, and background indent effects.

Key implementations:

  • Reusable useSwipeDismiss hook with velocity tracking, directional damping, and scroll conflict resolution
  • Snap points system supporting fractional viewport heights, pixel values, and rem units
  • Nested drawer coordination with height tracking and swipe progress propagation
  • DrawerSwipeArea component enabling swipe-to-open from screen edges
  • Background indent effects via DrawerProvider for visual depth
  • CloseWatcher integration for Android back gesture support
  • Touch scrolling conflict resolution to prevent interference with scrollable content

Architecture:

  • Built on top of the existing Dialog component foundation
  • CSS variables for styling flexibility (--drawer-swipe-movement-x/y, --drawer-height, etc.)
  • Comprehensive test coverage including velocity-based gestures and edge cases
  • Well-documented with multiple demos showing various use cases

Confidence Score: 5/5

  • This PR is safe to merge with high confidence - well-architected, thoroughly tested, and follows established patterns
  • The implementation demonstrates excellent code quality with comprehensive test coverage, proper use of React hooks patterns, careful handling of edge cases (velocity reversals, touch conflicts, nested drawers), and adherence to the repository's coding guidelines. The component builds on the existing Dialog foundation and introduces no breaking changes.
  • No files require special attention - the implementation is solid throughout

Important Files Changed

Filename Overview
packages/react/src/drawer/root/DrawerRoot.tsx Root component implementation wrapping Dialog.Root with drawer-specific snap points and nested drawer tracking
packages/react/src/utils/useSwipeDismiss.ts Core swipe gesture hook with velocity tracking, directional damping, and scroll conflict resolution
packages/react/src/drawer/viewport/DrawerViewport.tsx Complex viewport with swipe interactions, snap points, touch scrolling, and nested drawer coordination
packages/react/src/drawer/popup/DrawerPopup.tsx Popup container with height measurement, snap point offset calculation, and nested drawer state management
packages/react/src/drawer/root/useDrawerSnapPoints.ts Snap point resolution logic converting fractional/px/rem values to pixel offsets with deduplication
packages/react/src/drawer/swipe-area/DrawerSwipeArea.tsx Swipe-to-open area component with opposite-direction swipe handling and visual feedback during opening

@michaldudak

Copy link
Copy Markdown
Member

The Drawer's contents are unusable with a stylus. Dragging works, but anything that requires clicks (buttons, inputs) don't work unless a really precise tap is performed (with no movement)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Once the drawer is expanded, I can't make it compact again - it always closes when swiped down.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's velocity-based, so if you do it slowly enough it won't skip the snap point. The snapToSequentialPoints prop disables this, if necessary

@michaldudak

Copy link
Copy Markdown
Member

When the Drawer content overflows, it's not possible to close it by swiping anymore (using touch, the other pointer types work ok)

@michaldudak

Copy link
Copy Markdown
Member

The new swipe reason is emitted by Drawer, but ReasonToEventMap has no swipe entry. That widens eventDetails.event to Event for swipe cases, losing pointer/touch typing for consumers handling onOpenChange.

@michaldudak

Copy link
Copy Markdown
Member

Right-clicking during dragging leaves the drawer in a weird state where it's draggable without a pressed mouse button.

@atomiks

atomiks commented Feb 10, 2026

Copy link
Copy Markdown
Contributor Author

When the Drawer content overflows, it's not possible to close it by swiping anymore (using touch, the other pointer types work ok)

Can you elaborate on this? It's intentional that scrolling is allowed (and swiping doesn't work) unless .scrollTop === 0 (for bottom sheets)

@michaldudak

Copy link
Copy Markdown
Member

Here's the issue:

Screen.Recording.2026-02-10.at.13.01.05.mov

@michaldudak

Copy link
Copy Markdown
Member

Sometimes when I swipe to open, the drawer doesn't open fully:

Screen.Recording.2026-02-11.at.14.09.10.mov

@colmtuite

Copy link
Copy Markdown
Contributor

@atomiks Do you think we need anything new to handle multiple panels in a single drawer? Or would it just be that the drawer itself is transparent, and you add your own divs and buttons inside to achieve the effect?

iPhone 17 - 1 (1)

@atomiks

atomiks commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

Do you think we need anything new to handle multiple panels in a single drawer? Or would it just be that the drawer itself is transparent, and you add your own divs and buttons inside to achieve the effect?

Yep, I would say this is the same as this pattern for Dialog: https://base-ui.com/react/components/dialog#placing-elements-outside-the-popup (popup is transparent, inner elements are colored)

@colmtuite

Copy link
Copy Markdown
Contributor

@atomiks An example might be useful, if you have time

@green-mint

Copy link
Copy Markdown

Been following this for sometime, just wanted to point out that the drawer does not close if you try to flick to close inside a scrollable container.

On examples:

https://deploy-preview-3680--base-ui.netlify.app/react/components/drawer#snap-points

https://deploy-preview-3680--base-ui.netlify.app/react/components/drawer#mobile-navigation

ios 26 safari and chrome

@atomiks

atomiks commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

@green-mint thanks, swipe behavior changed after addressing the recent reviews, this is fixed with regression tests in place

@michaldudak michaldudak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm seeing the behavior I reported in #3680 (comment) in other demos as well (mobile navigation, indent), but we can fix it after the preview version is released. I haven't found other issues.

@colmtuite

Copy link
Copy Markdown
Contributor

@atomiks When I drag a bottom drawer to very close to the bottom of the viewport, then stop dragging completely, then release, it closes.

On Instagram iOS, it seems to work like this too. On Instagram, it requires at least some velocity in order to close (although I think Instagram use RN?)

@oliviertassinari

oliviertassinari commented Feb 12, 2026 •

Copy link
Copy Markdown
Member

Just to be clear, this is not getting to be released today? If it's, let's hold a bit on the decision about the plan. (Or maybe it's simply about renaming DrawerPreview to Unstable_Drawer).

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

Labels

component: drawer Changes related to the drawer component. type: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[drawer] Create the unstyled Drawer / Sheet component

10 participants