Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add drawer component based on Base UI DrawerPreview#689

Draft
pasqualevitiello wants to merge 46 commits intomainfrom
devin/1771247692-add-drawer-component
Draft

feat: add drawer component based on Base UI DrawerPreview#689
pasqualevitiello wants to merge 46 commits intomainfrom
devin/1771247692-add-drawer-component

Conversation

@pasqualevitiello
Copy link
Contributor

@pasqualevitiello pasqualevitiello commented Feb 16, 2026

feat: add drawer component based on Base UI DrawerPreview

Summary

Adds a new Drawer coss UI primitive wrapping Base UI's DrawerPreview (shipped in v1.2.0) with Tailwind classes. The Drawer is similar to the existing Sheet component but built on a real drawer primitive with native swipe-to-dismiss gestures, snap points, and nested drawer stacking support.

Key changes:

  • Bumped @base-ui/react from ^1.1.0 to ^1.2.0
  • Created drawer.tsx with the same part structure as Dialog/Sheet (Root, Trigger, Popup, Header, Footer, Title, Description, Panel, etc.)
  • Props: side (right/left/top/bottom), variant (default/inset), showCloseButton, plus pass-through for snapPoints, open, onOpenChange, etc.
  • 5 particle demos: default form, inset variant, all 4 sides, nested drawers, bottom drawer with snap points
  • Full MDX documentation with API reference and examples
  • Registered in registry-ui.ts, registry-categories.ts, registry-particles.ts
  • Generated registry JSON files and synced to packages/ui

Note: Base UI exports this as DrawerPreview (preview API, subject to breaking changes in minor versions). We alias it as DrawerPrimitive internally.

Updates since last revision

Reworked all transitions to match Base UI's official drawer examples:

  • Backdrop: 450ms cubic-bezier(0.32, 0.72, 0, 1) timing, opacity driven by --drawer-swipe-progress during swipe, 0ms duration while swiping (data-swiping), velocity-scaled release via --drawer-swipe-strength
  • Popup: 450ms cubic-bezier(0.32, 0.72, 0, 1) for transform, CSS variable-driven swipe tracking (--drawer-swipe-movement-x/y, --drawer-snap-point-offset), full off-screen translate for starting/ending styles (e.g. translate-x-full) instead of small 8px shifts
  • Removed opacity fade from popup transitions — drawers use transform-only animations per Base UI convention

Review & Testing Checklist for Human

  • Visually test all 5 particle demos in the dev server (bun run dev --filter=ui). None of these were tested in a browser — swipe gestures, snap points, nested drawer stacking, and side positioning all need hands-on verification.
  • Verify swipe/drag tracking works during gesture. The popup now applies translate-x-[var(--drawer-swipe-movement-x)] (or translate-y-[...] for vertical drawers) directly. If the drawer doesn't track the finger during swipe, confirm Tailwind is correctly compiling these arbitrary value utilities with CSS variables.
  • Verify transition timing feels right. The duration-450 ease-[cubic-bezier(0.32,0.72,0,1)] and data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] utilities are complex arbitrary values — confirm they compile and produce smooth open/close/release animations.
  • Check the side prop design. The side prop must be passed in two places: <Drawer side="left"> (sets swipeDirection) and <DrawerPopup side="left"> (sets visual positioning). This is error-prone. Consider if the root Drawer should automatically pass side down via context, or if the docs should clearly warn about this.
  • Confirm Base UI 1.2.0 upgrade doesn't break existing components. Run the dev server and spot-check Dialog, Sheet, and other Base UI-dependent components.
  • Test nested drawers with varying heights to ensure the --nested-drawers CSS variable and scale/opacity stacking work correctly.

Test Plan

  1. Start dev server: bun run dev --filter=ui
  2. Navigate to /ui/docs/components/drawer
  3. Test each particle:
    • p-drawer-1: Open, fill form, swipe to dismiss — verify smooth 450ms animation
    • p-drawer-2: Verify inset spacing on desktop
    • p-drawer-3: Open all 4 sides, swipe each direction to dismiss — verify swipe tracking and directional exit animations
    • p-drawer-4: Open nested drawer, verify parent scales/dims, swipe child to dismiss
    • p-drawer-5: Open bottom drawer, drag to snap points, verify it locks at 148px and full-screen with smooth snap transitions

Notes

  • Requested by @pasqualevitiello
  • Devin session: https://app.devin.ai/sessions/da4589e6781140be92e31994d09d9e74
  • The existing Sheet component (built on Dialog primitive) remains unchanged for backward compatibility
  • PR size: ~1600 lines added (mostly generated registry JSON + particles), 26 files changed (3 files updated in latest commit)
  • Transitions were reworked based on Base UI source code inspection but NOT tested in a browser — manual verification is critical

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link

vercel bot commented Feb 16, 2026

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

Project Deployment Actions Updated (UTC)
coss-com Ready Ready Preview, Comment Mar 2, 2026 11:53am
coss-com-ui Ready Ready Preview, Comment Mar 2, 2026 11:53am
coss-examples-calcom Ready Ready Preview, Comment Mar 2, 2026 11:53am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
coss-com-origin Skipped Skipped Mar 2, 2026 11:53am

Request Review

@vercel vercel bot temporarily deployed to Preview – coss-com-origin February 27, 2026 11:47 Inactive
@pasqualevitiello
Copy link
Contributor Author

TODOS:

  • Deprecate Sheet component
  • Migrate all Sheet instances to Drawer
  • Simplify Dialog component by removing the bottomStickOnMobile prop

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant