WlDrawer
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Opening side.
Heading (when no header slot is provided).
Accessible panel name without a text heading.
Modal mode with backdrop.
Close by clicking the backdrop.
Close with Escape.
Locks page scrolling while the panel is open.
Opening and closing animation; defaults to WlConfig.motion (true).
Show the explicit close action.
Props ariaLabelledby, pt, size, width, initialFocus, models, handlers and slots can be edited in the SFC. See their descriptions in API.
Example
Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.
Code for your application
Vue SFC · current settings
<script setup lang="ts">
import { WlButton, WlDrawer } from "legato-ui";
import { ref } from "vue";
const visible = ref(false);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlButton @click="visible = true">{{ "Open drawer" }}</WlButton><WlDrawer
v-model:visible="visible"
header="About the material"
size="md"
:dismissible="true"
>
<p class="wl-text-body">{{ "Material details appear over the page." }}</p>
<template #footer><WlButton @click="visible = false">{{ "Done" }}</WlButton></template>
</WlDrawer>
</div>
</template>Panel positions
Right/left/top/bottom/full, controlled animation, details and footer actions.
Open the drawer from any side.
Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlCheckbox, WlDrawer, type WlDrawerPosition, WlTag } from "legato-ui";
import { ref } from "vue";
const visible = ref(false);
const position = ref<WlDrawerPosition>("right");
const motion = ref(true);
const saved = ref(false);
const positions = { right: "Right", left: "Left", top: "Top", bottom: "Bottom", full: "Full screen" } satisfies Record<WlDrawerPosition, string>;
function open(value: WlDrawerPosition): void {
position.value = value;
visible.value = true;
}
</script>
<template>
<div class="wl-stack" data-space="lg">
<WlCheckbox v-model="motion">{{ "Drawer animation" }}</WlCheckbox>
<div class="wl-inline" data-space="sm"><WlButton
v-for="(label, key) in positions"
:key="key"
size="sm"
@click="open(key)"
>{{ label }}</WlButton></div>
<WlDrawer
v-model:visible="visible"
header="Material details"
:position="position"
:motion="motion"
:pt="{ footer: { style: { flexWrap: 'wrap' } } }"
>
<div class="wl-stack" data-space="md">
<WlTag color="blue">{{ "Draft" }}</WlTag>
<h3 class="wl-text-subheading">{{ "Release plan" }}</h3>
<p class="wl-text-body">
{{ "Drawer" }} {{ positions[position] }}
{{ "contains the details; its footer holds the actions. Escape and the close button return to the page." }}
</p>
</div>
<template #footer>
<WlButton @click="visible = false">{{ "Close details" }}</WlButton>
<WlButton variant="primary" @click="saved = true; visible = false">{{ "Save details" }}</WlButton>
</template>
</WlDrawer>
<p class="wl-text-small" role="status">
{{ saved ? "Details saved in the local example." : "Open the drawer from any side." }}
</p>
</div>
</template>