WlDrawer

Side panel with focus management and Escape.
Components / Containers v0.1.0

Placement

Full example
<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>

Behavior

Full example
<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>

Panel positions

Right/left/top/bottom/full, controlled animation, details and footer actions.

Open the drawer from any side.

Full 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>