Dropdown menu
A list of actions opened from a button.
Example
<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>import { Menu } from '@focsd-dev/react';
export function Example() { return <Menu label="Project actions">…</Menu>;}<script setup>import '@focsd-dev/components/focsd-menu.js';</script>
<template> <focsd-menu label="Project actions">…</focsd-menu></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-menu.js';
// template<focsd-menu label="Project actions">…</focsd-menu><script> import '@focsd-dev/components/focsd-menu.js';</script>
<focsd-menu label="Project actions">…</focsd-menu>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
label | label | string | — |
open | open | boolean | false |
Methods
| Method | Description |
|---|---|
openMenu(edge) | Open and focus the first or last item. |
closeMenu() | Close the menu. |
Slots
| Slot | Description |
|---|---|
(default) | The focsd-menu-item elements. |
trigger | The button that opens the menu. |
CSS parts
Style the inside of the component with ::part(), for example focsd-menu::part(menu).
| Part | Description |
|---|---|
menu | The menu element. |
Accessibility
- APG menu button: the trigger gets
aria-haspopup="menu"andaria-expanded; items arerole="menuitem". - Choosing an item fires
focsd-selectwithdetail.value, closes the menu and returns focus to the trigger.
Keyboard
| Key | Action |
|---|---|
| Enter / Space / Arrow Down | Open at the first item |
| Arrow Up | Open at the last item |
| Arrow Up / Down | Move (wrapping, skips disabled items) |
| Home / End | First / last item |
| Type a letter | Jump to an item |
| Enter / Space | Choose the item |
| Escape | Close and return focus to the trigger |
| Tab | Close |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.