Dropdown Menu
Show a menu of actions for an item.
Recommended API
| Property or element | Type | Example initial value | Description |
|---|---|---|---|
popovertarget | Matching element ID | Per instance | Associate the trigger with a native popover. |
role="menuitem" | ARIA role | Edit, Duplicate, Archive | Mark focusable actions within the menu. |
States
| State | Trigger | Result |
|---|---|---|
open | Activate Actions. | The menu opens next to the trigger and focuses the first action. |
navigating | Use Up, Down, Home or End. | Focus moves among the actions. |
dismissed | Select an action, press Escape or click outside. | The menu closes. Selecting an action also announces the selection. |
Svelte implementation guidance
Open the menu with the trigger; Arrow Up/Down and Home/End move focus. Selecting an item closes the menu and returns focus to the trigger. Escape and outside clicks dismiss it.
Use the included svelte source as the example. Keep IDs unique per instance and use the framework's normal lifecycle for any added listeners. Prefer a compatible existing accessible primitive when the project requires behavior beyond the example. Test the native Popover API and CSS anchor positioning in the target browsers.
CSS variables
| Variable | Type | Default | Description |
|---|---|---|---|
--q-text | color | #28302a | Main text and foreground color. |
--q-muted | color | #70776f | Color for secondary text. |
--q-font-size | length | 13px | Base size for the component text. |
--q-accent | color | #344e41 | Accent for active controls, indicators and focus. |
--q-surface | color | #ffffff | Surface for controls and cards. |
--q-border | color | #dce0d8 | Color for outlines and dividers. |
--q-radius | length | 10px | Base corner radius. |
--q-space | length | 4px | Base unit for gaps and padding. |
--q-shadow | shadow | 0 4px 16px rgb(0 0 0 / 8%) | Shadow behind raised elements. |