Menu dropdown
Importing
Add rh-menu-dropdown to your page with this import statement:
<script type="module">
import '@rhds/elements/rh-menu-dropdown/rh-menu-dropdown.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
<div id="menu-dropdown-container">
<rh-menu-dropdown>
<span slot="toggle-label">Basic toggle</span>
<rh-menu-item>Action one</rh-menu-item>
<rh-menu-item>Action two</rh-menu-item>
<rh-menu-item>Action three</rh-menu-item>
<rh-menu-item disabled>Disabled Action</rh-menu-item>
<hr/>
<rh-menu-item>Separated action</rh-menu-item>
</rh-menu-dropdown>
</div>
<script type="module">
import '@rhds/elements/rh-menu-dropdown/rh-menu-dropdown.js';
import '@rhds/elements/rh-menu/rh-menu-item.js';
const dropdown = document.querySelector('rh-menu-dropdown');
dropdown.addEventListener('select', e => {
console.log('Selected:', e.text);
});
</script>
<style>
#menu-dropdown-container {
padding: 1rem;
rh-menu-dropdown {
width: 296px;
}
}
</style>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
rh-menu-dropdown
A menu dropdown presents a list of actions or links in a vertically stacked menu, appearing when a user interacts with a toggle button.
| Slot Name | Summary | Description |
|---|---|---|
|
Use this slot for the toggle label. Keep toggle labels short and succinct. |
||
|
Use this slot to provide the menu content. Use the "rh-menu" component
for the menu panel, and use "rh-menu-items" to define the individual menu items.
To organize menu items into groups, use the "rh-menu-item-group" component. |
| Attribute | DOM Property | Description | Type | Default |
|---|---|---|---|---|
|
|
open |
whether the dropdown is currently open. |
|
|
|
|
variant |
Defines the visual style of the dropdown. Setting it to 'borderless' removes the default border styling. |
|
|
|
|
layout |
The 'compact' layout reduces spacing and add the rh-icon |
|
|
|
|
disabled |
Disables user interaction with the dropdown. When true, the dropdown cannot be opened or interacted with, and appears visually disabled. |
|
|
|
|
accessibleLabel |
Provides an accessible name for the dropdown's trigger, improving screen reader support. This label is announced to assistive technologies to describe the purpose of the compact menu dropdown. |
|
|
| Method Name | Description |
|---|---|
|
|
|
|
|
Moves focus to the currently active (focused) item. |
| Token | Summary | Copy |
|---|---|---|
--rh-border-width-sm
|
|
|
--rh-color-text-primary
|
|
|
--rh-box-shadow-md
|
|
|
--rh-color-accent-base-on-light
|
|
|
--rh-color-accent-base-on-dark
|
|
|
--rh-font-family-body-text
|
|
|
--rh-font-size-body-text-md
|
|
|
--rh-font-weight-body-text-regular
|
|
|
--rh-line-height-code
|
|
|
--rh-space-sm
|
|
|
--rh-space-lg
|
|
|
--rh-border-radius-default
|
|
|
--rh-color-surface-lightest
|
|
|
--rh-color-surface-darkest
|
|
|
--rh-color-surface-lighter
|
|
|
--rh-color-surface-darker
|
|
|
--rh-length-3xs
|
|
|
--rh-color-gray-30
|
|
|
--rh-color-gray-40
|
|
|
--rh-space-md
|
|
|
--rh-color-gray-50
|
|
|
--rh-color-gray-60
|
|
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.