Skip to content

Drawer

Open a panel from an edge of the screen.

Demos

Width

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy Drawer.vue and index.ts into app/components/ui/drawer/.

API

Variants and defaults

PropValuesDefault
widthxs, sm, md, lg, xlmd

width sets the floating surface width, independently of control size. The surface stays inside the viewport.

Props

PropTypeDefaultDescription
side"left" | "right" | "top" | "bottom""right"Edge the drawer slides from.
titlestring—Convenience title. Slot #title takes priority.
descriptionstring—Convenience description. Slot #description takes priority.
ariaLabelstring—Fallback accessible name when no title is rendered.
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.
uiDrawerUi—CSS class overrides.

Slots

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

Events

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

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.

Keyboard

KeyBehavior
Tab / Shift + TabCycles through focusable drawer controls.
EscapeCloses topmost drawer and restores prior focus.

Pointer and touch users can activate backdrop dismissal and configured swipe gestures. Keyboard users always have explicit controls and Escape.