Skip to Content
Getting startedFoundationsComponentsPackagesTools

Drawer

A panel that slides in from the edge, over the page: settings, a record, a set of filters.

Examples

Playground

Size

Modal's widths: sm (400px) for a short form, md (560px) for most, lg (720px) for a record.

sm
md
lg

Side

`end` by default, for details and settings; `start` for navigation or filters that read before the content. Logical, so they follow the writing direction.

end
start

Install

npx shadcn add @hipuku/drawer

Usage

import { Drawer } from '@/components/haus/components/Drawer'

<Drawer open={open} onClose={() => setOpen(false)} title="Filters">
  {filters}
</Drawer>

API

Drawer also takes its element's own attributes and forwards its ref. className lands on the backdrop and dialogClassName on the panel.

PropTypeDescription
openrequiredboolean
onCloserequired() => void
size"sm" | "md" | "lg" | "xl"
footerReact.ReactNode
initialFocusReact.RefObject<HTMLElement | null>Where focus goes when the dialog opens. Defaults to the dialog itself, which is safe and says nothing: a screen reader announces the dialog and the user tabs from the top. Point it at the primary action when there is an obvious one, or at the first field on a form.
dismissOnBackdropbooleanWhether clicking the backdrop closes the dialog. On by default, and worth turning off for anything destructive or anything holding unsaved input: a misplaced click should not discard work, and there was no way to say so.
dialogClassNamestringLands on the dialog rather than the backdrop, where className used to. Ruling B5 put className on the root, here the backdrop, and this is the named second target it asks for.
side"start" | "end"Which edge it comes from. Logical: end is the right edge in a left-to-right page.

Side

side is end by default, which is the right edge on a left-to-right page and flips for right-to-left. size sets the panel's width.

A Drawer is a Modal anchored to an edge. For a dialog in the middle of the page, use Modal.

Accessibility

  • Needs a name: title, or aria-label when there is no visible title.
  • Focus moves in on open and returns on close. Tab stays in the panel, and Escape closes it.
  • The page behind does not scroll while it is open.

On this page