Drawer
Side panels and form surfaces
Drawer
Panels that slide in from the screen edge, ideal for settings, forms, and auxiliary content.
Basic Usage
Basic Drawer
The common drawer pattern.
Demo will load when visible.
Direction
Drawers can slide in from the left or right.
Direction
Left and right drawers.
Demo will load when visible.
Custom Width
Custom Width
Fixed width drawer example.
Demo will load when visible.
Footer Slot
Use the footer slot to add action buttons.
<template>
<TxDrawer v-model:visible="visible" title="Form">
<form>
<input type="text" placeholder="Name" />
</form>
<template #footer>
<TxButton @click="visible = false">Cancel</TxButton>
<TxButton type="primary" @click="handleSave">Save</TxButton>
</template>
</TxDrawer>
</template>
Close Behavior
<template>
<!-- Disable mask click -->
<TxDrawer
v-model:visible="visible"
title="Persistent"
:close-on-click-mask="false"
>
<p>Close via the button only.</p>
</TxDrawer>
<!-- Disable Escape close -->
<TxDrawer
v-model:visible="visible2"
title="Disable Escape"
:close-on-press-escape="false"
>
<p>Escape key won't close this drawer.</p>
</TxDrawer>
</template>
Events
<template>
<TxDrawer
v-model:visible="visible"
title="Event Demo"
@open="handleOpen"
@close="handleClose"
>
<p>Content</p>
</TxDrawer>
</template>
API
Props
| Property | Type | Default | Description |
|---|---|---|---|
| visible | Controls drawer visibility | ||
| title | Title text | ||
| width | Drawer width | ||
| direction | leftright | Slide-in direction | |
| showClose | Show close button | ||
| closeOnClickMask | Close on mask click | ||
| closeOnPressEscape | Close on Escape key | ||
| zIndex | Custom z-index |
Events
| Property | Type | Default | Description |
|---|---|---|---|
| update:visible | - | Emitted on visibility change | |
| open | - | Emitted when opened | |
| close | - | Emitted when closed |
Slots
| Property | Type | Default | Description |
|---|---|---|---|
| default | - | - | Main content |
| footer | - | - | Footer area |
Interaction Contract
- The drawer root exposes
role="dialog"andaria-modal="true", with an instance-scopedaria-labelledbylink to the title. - Opening the drawer focuses the drawer root; hiding or unmounting restores focus to the element that was active before opening.
- The close button, mask click, and Escape close paths emit
update:visible(false)andcloseby default;closeOnClickMask=falseandcloseOnPressEscape=falseblock their respective paths. showClose=falseremoves the close button without changing mask or Escape behavior.