Panel on an edge of the screen for filters, details and short tasks, without leaving the page.
Filters
The usual use: narrow a list without leaving it. Header, scrolling body and a footer with the actions.
Installation
Copies the component into src/design-system/ as your own source, with only the files it needs.
npx avesk-ui@latest add drawerBrings the 2 files it builds on (button.tsx, glyph.tsx). The first time, it also adds the tokens and the cn() helper, imports the tokens in globals.css and installs clsx and tailwind-merge. Files already in your project are kept unless you add --force.
Import
Lives in src/design-system/components/drawer.tsx.
import { Drawer, DrawerHeader, DrawerBody, DrawerFooter, useDrawer } from "@/design-system/components/drawer";Usage
<Drawer open={open} onOpenChange={setOpen}>
<DrawerHeader title="Filters" description="Narrow the invoice list." />
<DrawerBody>…</DrawerBody>
<DrawerFooter>
<Button onClick={reset}>Reset</Button>
<Button variant="primary" onClick={apply}>Show 24 invoices</Button>
</DrawerFooter>
</Drawer>Examples
Placement
start, end (default), top or bottom. Start and end follow the reading direction.
Long content
Side drawers take the full height; the body scrolls with the header held in place, and a soft blur appears under it.
Bottom sheet
placement="bottom" rises from the bottom, the natural home for actions on a phone. It grows up to 85% of the screen.
Sizes
Side drawers come in sm 320px, md 400px (default) and lg 600px, all capped by the screen.
When to use
Use it when
- Filtering a list without leaving it
- Reading the details of a row: a member, an invoice, a proposal's scope
- A bottom sheet of actions on a phone
Don’t use it when
- A short form or a confirmation → Dialog
- The content deserves its own URL → a page
- A short list of actions → Dropdown menu
Rules
- Always give it a DrawerHeader: its title names the drawer for screen readers
- Put the main action last in DrawerFooter; it sits on the right, and on top on phones
- Use placement="bottom" for action sheets on phones; side drawers for filters and details
- Pick the width for the content: sm for lists, md (default) for forms, lg for details
- No open or close animation: it appears and leaves at once
Properties
Drawer
| Prop | Type | Default |
|---|---|---|
open * | boolean | – |
onOpenChange * | (open: boolean) => void | – |
placement | "start" | "end" | "top" | "bottom" | "end" |
size | "sm" | "md" | "lg" | "md" |
aria-label | string | – |
className | string | – |
children * | ReactNode | – |
DrawerHeader
| Prop | Type | Default |
|---|---|---|
title * | ReactNode | – |
description | ReactNode | – |
closeLabel | string | "Close" |
className | string | – |
DrawerBody
| Prop | Type | Default |
|---|---|---|
children * | ReactNode | – |
className | string | – |
DrawerFooter
| Prop | Type | Default |
|---|---|---|
children * | ReactNode | – |
className | string | – |
* required
Accessibility
- Native <dialog>: focus moves inside and is trapped, Escape and the backdrop close it, focus returns to the trigger
- The page behind stops scrolling while it is open
- No open or close motion: it appears and leaves at once
- data-autofocus picks the element that gets focus on open
Related
Used in the Avesk app: Projects & Clients, Proposals & Scope.