Skip to content
Haze UI

Drawer

Modal panel that slides in from the right, left or bottom edge, with a header, scrolling body and footer, and swipe to dismiss.

pnpm dlx shadcn@latest add @haze/drawer
Open preview in a new tab
Livesmall script

When to use

  • Details of a list row, such as an issue or an order, without leaving the list
  • Filters or settings with more fields than fit in a popover
  • A bottom sheet of actions on small screens

When not to use

  • A short yes-or-no confirmation; use dialog
  • The site's main mobile menu when it only holds links; a popover is lighter
  • Content people need to see next to the page; a modal drawer blocks the page behind it

Installation

Add the Haze registry to components.json once, then install Drawer with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/drawer
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique on the page. Buttons target it with commandfor="<id>".
title*string–Heading; also the drawer's accessible name.
descriptionstring–One line under the title.
side"right" | "left" | "bottom""right"Screen edge the panel is attached to.
triggerbooleantrueSet to false when the opening button lives elsewhere.
triggerLabelstring"Open panel"Trigger text when the trigger slot is not used.
triggerVariant"primary" | "secondary" | "outline" | "ghost""outline"Trigger button style.
closeLabelstring"Close"Accessible name of the close button; translate it.
classstring–Extra classes on the panel, for example a wider width.
default slotslot–Body content; it scrolls when it is taller than the panel.
footer slotslot–Action buttons pinned to the bottom.
trigger slotslot–Custom trigger content.

Keyboard interactions

EnterSpace
Open the drawer from the trigger
TabShiftTab
Move between controls inside the drawer
Escape
Close the drawer and return focus to the trigger

Accessibility

  • The panel slides in from its edge over 300 ms and slides out again, and its backdrop fades with it; reduced-motion users get no animation.
  • Dragging the header toward the edge the panel came from (down for bottom, right for right, left for left) closes it: past 30 % of its size or faster than 0.5 px/ms it dismisses, otherwise it springs back over 200 ms. Reduced-motion users get no follow animation but the same threshold. The swipe is an extra; Escape, the close button and a backdrop click always work.
  • It is a modal <dialog>: while it is open the rest of the page cannot be reached by pointer, keyboard or screen reader.
  • Side panels leave at least 48 px of the page visible, so a tap on the backdrop can always close them.
  • Only the body scrolls; the title and the footer actions stay in view.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Drawer" with `npx shadcn@latest add @haze/drawer`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Drawer from "@/components/haze/ui/drawer.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/drawer.md

  • Customize with real content

    Adapt the Haze drawer ui for our product. Replace the demo values of these props with our real content: id, title, description, side, trigger, triggerLabel, triggerVariant, closeLabel, class, default slot, footer slot, trigger slot. Keep the layout, the heading level rules and these accessibility details: The panel slides in from its edge over 300 ms and slides out again, and its backdrop fades with it; reduced-motion users get no animation. Dragging the header toward the edge the panel came from (down for bottom, right for right, left for left) closes it: past 30 % of its size or faster than 0.5 px/ms it dismisses, otherwise it springs back over 200 ms. Reduced-motion users get no follow animation but the same threshold. The swipe is an extra; Escape, the close button and a backdrop click always work. It is a modal <dialog>: while it is open the rest of the page cannot be reached by pointer, keyboard or screen reader. Side panels leave at least 48 px of the page visible, so a tap on the backdrop can always close them. Only the body scrolls; the title and the footer actions stay in view. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using drawer, check it fits: use it when details of a list row, such as an issue or an order, without leaving the list; filters or settings with more fields than fit in a popover; a bottom sheet of actions on small screens. Avoid it when a short yes-or-no confirmation; use dialog; the site's main mobile menu when it only holds links; a popover is lighter; content people need to see next to the page; a modal drawer blocks the page behind it. Alternatives: @haze/dialog, @haze/popover.

Dependencies

  • npm: @lucide/astro
  • @haze/button
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog