Drawer
On this page
Overview
A side panel that provides supplementary content or navigation.
The default slot holds all panel content and an accessible-label
should be set so screen readers can identify the panel per WCAG.
By default the drawer is an overlay that slides over content. When
the parent element has container-type: inline-size, the drawer
responds to the container width — appearing inline at wide widths
and switching to overlay at narrow widths. Add collapsible to
enable a collapse toggle (push at wide, overlap at narrow).
Edit element properties
#main {
padding: var(--rh-space-2xl, 32px);
}
import '@rhds/elements/rh-drawer/rh-drawer.js';
<meta itemprop="description" content="Minimal drawer. Click the trigger to slide the panel open.">
<div id="container">
<rh-drawer id="drawer" trigger-id="trigger">
<p>Panel content slotted here.</p>
</rh-drawer>
<div id="main">
<button id="trigger" aria-controls="drawer" aria-expanded="false">Toggle Drawer</button>
<p>Click the trigger to open the drawer panel.</p>
</div>
</div>
import { Drawer } from "@rhds/elements/react/rh-drawer/rh-drawer.js";
// NOTE: React 19+ does not require these wrapper imports.
// You can use the custom elements directly as-is.
export const Demo = () => (
<meta itemprop="description" content="Minimal drawer. Click the trigger to slide the panel open." />
<div id="container">
<Drawer id="drawer" trigger-id="trigger">
<p>Panel content slotted here.</p>
</Drawer>
<div id="main">
<button id="trigger" aria-controls="drawer" aria-expanded="false">Toggle Drawer</button>
<p>Click the trigger to open the drawer panel.</p>
</div>
</div>
);
Which side the panel appears on.
Overlay positioning mode. viewport fixes the panel to the viewport.
contained positions it within the nearest positioned ancestor.
When unset, auto-derived: contained if a named container context
exists, viewport otherwise.
Adds a collapse toggle so the panel can be expanded and collapsed. Without this attribute, the panel has no toggle.
Whether the drawer panel is open.
ID of the external trigger element that toggles the drawer open and closed. The referenced element receives click handling automatically and receives focus when the panel closes.
Accessible label for the drawer panel. When set, used as aria-label
on the panel. When omitted, the panel uses aria-labelledby referencing
the first heading found in slotted content.
Label for the close button. Overridden by the close-label slot.
Label for the collapse toggle. Overridden by the collapse-label slot.
Status
- Figma library:
-
In Progress - RH Elements:
-
In Progress - RH Shared Libs:
-
In Progress
When to use
Status checklist
| Property | Status | Meaning |
|---|---|---|
| Figma library |
|
Component is being designed in Figma |
| RH Elements |
|
Component is being developed for RH Elements |
| RH Shared Libs |
|
Component is being developed for RH Shared Libs |
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.