Drawer
An edge-attached modal drawer supporting four sides, scrollable content, custom sizing, and draggable snap points.
A modal drawer that slides in from any of the four viewport edges, supporting content-fit sizing, vertical scrolling, and draggable snap points. The examples on this page use the Shadcn Rhea style preset.
Preview
Section titled “Preview”<wc-shadcn-drawer-root
style-profile="rhea"
a11y-label="Daily activity goal"
>
<wc-shadcn-drawer-trigger style-profile="rhea">
<wc-shadcn-button style-profile="rhea" variant="outline">
Open Drawer
</wc-shadcn-button>
</wc-shadcn-drawer-trigger>
<wc-shadcn-drawer-mask
style-profile="rhea"
></wc-shadcn-drawer-mask>
<wc-shadcn-drawer-content style-profile="rhea" side="bottom">
<wc-shadcn-drawer-handle
style-profile="rhea"
a11y-label="Resize drawer"
></wc-shadcn-drawer-handle>
<div class="mx-auto w-full max-w-sm">
<wc-shadcn-drawer-header style-profile="rhea">
<wc-shadcn-drawer-title style-profile="rhea">
Move Goal
</wc-shadcn-drawer-title>
<wc-shadcn-drawer-description style-profile="rhea">
Set your daily activity goal.
</wc-shadcn-drawer-description>
</wc-shadcn-drawer-header>
<div class="px-4 py-3 text-center">
<div class="text-4xl font-bold tabular-nums">350</div>
<div class="text-xs uppercase text-muted-foreground">
Calories / day
</div>
</div>
<wc-shadcn-drawer-footer style-profile="rhea">
<wc-shadcn-button style-profile="rhea">
Submit
</wc-shadcn-button>
<wc-shadcn-drawer-close style-profile="rhea">
<wc-shadcn-button style-profile="rhea" variant="outline">
Cancel
</wc-shadcn-button>
</wc-shadcn-drawer-close>
</wc-shadcn-drawer-footer>
</div>
</wc-shadcn-drawer-content>
</wc-shadcn-drawer-root>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases (@proto.ui/prototypes-shadcn/drawer).
import { ShadcnButton, ShadcnDrawerRoot, ShadcnDrawerTrigger, ShadcnDrawerMask, ShadcnDrawerContent, ShadcnDrawerHandle, ShadcnDrawerHeader, ShadcnDrawerTitle, ShadcnDrawerDescription, ShadcnDrawerFooter, ShadcnDrawerClose,} from '../proto-ui/components/react';<ShadcnDrawerRoot styleProfile="rhea"> <ShadcnDrawerTrigger styleProfile="rhea"> <ShadcnButton styleProfile="rhea" variant="outline"> Open Drawer </ShadcnButton> </ShadcnDrawerTrigger> <ShadcnDrawerMask styleProfile="rhea" /> <ShadcnDrawerContent styleProfile="rhea" side="bottom"> <ShadcnDrawerHandle styleProfile="rhea" /> <ShadcnDrawerHeader styleProfile="rhea"> <ShadcnDrawerTitle styleProfile="rhea">Move Goal</ShadcnDrawerTitle> <ShadcnDrawerDescription styleProfile="rhea"> Set your daily activity goal. </ShadcnDrawerDescription> </ShadcnDrawerHeader> <div className="flex-1 overflow-y-auto px-4">{/* Content */}</div> <ShadcnDrawerFooter styleProfile="rhea"> <ShadcnButton styleProfile="rhea">Submit</ShadcnButton> <ShadcnDrawerClose styleProfile="rhea"> <ShadcnButton styleProfile="rhea" variant="outline"> Cancel </ShadcnButton> </ShadcnDrawerClose> </ShadcnDrawerFooter> </ShadcnDrawerContent></ShadcnDrawerRoot>Composition
Section titled “Composition”DrawerRoot├── DrawerTrigger├── DrawerMask└── DrawerContent ├── DrawerHandle ├── DrawerHeader │ ├── DrawerTitle │ └── DrawerDescription └── DrawerFooter └── DrawerClose- Trigger and Close: Under modern presets like
rhea,TriggerandClosestay headless so you can nest a publicButtondirectly inside them. Undernew-york-v4, they retain outline button paint (with optionalwrapfor long labels). - Extent bounds: Use
minExtentandmaxExtentonContentwith neutral units ('logical','root-text','available', or'available-minus-root-text'). Vertical drawers fit their content height within the safe viewport cap; horizontal drawers default to a20root-textcap. - Snapping and accessibility: Passing a non-empty
snapPointsarray in(0, 1]enables namedseparatorsemantics onHandlewith Arrow keys andHome/Endresizing. PressingEscapeor clicking the backdrop dismisses the drawer and restores focus to the trigger.
Examples
Section titled “Examples”Position
Section titled “Position”Set side on Content to 'top', 'right', 'bottom', or 'left':
<div class="flex flex-wrap gap-3">
<wc-shadcn-drawer-root
style-profile="rhea"
a11y-label="Right Drawer"
>
<wc-shadcn-drawer-trigger style-profile="rhea">
<wc-shadcn-button style-profile="rhea" variant="outline">
Right
</wc-shadcn-button>
</wc-shadcn-drawer-trigger>
<wc-shadcn-drawer-mask
style-profile="rhea"
></wc-shadcn-drawer-mask>
<wc-shadcn-drawer-content style-profile="rhea" side="right">
<wc-shadcn-drawer-handle
style-profile="rhea"
></wc-shadcn-drawer-handle>
<wc-shadcn-drawer-header style-profile="rhea">
<wc-shadcn-drawer-title style-profile="rhea">
Right Drawer
</wc-shadcn-drawer-title>
<wc-shadcn-drawer-description style-profile="rhea">
Slides in from the right edge.
</wc-shadcn-drawer-description>
</wc-shadcn-drawer-header>
<wc-shadcn-drawer-footer style-profile="rhea">
<wc-shadcn-drawer-close style-profile="rhea">
<wc-shadcn-button style-profile="rhea" variant="outline">
Close
</wc-shadcn-button>
</wc-shadcn-drawer-close>
</wc-shadcn-drawer-footer>
</wc-shadcn-drawer-content>
</wc-shadcn-drawer-root>
</div>Scrollable Content
Section titled “Scrollable Content”Wrap the body region in a flex-1 overflow-y-auto container so header and footer controls stay anchored while long content scrolls:
<wc-shadcn-drawer-root
style-profile="rhea"
a11y-label="Release notes"
>
<wc-shadcn-drawer-trigger style-profile="rhea">
<wc-shadcn-button style-profile="rhea" variant="outline">
Scrollable Content
</wc-shadcn-button>
</wc-shadcn-drawer-trigger>
<wc-shadcn-drawer-mask
style-profile="rhea"
></wc-shadcn-drawer-mask>
<wc-shadcn-drawer-content style-profile="rhea" side="bottom">
<wc-shadcn-drawer-handle
style-profile="rhea"
></wc-shadcn-drawer-handle>
<wc-shadcn-drawer-header style-profile="rhea">
<wc-shadcn-drawer-title style-profile="rhea">
Release Highlights
</wc-shadcn-drawer-title>
<wc-shadcn-drawer-description style-profile="rhea">
Scroll through the notes while keeping header and footer
anchored.
</wc-shadcn-drawer-description>
</wc-shadcn-drawer-header>
<div class="flex-1 overflow-y-auto px-4 py-2 space-y-3">
<!-- Scrollable body items -->
</div>
<wc-shadcn-drawer-footer style-profile="rhea">
<wc-shadcn-drawer-close style-profile="rhea">
<wc-shadcn-button style-profile="rhea" variant="outline">
Close
</wc-shadcn-button>
</wc-shadcn-drawer-close>
</wc-shadcn-drawer-footer>
</wc-shadcn-drawer-content>
</wc-shadcn-drawer-root>Snap Points
Section titled “Snap Points”Configure snapPoints and defaultSnapPoint (or controlled snapPoint / snapPointChange) to snap between height fractions via drag gestures or arrow keys:
<wc-shadcn-drawer-root
style-profile="rhea"
a11y-label="Snap points drawer"
>
<wc-shadcn-drawer-trigger style-profile="rhea">
<wc-shadcn-button style-profile="rhea" variant="outline">
Open Snap Drawer
</wc-shadcn-button>
</wc-shadcn-drawer-trigger>
<wc-shadcn-drawer-mask
style-profile="rhea"
></wc-shadcn-drawer-mask>
<wc-shadcn-drawer-content
id="snap-drawer-content"
style-profile="rhea"
side="bottom"
>
<wc-shadcn-drawer-handle
style-profile="rhea"
a11y-label="Resize drawer height"
></wc-shadcn-drawer-handle>
<wc-shadcn-drawer-header style-profile="rhea">
<wc-shadcn-drawer-title style-profile="rhea">
Snap Points
</wc-shadcn-drawer-title>
<wc-shadcn-drawer-description style-profile="rhea">
Drag the handle or press Arrow Up / Down to switch between
50% and full height.
</wc-shadcn-drawer-description>
</wc-shadcn-drawer-header>
<wc-shadcn-drawer-footer style-profile="rhea">
<wc-shadcn-drawer-close style-profile="rhea">
<wc-shadcn-button style-profile="rhea" variant="outline">
Close
</wc-shadcn-button>
</wc-shadcn-drawer-close>
</wc-shadcn-drawer-footer>
</wc-shadcn-drawer-content>
</wc-shadcn-drawer-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#snap-drawer-content'), {
styleProfile: 'rhea',
side: 'bottom',
snapPoints: [0.5, 1],
defaultSnapPoint: 0.5,
});
</script>Custom Sizes & Locked Drag
Section titled “Custom Sizes & Locked Drag”Constrain drawer dimensions with maxExtent and set dragDismissible={false} to prevent accidental swipe dismissal while keeping Close buttons, Escape, and outside clicks active:
<wc-shadcn-drawer-root
style-profile="rhea"
a11y-label="Custom sized drawer"
>
<wc-shadcn-drawer-trigger style-profile="rhea">
<wc-shadcn-button style-profile="rhea" variant="outline">
Custom Size & Locked Drag
</wc-shadcn-button>
</wc-shadcn-drawer-trigger>
<wc-shadcn-drawer-mask
style-profile="rhea"
></wc-shadcn-drawer-mask>
<wc-shadcn-drawer-content
id="sized-drawer-content"
style-profile="rhea"
side="right"
>
<wc-shadcn-drawer-header style-profile="rhea">
<wc-shadcn-drawer-title style-profile="rhea">
Inspector Panel
</wc-shadcn-drawer-title>
<wc-shadcn-drawer-description style-profile="rhea">
Capped at 420px with drag dismissal disabled.
</wc-shadcn-drawer-description>
</wc-shadcn-drawer-header>
<wc-shadcn-drawer-footer style-profile="rhea">
<wc-shadcn-drawer-close style-profile="rhea">
<wc-shadcn-button style-profile="rhea" variant="outline">
Close
</wc-shadcn-button>
</wc-shadcn-drawer-close>
</wc-shadcn-drawer-footer>
</wc-shadcn-drawer-content>
</wc-shadcn-drawer-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#sized-drawer-content'), {
styleProfile: 'rhea',
side: 'right',
maxExtent: { unit: 'logical', value: 420 },
dragDismissible: false,
});
</script>Pass open for controlled mode and subscribe to openChange. Exposes openDrawer(), close(), and toggle() methods.
| Prop | Type | Default |
|---|---|---|
open | boolean | — |
defaultOpen | boolean | false |
disabled | boolean | false |
a11yLabel | string | '' |
styleProfile | ShadcnStyleProfile | 'inherit' |
Content
Section titled “Content”Exposes open, snapPoint, dragging, dragProgress, offsetPercentage, extentValid, requestSnapPoint(), and the snapPointChange event.
| Prop | Type | Default | Description |
|---|---|---|---|
side | 'top' 'right' 'bottom' 'left' | 'bottom' | — |
snapPoints | number[] | — | — |
snapPoint | number | — | — |
defaultSnapPoint | number | — | — |
minExtent | AvailableLayoutLength | { unit: 'logical', value: 0 } | — |
maxExtent | AvailableLayoutLength | by side | vertical { unit: 'available-minus-root-text', value: 6 } / horizontal { unit: 'root-text', value: 20 } |
dragDismissible | boolean | true | — |
dragDismissThreshold | number | 0.25 | — |
enterDuration | number | 500 | — |
leaveDuration | number | 500 | — |
styleProfile | ShadcnStyleProfile | 'inherit' | — |
| Prop | Type | Default |
|---|---|---|
passthrough | boolean | false |
enterDuration | number | 500 |
leaveDuration | number | 500 |
styleProfile | ShadcnStyleProfile | 'inherit' |
Handle / Trigger / Close
Section titled “Handle / Trigger / Close”| Prop | Type | Default |
|---|---|---|
Handle.disabled | boolean | false |
Handle.a11yLabel | string | 'Resize drawer' |
Trigger / Close.disabled | boolean | false |
Trigger / Close.wrap | boolean | false |
styleProfile | ShadcnStyleProfile | 'inherit' |
Header, Footer, Title, and Description accept only the optional styleProfile prop.