Drawer
Usage
Put the element that opens the drawer in the default slot, and what the drawer shows in the body and footer slots. By default, the drawer slides in from the end of the screen: the right in a left-to-right page.
<script setup lang="ts">
import { Download } from 'lucide-vue-next'
</script>
<template>
<KDrawer title="Acme Corp" description="Payment received on Nov 21, 2026." dividers>
<KButton label="Show transaction" />
<template #body>
<div
class="h-full rounded-lg border border-dashed border-line bg-[repeating-linear-gradient(-45deg,currentColor_0_1px,transparent_1px_10px)] light:text-stone-950/10 dark:text-white/10"
/>
</template>
<template #footer="{ close }">
<KButton label="Download receipt" variant="soft" color="gray" :leading-icon="Download" />
<KButton label="Edit" @click="close" />
</template>
</KDrawer>
</template>
The drawer works like the Modal: same slots, same title, description, dividers, translucent, close and dismissible props, and the same v-model:open. The page behind it can't be used until it closes. To open a drawer from your code and wait for what it returns, see useOverlay.
Side
Use the side prop to slide the drawer from the start, the end (default), the top or the bottom of the screen. start and end follow the reading direction: in a right-to-left page, end is on the left.
<script setup lang="ts">
const drawerSides = ['start', 'end', 'top', 'bottom'] as const
</script>
<template>
<div class="flex flex-wrap gap-3">
<KDrawer v-for="drawerSide in drawerSides" :key="drawerSide" :side="drawerSide" :title="`Side ${drawerSide}`">
<KButton :label="drawerSide" variant="outline" color="gray" />
<template #body>
<div
class="h-full min-h-48 rounded-lg border border-dashed border-line bg-[repeating-linear-gradient(-45deg,currentColor_0_1px,transparent_1px_10px)] light:text-stone-950/10 dark:text-white/10"
/>
</template>
</KDrawer>
</div>
</template>
A drawer at the top or the bottom takes the width of the screen, and the height of its content, up to the screen minus 96px.
Size
Use the size prop to make a drawer at the start or the end sm (384px), md (448px, default), lg (576px) or xl (672px) wide. On a small screen, it takes the whole width.
<script setup lang="ts">
const drawerSizes = ['sm', 'md', 'lg', 'xl'] as const
</script>
<template>
<div class="flex flex-wrap gap-3">
<KDrawer v-for="drawerSize in drawerSizes" :key="drawerSize" :size="drawerSize" :title="`Size ${drawerSize}`">
<KButton :label="drawerSize" variant="outline" color="gray" />
<template #body>
<div
class="h-full rounded-lg border border-dashed border-line bg-[repeating-linear-gradient(-45deg,currentColor_0_1px,transparent_1px_10px)] light:text-stone-950/10 dark:text-white/10"
/>
</template>
</KDrawer>
</div>
</template>
Detached from the edges
Set inset to keep the drawer 8px away from the edges of the screen, with rounded corners.
<script setup lang="ts">
import { Bell } from 'lucide-vue-next'
</script>
<template>
<KDrawer title="Notifications" size="sm" inset>
<KButton label="Notifications" variant="outline" color="gray" :leading-icon="Bell" />
<template #body>
<div
class="h-full rounded-lg border border-dashed border-line bg-[repeating-linear-gradient(-45deg,currentColor_0_1px,transparent_1px_10px)] light:text-stone-950/10 dark:text-white/10"
/>
</template>
</KDrawer>
</template>
Swipe to close
The user can drag the drawer toward its edge to close it, with a finger or the mouse. Past 35% of its size, or with a quick flick, the drawer closes; otherwise it slides back. Set :swipe-to-close="false" to turn it off. A drawer that can't be dismissed never moves.
<script setup lang="ts">
import { ListFilter } from 'lucide-vue-next'
</script>
<template>
<KDrawer title="Filters" description="Narrow down the transactions you see." side="bottom">
<KButton label="Filters" variant="outline" color="gray" :leading-icon="ListFilter" />
<template #body>
<div
class="h-48 rounded-lg border border-dashed border-line bg-[repeating-linear-gradient(-45deg,currentColor_0_1px,transparent_1px_10px)] light:text-stone-950/10 dark:text-white/10"
/>
</template>
<template #footer="{ close }">
<KButton label="Reset" variant="soft" color="gray" />
<KButton label="Show 42 transactions" @click="close" />
</template>
</KDrawer>
</template>
The swipe leaves fields, selected text and scrolled content alone. In a drawer at the bottom, dragging the body down closes the drawer only while the body is scrolled to the top; once scrolled, it scrolls back first.
Handle
A drawer at the top or the bottom shows a handle, the small bar that tells it can be dragged. Set :handle="false" to hide it, or handle to show it on a drawer at the start or the end.
<template>
<KDrawer title="Filters" side="bottom" :handle="false">
<KButton label="Filters" variant="outline" color="gray" />
</KDrawer>
</template>
Open state
Use v-model:open to open and close the drawer from your code, like a navigation opened by a menu button. The default slot can then stay empty.
The navigation is closed.
<script setup lang="ts">
import { Menu } from 'lucide-vue-next'
import { ref } from 'vue'
const isNavigationOpen = ref(false)
const navigationLinks = ['Dashboard', 'Transactions', 'Budgets', 'Reports']
</script>
<template>
<div class="flex flex-wrap items-center gap-3">
<KButton label="Menu" variant="ghost" color="gray" :leading-icon="Menu" square @click="isNavigationOpen = true" />
<p class="text-sm text-muted">The navigation is {{ isNavigationOpen ? 'open' : 'closed' }}.</p>
</div>
<KDrawer v-model:open="isNavigationOpen" title="Kuina" side="start" size="sm">
<template #body>
<nav class="flex flex-col gap-1">
<KButton
v-for="navigationLink in navigationLinks"
:key="navigationLink"
:label="navigationLink"
variant="ghost"
color="gray"
:pill="false"
:ui="{ content: 'justify-start' }"
@click="isNavigationOpen = false"
/>
</nav>
</template>
</KDrawer>
</template>
Behavior
The drawer closes when:
closeis called, or the close button is clicked;- Esc is pressed;
- a pointer goes down on the dark layer around it;
- it is swiped toward its edge.
The rest works like the Modal: the page behind can't be used and doesn't scroll, menus and selects inside work as usual, and the focus goes inside on open and back to the element that opened it on close.
Keyboard
| Key | Action |
|---|---|
| Enter Space | On the element, opens the drawer. |
| Tab | Moves through the drawer. |
| Esc | Closes the drawer, or shakes it when it can't be dismissed. |
Customization
Use the ui prop to change the classes of each part, and class for the drawer panel (panel). Your classes always win: rounded-none replaces the default rounded corners of a drawer at the bottom.
<template>
<KDrawer title="Filters" side="bottom" :ui="{ panel: 'rounded-none', handle: 'w-16' }">
<KButton label="Filters" />
</KDrawer>
</template>
The parts are those of the Modal, plus the handle.
API
Props
| Prop | Type | Default |
|---|---|---|
open | boolean | false |
title | string | |
description | string | |
side | 'start' | 'end' | 'top' | 'bottom' | 'end' |
size | 'sm' | 'md' | 'lg' | 'xl', for start and end | 'md' |
inset | boolean | false |
handle | boolean | true at the top and the bottom |
swipeToClose | boolean | true |
dividers | boolean | false |
translucent | boolean | false |
close | boolean | ButtonProps | true |
closeLabel | string | 'Close' |
dismissible | boolean | true |
ui | { layer?, overlay?, overlayEntering?, overlayLeaving?, overlayHidden?, panel?, panelEntering?, panelLeaving?, panelHidden?, handle?, header?, headerText?, title?, description?, actions?, body?, footer?, closeButton? } | |
class | string |
Slots
| Slot | Props | Description |
|---|---|---|
default | The element that opens the drawer. Optional with v-model:open. | |
header | { close } | Replaces the title, the description and the actions. |
title | Replaces the text of the title. | |
description | Replaces the text of the description. | |
actions | { close } | Buttons next to the title. |
body | { close } | The main content. Scrolls when it is too long. |
footer | { close } | The buttons at the bottom. |
content | { close } | Replaces everything inside the drawer, except the handle. |
Emits
| Event | Payload |
|---|---|
update:open | boolean |
closePrevented | |
afterOpen | |
afterClose |
Expose
| Method | Description |
|---|---|
open() | Opens the drawer. |
close() | Closes the drawer. |
shake() | Shakes the drawer sideways once. |