Back to library

Dropdown Menu

Show a menu of actions for an item.

Recommended API

Property or elementTypeExample initial valueDescription
popovertargetMatching element IDPer instanceAssociate the trigger with a native popover.
role="menuitem"ARIA roleEdit, Duplicate, ArchiveMark focusable actions within the menu.

States

StateTriggerResult
openActivate Actions.The menu opens next to the trigger and focuses the first action.
navigatingUse Up, Down, Home or End.Focus moves among the actions.
dismissedSelect 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

VariableTypeDefaultDescription
--q-textcolor #28302aMain text and foreground color.
--q-mutedcolor #70776fColor for secondary text.
--q-font-sizelength 13pxBase size for the component text.
--q-accentcolor #344e41Accent for active controls, indicators and focus.
--q-surfacecolor #ffffffSurface for controls and cards.
--q-bordercolor #dce0d8Color for outlines and dividers.
--q-radiuslength 10pxBase corner radius.
--q-spacelength 4pxBase unit for gaps and padding.
--q-shadowshadow 0 4px 16px rgb(0 0 0 / 8%)Shadow behind raised elements.