Drawer
Importing
Add rh-drawer to your page with this import statement:
<script type="module">
import '@rhds/elements/rh-drawer/rh-drawer.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
To learn more about installing RHDS elements on your site using an import map read our getting started docs.
Usage
<rh-drawer open>
<div slot="header">Header</div>
<div slot="body">Body</div>
<div slot="footer">Footer</div>
<div>
<h3>Main Content</h3>
<p>The default auto variant displays as inline at wide container widths and switches to
overlay below 992px.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</rh-drawer>
<script type="module">
import '@rhds/elements/rh-drawer/rh-drawer.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
rh-drawer
A drawer is a panel that slides in from the edge of its container, providing supplementary content or navigation without leaving the current page.
Slots
10
| Slot Name | Summary | Description |
|---|---|---|
fullscreen-label-expand
|
Accessible label for the fullscreen button when not fullscreen |
|
fullscreen-label-collapse
|
Accessible label for the fullscreen button when fullscreen |
|
close-label
|
Accessible label for the close button |
|
header
|
Header content for the panel |
|
body
|
Body content for the panel |
|
|
Footer content for the panel |
||
resize-label
|
Accessible label for the resize handle |
|
collapse-label-open
|
Accessible label for the collapse toggle when panel is open |
|
collapse-label-closed
|
Accessible label for the collapse toggle when panel is closed |
|
[default]
|
Page content displayed alongside the panel (not used with fixed variant) |
Attributes
7
| Attribute | DOM Property | Description | Type | Default |
|---|---|---|---|---|
variant
|
variant |
Controls the layout behavior of the drawer. |
|
|
position
|
position |
Which side the panel appears on. |
|
|
open
|
open |
Whether the drawer panel is open. |
|
|
trigger-id
|
triggerId |
Optional ID of the external trigger element. |
|
|
fullscreen
|
fullscreen |
Adds a fullscreen toggle button to the panel actions. |
|
|
panel
|
panel |
Controls the panel edge interaction.
|
|
|
storage-key
|
storageKey |
When set, persists open/closed state and panel width to sessionStorage under this key. |
|
|
Methods
3
| Method Name | Description |
|---|---|
show()
|
Opens the drawer panel. |
close()
|
Closes the drawer panel. |
toggle()
|
Toggles the drawer panel open/closed. |
Events
2
| Event Name | Description |
|---|---|
open
|
Fires when the drawer panel opens. |
close
|
Fires when the drawer panel closes. |
CSS Shadow Parts
9
| Part Name | Summary | Description |
|---|---|---|
panel
|
||
|
|
||
|
|
||
header
|
||
body
|
||
|
|
||
resize-handle
|
||
collapse-toggle
|
||
content
|
CSS Custom Properties
1
| CSS Property | Description | Default |
|---|---|---|
--rh-drawer-content-padding |
var(--rh-space-4xl, 64px)
|
Design Tokens
25
| Token | Description | Copy |
|---|---|---|
--rh-color-surface
|
|
|
--rh-font-family-body-text
|
Body text font family |
|
--rh-color-text-primary
|
|
|
--rh-space-sm
|
6px spacer |
|
--rh-space-md
|
8px spacer |
|
--rh-border-radius-default
|
3px border radius; Example: Card |
|
--rh-color-text-secondary
|
|
|
--rh-color-text-secondary-on-dark
|
Secondary text color for dark theme |
|
--rh-color-text-secondary-on-light
|
Secondary text color for light theme |
|
--rh-color-interactive-secondary-active
|
|
|
--rh-font-family-heading
|
Heading font family |
|
--rh-font-size-heading-sm
|
h5 heading font size |
|
--rh-font-weight-body-text-regular
|
Regular font weight |
|
--rh-space-xl
|
24px spacer |
|
--rh-box-shadow-sm
|
Small box shadow |
|
--rh-color-surface-light
|
Secondary surface (light theme) |
|
--rh-color-surface-dark
|
Tertiary surface (dark theme) |
|
--rh-color-icon-secondary
|
|
|
--rh-border-width-md
|
2px border width: Example: Alert |
|
--rh-color-interactive-primary-default
|
|
|
--rh-border-width-sm
|
1px border width; Example: Secondary CTA or Button |
|
--rh-color-border-subtle
|
|
|
--rh-space-lg
|
16px spacer |
|
--rh-space-2xl
|
32px spacer |
|
--rh-space-4xl
|
64px spacer |
|
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.