Drawer
Drawer slides in a panel from a screen edge that the user can drag to dismiss. Use it for mobile-style panels, especially bottom drawers. Install vaul in your app to use it.
- For a side panel without drag gestures, use Sheet.
- For a centered modal task, use Dialog.
- For a confirmation that forces a choice, use AlertDialog.
- Set
showHandle={false}on DrawerContent to remove the handle and its spacing. Dragging and dismissal stay the same.
This example also needs: Button.
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Composition
Examples
Scrollable content
Manual check: on a touch device, scroll DrawerBody, then drag the handle or frame to dismiss the drawer.
With header actions
Place a close button in DrawerHeader next to the title.
All variants
Set direction on the root to open the drawer from any edge.
Props
Drawer
Drawer adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerBody
DrawerBody adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerClose
DrawerClose adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerContent
| Prop | Type | Default | Description |
|---|---|---|---|
showHandle | boolean | true | Shows the handle on bottom drawers. Hiding it does not change dragging or dismissal. |
DrawerDescription
DrawerDescription adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerFooter
DrawerFooter adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerHeader
DrawerHeader adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerOverlay
DrawerOverlay adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerPortal
DrawerPortal adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerTitle
DrawerTitle adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerTrigger
DrawerTrigger adds no props of its own; it accepts the props of the element or primitive it wraps.
Drawer slides in a panel from a screen edge that the user can drag to dismiss. Use it for mobile-style panels, especially bottom drawers. Install vaul-vue in your app to use it.
- For a side panel without drag gestures, use Sheet.
- For a centered modal task, use Dialog.
- For a confirmation that forces a choice, use AlertDialog.
- Set
:show-handle="false"on DrawerContent to remove the handle and its spacing. Dragging and dismissal stay the same.
This example also needs: Button.
Installation
Install the following dependencies:
Copy and paste the following code into your project.
components/drawer/Drawer.vue components/drawer/DrawerBody.vue components/drawer/DrawerContent.vue components/drawer/DrawerDescription.vue components/drawer/DrawerFooter.vue components/drawer/DrawerHeader.vue components/drawer/DrawerOverlay.vue components/drawer/DrawerTitle.vue components/drawer/index.ts components/overlay-layout/overlay-layout.ts Keep each file at the path shown above it.
Paths are relative to
packages/vue/src/. Keep the same folders under your@/root, and the imports between files work without edits.
Usage
Examples
Scrollable content
Manual check: on a touch device, scroll DrawerBody, then drag the handle or frame to dismiss the drawer.
With header actions
Place a close button in DrawerHeader next to the title.
This example also needs:
All variants
Set direction on the root to open the drawer from any edge.
Props
Drawer
Drawer adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerBody
DrawerBody adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerContent
| Prop | Type | Default | Description |
|---|---|---|---|
showHandle | boolean | true | Shows the handle on bottom drawers. Hiding it does not change dragging or dismissal. |
DrawerDescription
DrawerDescription adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerFooter
DrawerFooter adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerHeader
DrawerHeader adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerOverlay
DrawerOverlay adds no props of its own; it accepts the props of the element or primitive it wraps.
DrawerTitle
DrawerTitle adds no props of its own; it accepts the props of the element or primitive it wraps.