Overlays
Layout
Drawer
A panel that slides in from an edge of the screen. Use it for navigation, filters or details beside the page.
Install
import { Drawer } from 'vael-ui'Playground
md
dialog
undefined
Placement, behaviour and animation
right
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Drawer } from 'vael-ui'
const open = ref(false)
</script>
<template>
<Drawer v-model:open="open">
<p>This is the drawer body. Put any content here.</p>
</Drawer>
</template>Motion New
Dialog's motion, and Drawer's and BottomSheet's: values or hooks for its parts (DialogPart), how it opens and closes (morph, linked, exitOrder, resize) and swapped content. false turns it off.
<Drawer
:motion="{
initial: { panel: { opacity: 0, y: 8, scale: 0.98 } },
spring: { damping: 0.85, response: 0.35 },
}"
/>| Name | Type | Description |
|---|---|---|
initialexit | overlaypanelheadertitledescriptionbodyfootermaximizeclose | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
morphlinkedexitOrder | 'trigger' | Record<string, LinkedMotion> | 'reverse' | morph: 'trigger' grows it out of the element that opened it. linked moves other elements with it, such as the page receding behind it. exitOrder: 'reverse' closes its children first. |
swapresize | 'sync' | 'wait' | boolean | Content that changes while it's open crossfades ('sync') or waits for the old view to leave ('wait'), and the box eases to its new size unless resize: false. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
Follows the Dialog (modal) pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| Escape | Closes the drawer, unless closeOnEsc is false. |
| Tab | Moves focus to the next element in the drawer, wrapping from the last to the first. |
| ShiftTab | Moves focus to the previous element in the drawer, wrapping from the first to the last. |
- Drawer is a Dialog anchored to an edge, so it has the same roles, labels, focus behavior and inert page.
titlewiresaria-labelledbyanddescriptionwiresaria-describedby. Withouttitle, passaria-label.- Focus moves into the drawer on open and returns to the element that opened it on close.