Skip to content
Haze UI

Smooth drawer

Centered bottom sheet built on native dialog with a drag handle, optional price badge header, snap heights and drag-to-dismiss.

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

When to use

  • Checkout reviews, plan confirmations or quick navigation need a refined bottom sheet modal
  • Touch and pointer users benefit from dragging a sculpted grab handle to expand or dismiss a sheet
  • A modal overlay requires native focus trapping, Escape dismissal and a backdrop without extra libraries

When not to use

  • Content should dock to the left or right screen edge; use drawer
  • A compact centered confirmation modal is needed; use dialog

Installation

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

pnpm dlx shadcn@latest add @haze/smooth-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 dialog ID targeted by commandfor on opening or closing buttons.
titlestring"Studio Annual Pass"Heading text used as the accessible name of the modal dialog.
descriptionstring"Review your plan details before confirming."Optional subtitle linked via aria-describedby.
pricestring–Optional formatted price rendered in a tabular-nums badge beside the title.
priceLabelstring–Optional micro-label rendered beneath the price badge.
badgestring–Optional eyebrow pill displayed above the sheet heading.
initialSnap"half" | "full""half"Starting snap height when the bottom sheet opens.
triggerbooleantrueRender the built-in opening button; set false when triggering externally.
triggerLabelstring"Open sheet"Label of the built-in trigger button when the trigger slot is empty.
triggerVariant"primary" | "secondary" | "outline" | "ghost""outline"Visual variant of the built-in trigger button.
closeLabelstring"Close"Accessible name for the explicit close button.
snapLabelstring"Toggle sheet height"Accessible name for the keyboard-accessible snap height toggle button.
classstring–Extra classes applied to the dialog panel.

Keyboard interactions

EnterSpace
Open the sheet from the trigger or toggle half/full snap height
TabShiftTab
Cycle focus through interactive elements inside the open sheet
Escape
Dismiss the bottom sheet and return focus to the trigger

Accessibility

  • Built on a native modal <dialog> with command/commandfor and closedby="any", trapping focus and handling Escape natively.
  • Includes both an explicit Close button inside <form method="dialog"> and a keyboard-operable snap height button alongside drag gestures.
  • Honors prefers-reduced-motion by disabling spring transitions and live drag translation.

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 "Smooth drawer" with `npx shadcn@latest add @haze/smooth-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 SmoothDrawer from "@/components/haze/ui/smooth-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/smooth-drawer.md

  • Customize with real content

    Adapt the Haze smooth-drawer ui for our product. Replace the demo values of these props with our real content: id, title, description, price, priceLabel, badge, initialSnap, trigger, triggerLabel, triggerVariant, closeLabel, snapLabel, class. Keep the layout, the heading level rules and these accessibility details: Built on a native modal <dialog> with command/commandfor and closedby="any", trapping focus and handling Escape natively. Includes both an explicit Close button inside <form method="dialog"> and a keyboard-operable snap height button alongside drag gestures. Honors prefers-reduced-motion by disabling spring transitions and live drag translation. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using smooth-drawer, check it fits: use it when checkout reviews, plan confirmations or quick navigation need a refined bottom sheet modal; touch and pointer users benefit from dragging a sculpted grab handle to expand or dismiss a sheet; a modal overlay requires native focus trapping, escape dismissal and a backdrop without extra libraries. Avoid it when content should dock to the left or right screen edge; use drawer; a compact centered confirmation modal is needed; use dialog. Alternatives: @haze/drawer, @haze/dialog.

Dependencies

  • npm: @lucide/astro
  • @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