On this page

Drawer

Live examples of Drawer, with the exact Vue file that renders each one.

Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz. Press a button, then drag the drawer back to its edge, press Esc or use Cancel.

From the bottom

The default. The grab bar shows the drawer can be swiped down. One choice from a few, then Save.

DrawerBottom.vue
<script setup lang="ts">
import { ref } from 'vue'
import { Button } from '@/components/ui/button'
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from '@/components/ui/drawer'
import { Label } from '@/components/ui/label'
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'

const choices = [
  { value: '15m', label: 'Every 15 minutes' },
  { value: '1h', label: 'Every hour' },
  { value: '1d', label: 'Once a day' },
]
const chosen = ref('1h')
</script>

<template>
  <Drawer>
    <DrawerTrigger as-child>
      <Button variant="outline">Sync schedule</Button>
    </DrawerTrigger>
    <DrawerContent>
      <div class="mx-auto w-full max-w-sm">
        <DrawerHeader>
          <DrawerTitle>Sync schedule</DrawerTitle>
          <DrawerDescription>How often orders move from the online store to the ERP.</DrawerDescription>
        </DrawerHeader>
        <RadioGroup v-model="chosen" class="px-(--bh-space-modal)" aria-label="Sync schedule">
          <div v-for="choice in choices" :key="choice.value" class="flex items-center gap-(--bh-space-100)">
            <RadioGroupItem :id="`schedule-${choice.value}`" :value="choice.value" />
            <Label :for="`schedule-${choice.value}`">{{ choice.label }}</Label>
          </div>
        </RadioGroup>
        <DrawerFooter>
          <DrawerClose as-child>
            <Button variant="outline">Cancel</Button>
          </DrawerClose>
          <DrawerClose as-child>
            <Button>Save</Button>
          </DrawerClose>
        </DrawerFooter>
      </div>
    </DrawerContent>
  </Drawer>
</template>

From the side

swipe-direction="right" brings the drawer in from the end edge, without a grab bar.

DrawerSide.vue
<script setup lang="ts">
import { ListFilter } from '@lucide/vue'
import { ref } from 'vue'
import { Button } from '@/components/ui/button'
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from '@/components/ui/drawer'

const statuses = ['New', 'Paid', 'Shipped', 'Failed to sync']
const shown = ref<string[]>(['New', 'Paid'])

function toggle(status: string) {
  shown.value = shown.value.includes(status)
    ? shown.value.filter(s => s !== status)
    : [...shown.value, status]
}
</script>

<template>
  <!-- swipe-direction="right": the drawer comes in from the end edge and is swiped back to it. -->
  <Drawer swipe-direction="right">
    <DrawerTrigger as-child>
      <Button variant="outline"><ListFilter />Filters</Button>
    </DrawerTrigger>
    <DrawerContent>
      <DrawerHeader>
        <DrawerTitle>Filter orders</DrawerTitle>
        <DrawerDescription>Show orders with these statuses.</DrawerDescription>
      </DrawerHeader>
      <div class="flex flex-wrap gap-(--bh-space-100) px-(--bh-space-modal)">
        <Button
          v-for="status in statuses"
          :key="status"
          variant="outline"
          size="sm"
          :aria-pressed="shown.includes(status)"
          @click="toggle(status)"
        >
          {{ status }}
        </Button>
      </div>
      <DrawerFooter>
        <DrawerClose as-child>
          <Button variant="outline">Cancel</Button>
        </DrawerClose>
        <DrawerClose as-child>
          <Button>Apply</Button>
        </DrawerClose>
      </DrawerFooter>
    </DrawerContent>
  </Drawer>
</template>