Skip to content
Focsd homeFocsd homeFocsd
Forms

Dropdown menu

A list of actions opened from a button.

  • Tag: focsd-menu
  • Pattern: Menu button
  • Category: Overlays

Example

Actions Rename Duplicate Archive (locked) Delete
HTML
<focsd-menu label="Project actions">
<focsd-button slot="trigger">Actions</focsd-button>
<focsd-menu-item value="rename">Rename</focsd-menu-item>
<focsd-menu-item value="duplicate">Duplicate</focsd-menu-item>
<focsd-menu-item value="archive" disabled>Archive (locked)</focsd-menu-item>
<focsd-menu-item value="delete" variant="critical">Delete</focsd-menu-item>
</focsd-menu>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-menu.js';
</script>
<focsd-menu label="Project actions">…</focsd-menu>

API

Attributes

AttributePropertyTypeDefault
labellabelstring—
openopenbooleanfalse

Methods

MethodDescription
openMenu(edge)Open and focus the first or last item.
closeMenu()Close the menu.

Slots

SlotDescription
(default)The focsd-menu-item elements.
triggerThe button that opens the menu.

CSS parts

Style the inside of the component with ::part(), for example focsd-menu::part(menu).

PartDescription
menuThe menu element.

Accessibility

  • APG menu button: the trigger gets aria-haspopup="menu" and aria-expanded; items are role="menuitem".
  • Choosing an item fires focsd-select with detail.value, closes the menu and returns focus to the trigger.

Keyboard

KeyAction
Enter / Space / Arrow DownOpen at the first item
Arrow UpOpen at the last item
Arrow Up / DownMove (wrapping, skips disabled items)
Home / EndFirst / last item
Type a letterJump to an item
Enter / SpaceChoose the item
EscapeClose and return focus to the trigger
TabClose