Components

Drawer

A panel that slides in from the edge of the viewport.

A slide-in panel anchored to a viewport edge. Supports swipe-to-close on touch devices, focus trapping, and all four sides.

Anatomy

  • #trigger — element that opens the drawer
  • #handle — optional drag handle (shown at the top for bottom drawers)
  • #header — region with title and close control
  • #title — the drawer's accessible title
  • #description — supplementary text
  • #body — main content area
  • #footer — action buttons

Usage

Examples

Bottom drawer

<template>
  <Drawer side="bottom" title="Options">
    <template #trigger="{ toggle }">
      <button @click="() => toggle()">Open options</button>
    </template>
    <template #body>
      <p>Sheet content.</p>
    </template>
  </Drawer>
</template>

Disable swipe to close

<template>
  <Drawer :swipe-to-close="false" title="Required">
    <template #trigger="{ toggle }">
      <button @click="() => toggle()">Open</button>
    </template>
    <template #footer="{ close }">
      <button @click="() => close()">Done</button>
    </template>
  </Drawer>
</template>

Custom header

<template>
  <Drawer side="left">
    <template #trigger="{ toggle }">
      <button @click="() => toggle()">Menu</button>
    </template>

    <template #header="{ close, titleId }">
      <h2 :id="titleId">Navigation</h2>
      <button @click="() => close()"></button>
    </template>

    <template #body>
      <nav>...</nav>
    </template>
  </Drawer>
</template>

API Reference

Props

PropTypeDefaultDescription
side"left" | "right" | "top" | "bottom""right"Edge the drawer slides from.
titlestringConvenience title. Slot #title takes priority.
descriptionstringConvenience description. Slot #description takes priority.
insetnumber | string0Space between the drawer and the viewport edge.
closeOnBackdropClickbooleantrueClose when clicking the overlay.
swipeToClosebooleantrueAllow swiping the drawer closed on touch devices.
teleportstring | false"body"Teleport target.
asstring"div"Root element tag.
uiDrawerUiCSS class overrides.

Slots

SlotScoped propsDescription
trigger{ isOpen, open, close, toggle }Element that opens the drawer.
handleDrag handle element.
header{ close, titleId }Header region.
titleDrawer title. Defaults to the title prop.
descriptionDescription text. Defaults to the description prop.
body{ close, descriptionId }Main content area.
footer{ close }Action buttons region.

Exposed methods

MethodSignatureDescription
open(reason?, event?) => voidOpens the drawer.
close(reason?, event?) => voidCloses the drawer.
toggle(reason?, event?) => voidToggles the drawer.
titleIdstringAuto-generated id for the title element.
descriptionIdstringAuto-generated id for the description element.

Emits

EventPayloadDescription
open-change[open: boolean, details]Fired when the open state changes.

UI Options

KeyDescription
overlayThe backdrop overlay.
contentThe drawer panel.
headerThe header region.
titleThe title element.
descriptionThe description element.
bodyThe body region.
footerThe footer region.