Skip to content

Design system

Documentation

DesignComponents / Drawer

Components / Drawer

Beta

Drawer

Show a focused side panel while preserving modal focus and bounded scrolling.

On this page

Examples

Side panel with bounded content

Focus stays inside the modal panel; the body scrolls while the header and footer remain visible.

Open a right-side project details panel

Try the placement

Choose an edge; side drawers expand to the available mobile width.

Drawer placement playground

When to use

Use Drawer for a related task or detail panel that should keep the current page in context. It reuses Dialog's modal focus handling, Escape behavior, portal, and scroll lock. On small screens the panel expands to the available width or height.

Usage

import { Button } from "@phuctech/ui/components/button";
import { Drawer, DrawerBody, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger } from "@phuctech/ui/components/drawer";

<Drawer>
<DrawerTrigger render={<Button type="button">Open details</Button>} />
<DrawerContent side="right">
  <DrawerHeader><DrawerTitle>Project details</DrawerTitle></DrawerHeader>
  <DrawerBody>Long content scrolls inside the panel.</DrawerBody>
</DrawerContent>
</Drawer>

API

Component API
PropTypeDefaultDescriptionConstraints
DrawerDialog root propsclosedControlled or uncontrolled modal visibility.Supports Dialog's open/defaultOpen/onOpenChange contract.
DrawerTriggerDialog trigger props—Opens the panel and provides focus return behavior.Use a visible public Button or IconButton through render.
DrawerContent side"left" | "right" | "top" | "bottom""right"Sets the edge and responsive panel shape.Side panels use up to 28rem width; top/bottom panels use up to 40rem height.
DrawerHeader / DrawerTitle / DrawerDescriptionDialog header/title/description props—Names and explains the panel task.Every drawer needs a title.
DrawerBodyHTMLDivElement props—The bounded, growing scroll region.Put long content here to keep the header and footer available.
DrawerFooter / DrawerCloseHTMLDivElement / Dialog close props—Stable actions and a close control.Keep a visible close or cancel action for touch users.

Tokens

Component tokens
TokenRoleEffective valueUsage
card / border / elevation-lgPanel surfaceDialog surface tokensKeeps the overlay aligned with the shared modal treatment.
motion tokens / reduced motionPanel transitionShared short motionMovement is removed when reduced motion is requested.

Accessibility

Drawer inherits Dialog's focus trap, Escape close, modal backdrop, and focus return. Provide a title and keep the body as the only growing scroll region; the trigger must have a visible label and the close action must remain reachable.

Do and don’t

Do

Use a concise title and separate a long body from persistent actions.

Don’t

Put a long multi-step workflow in a narrow panel when a page is clearer.

  • Dialog is the centered modal surface.
  • Popover is the non-modal anchored alternative.