refactor(base-drawer): migrate base drawer to @base-ui/react/drawer#10430
Open
lunaxislu wants to merge 4 commits intoshadcn-ui:mainfrom
Open
refactor(base-drawer): migrate base drawer to @base-ui/react/drawer#10430lunaxislu wants to merge 4 commits intoshadcn-ui:mainfrom
lunaxislu wants to merge 4 commits intoshadcn-ui:mainfrom
Conversation
…/drawer Replace vaul with @base-ui/react/drawer as the primitive behind the base drawer wrapper. Keep the public API aligned with the radix drawer shape while rewriting DrawerContent to compose Backdrop, Viewport, Popup, and Content internally. Keep the registry dependency change in the same commit so the wrapper rewrite lands as one source-level migration step.
… to primitives Shared drawer styles previously owned direction-specific layout in CSS. With base and radix now exposing different direction attributes, keeping that logic in shared tokens would duplicate primitive-specific branching in the stylesheets. Move direction-specific layout into the base/radix drawer wrappers and leave shared CSS responsible only for visual surface styling. Also move handle visibility and header alignment into TSX, and unify the shared drawer token names to cn-drawer-*.
…er and swipeDirection Update in-repo base drawer consumers to the new wrapper API. Replace asChild usage with render, switch direction to swipeDirection, and align examples, blocks, app consumers, and docs with the new base drawer usage pattern.
Contributor
|
@lunaxislu is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Apr 18, 2026
Author
|
If this PR is difficult to review in full right away, I’d appreciate confirmation on whether these two design decisions match the current direction of the repo:
If those two directions look right, the rest of the changes are mostly migration work. |
Author
|
@shadcn Just following up on the two design questions above, in case it's easier to give a quick directional check before a full review. I'd especially appreciate confirmation on:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #10292.
This PR migrates the base drawer from
vaulto@base-ui/react/drawerand realigns bothbaseandradixwrappers to provide the same abstraction where possible.The previous attempt did not clearly separate wrapper replacement, direction layout ownership changes, and consumer migration into a single coherent flow. This PR restructures those boundaries so maintainers can review the migration in commit order.
What this does
Replaces the
vaul-based base drawer with@base-ui/react/drawer, maintaining the same 10 public exports as the radix drawer. The goal is not to expose the primitive anatomy directly, but to ensure the shadcn wrapper provides the same abstraction acrossbaseandradix.DrawerDrawerPrimitive.RootDrawerTriggerDrawerPrimitive.TriggerDrawerPortalDrawerPrimitive.PortalDrawerCloseDrawerPrimitive.CloseDrawerOverlayDrawerPrimitive.BackdropDrawerContentDrawerHeader<div>DrawerFooter<div>DrawerTitleDrawerPrimitive.TitleDrawerDescriptionDrawerPrimitive.DescriptionBase UI's drawer primitive exposes 13 parts; this wrapper surfaces 10 and removes
DrawerPopup,DrawerViewport, andDrawerSwipeAreafrom the public API.DrawerContentnow internally composes Portal → Backdrop → Viewport → Popup → Content, so consumers use the same level of wrapper abstraction as the radix drawer.Why Viewport is kept internally:
DrawerViewportwas removed from the public API, butDrawerPrimitive.Viewportis retained in the internal composition. Base UI emits a dev warning whenPopuprenders withoutViewportstarting from v1.4.0, so this wrapper follows that constraint.Direction layout ownership
The existing style files had
cn-drawer-contentwithdata-[vaul-drawer-direction=*]rules mixing layout (inset,position,width,max-height) and surface (rounded,border) together.This was reasonable when
vaulwas the only primitive, but with Base UI added, puttingdata-[swipe-direction=*]into the same token turns shared CSS tokens into a primitive branching table rather than a style surface.Comparing all 6 styles, the direction layout skeleton is largely identical across styles — what actually varies per style is surface (
rounded-*,border-*,before:*).Based on this analysis, ownership was reclassified:
inset-x-0,bottom-0,mt-24,max-h-[80vh],w-3/4,sm:max-w-sm--drawer-bleed-*,--drawer-transform, negative margin, compensating paddingbg-*,rounded-*,border-*,before:*, typographyPrinciple: primitives own layout, styles own surface.
The same principle was applied to the radix drawer. Moving layout to TSX only for Base UI while leaving it in CSS for radix would create an asymmetry: "base owns layout in TSX, radix owns layout in CSS."
Shared token cleanup
Merged separate
cn-base-ui-drawer-*/cn-radix-drawer-*tokens intocn-drawer-*, following the existing pattern where dialog/sheet already use sharedcn-dialog-*/cn-sheet-*tokens across radix and base.Post-merge token roles:
cn-drawer-overlaybg-*,backdrop-filter(animation in each TSX)cn-drawer-contentbg-*,rounded-*,border-*,before:*(layout in each TSX)cn-drawer-handlebg-*, size,rounded-full(direction visibility in each TSX)cn-drawer-headergap-*,p-*(direction alignment in each TSX)cn-drawer-titlecn-drawer-descriptioncn-drawer-footerDead code trade-off
registry:buildinlines shared CSS tokens into each base/style output as-is. Since it does not perform primitive-aware pruning, direction surface rules for the other primitive remain as dead code.Example:
data-[vaul-drawer-direction=bottom]:rounded-t-xlnever matches in base drawer outputs.This dead code is intentionally accepted:
rounded-*,border-*are theme-variable and cannot be moved to TSXnavigation-menu,dropdown-menu, andmenubaralready have shared tokens coexisting with primitive-specific selectorsIn other words, this change prioritizes the ownership model — shared stylesheets own theme surface, primitive wrappers own direction layout — over uniformly eliminating dead code.
Direction: reduce layout dead code, accept surface dead code.
Visual verification
Opened base/radix drawers across all 6 styles and compared overlay and content using
window.getComputedStyle().Properties compared:
backgroundColor,backdropFilter,opacitybackgroundColor,color,borderRadius,borderTopWidth,borderTopStyle,position,top/right/bottom/left,maxHeight,width,fontSize,marginTop,marginBottom,paddingOverlay showed no differences across all 6 styles for background, blur, and opacity.
Content is not numerically identical due to Base UI's bleed mechanic, but the differences are concentrated in bleed compensation, and the focus was on confirming that the user-facing visual output remains equivalent.
maxHeight80vh + 3rem80vhwidthcalc(100% + bleed)100%marginBottom-48px0pxpadding-bottom48px0pxThese differences stem from Base UI's swipe gesture bleed mechanic (
--drawer-bleed-y: 3rem). The bleed area is hidden off-screen via negative margin, so the user-facing visual output remains equivalent to radix.Parity verification
Checked base/radix parity:
cn-drawer-*tokens sharedswipe-direction, radix:vaul-drawer-directionswipe-direction+vaul-drawer-direction)API migration
Consumer changes (examples, blocks, app consumers, docs):
asChild→renderdirection→swipeDirectiontop/bottom→up/downCommit structure
This PR is split into 4 commits by design decision order, not file type:
refactor(base-drawer)— Base wrapper rewrite (2 files). Review the API surface here.refactor(drawer)— Direction rule ownership cleanup: moved layout and theme-invariant behavior from CSS to each primitive TSX (7 files). Review the ownership model here.fix(base-drawer)— Migrate all in-repo consumers (10 files). Mechanical API migration.chore— Regenerate registry outputs (41 files). Safe to skip.Commits 1–2 contain the design decisions. Commit 3 is follow-through. Commit 4 is generated.
Note: Commit 2 intentionally completes the base/radix direction selector migration as a single ownership change. Keeping the stylesheet-to-primitive migration in one commit makes the layout/surface ownership model easier to review across both implementations. Since this PR will be squash-merged, I prioritized keeping that refactor readable as one coherent step.
Verification
pnpm --filter=v4 typecheckpnpm --filter=v4 lintpnpm --filter=v4 registry:buildpnpm --filter=v4 build