Drawer
Mobile-style drawer panel that slides in from the bottom of the screen.
Preview
Installation
npx sigma-ui@latest add drawerUsage
Drawer is built on top of the Reka UI Drawer.
<script setup lang="ts">
import { Button } from '@/components/ui/button';
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from '@/components/ui/drawer';
</script>
<template>
<Drawer>
<DrawerTrigger>Open</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Are you absolutely sure?</DrawerTitle>
<DrawerDescription>This action cannot be undone.</DrawerDescription>
</DrawerHeader>
<DrawerFooter>
<Button>Submit</Button>
<DrawerClose as-child>
<Button variant="outline">
Cancel
</Button>
</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
</template>- Use
v-model:openon<Drawer>to control the open state. swipeDirectionisdownby default. Set it toup,left, orrightto anchor the panel to another edge.- The user can close the drawer by dragging it toward its edge, clicking the overlay, or pressing Esc.
Examples
Responsive Dialog
Combine the Dialog and Drawer components to create a responsive dialog. It renders a Dialog on desktop and a Drawer on mobile.
API Reference
Drawer
Props
| Prop | Type | Default |
|---|---|---|
openv-model:open | boolean | - |
defaultOpen | boolean | - |
modalModality of the drawer.
| DrawerModal | - |
swipeDirectionDirection to swipe to dismiss. | SwipeDirection$1 | 'down' |
snapPointsPreset snap positions (fractions 0-1, pixels >1, or '148px'/'30rem' strings) | DrawerSnapPoint[] | - |
snapPointv-model:snapPoint | DrawerSnapPoint | null | - |
defaultSnapPoint | DrawerSnapPoint | null | - |
snapToSequentialPointsWhen true, snaps to the next sequential snap point (one step at a time). When false, snaps to the nearest snap point by distance. | boolean | false |
Events
| Event | Payload |
|---|---|
update:open | [value: boolean, details: DrawerOpenChangeDetails] |
update:openComplete | [value: boolean] |
update:snapPoint | [value: DrawerSnapPoint | null] |
Slots
| Slot | Scope |
|---|---|
defaultTrigger and content. | - |
DrawerContent
Props
| Prop | Type | Default |
|---|---|---|
forceMount | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
disableOutsidePointerEventsWhen | boolean | - |
initialFocusInitial focus target when the drawer opens.
| boolean | HTMLElement | null | - |
finalFocusFinal focus target when the drawer closes.
| boolean | HTMLElement | null | - |
Events
| Event | Payload |
|---|---|
escapeKeyDownEvent handler called when the escape key is down. Can be prevented. | [event: KeyboardEvent] |
pointerDownOutsideEvent handler called when a | [event: PointerDownOutsideEvent] |
focusOutsideEvent handler called when the focus moves outside of the | [event: FocusOutsideEvent] |
interactOutsideEvent handler called when an interaction happens outside the | [event: PointerDownOutsideEvent | FocusOutsideEvent] |
openAutoFocus | [event: Event] |
closeAutoFocus | [event: Event] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
DrawerDescription
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
DrawerFooter
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
DrawerHeader
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
DrawerOverlay
Props
| Prop | Type | Default |
|---|---|---|
forceMountKeep mounted for animation control. | boolean | - |
forceRenderRender even when inside a nested drawer. | boolean | false |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
DrawerTitle
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
Accessibility
Renders as a modal dialog following the Dialog (Modal) WAI-ARIA design pattern. Focus stays inside the drawer and returns to the trigger on close.
| Key | Description |
|---|---|
| Space | Opens or closes the drawer. |
| Enter | Opens or closes the drawer. |
| Tab | Moves focus to the next focusable element. |
| Shift + Tab | Moves focus to the previous focusable element. |
| Esc | Closes the drawer and moves focus to the trigger. |