Navigation
Menu
A disclosed list of links and commands.
import { ActionMenu, Menu } from 'faifo-design'Menu opens a panel of items from a trigger; items may be links, submit actions or disabled entries
with a description. ActionMenu is the menu of secondary commands of a record or a row, with named
groups.
#When to use
- Use it for actions that are available but not primary.
- Keep the one primary action outside the menu.
- Group related commands and name the groups; assistive technology reads the names.
#Examples
Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.
#Menu and action menu
Native disclosure supports links, submit actions, descriptions and disabled state.
Show codeHide code
#Grouped action menu
Groups name related commands for assistive technology; a separator precedes every group after the first.
More actions ···
Show codeHide code
#Contract
#Menus stay in view and name the choice they show
A menu panel opens from its trigger's start or end (align, mobileAlign). Where that
carries it past an edge of the viewport, as from a trigger in the middle of a phone row,
the runtime slides the open panel along the row until it is 8px inside, its leading edge
on a whole pixel; a panel the viewport holds stays where its trigger put it, and closing
forgets the move. The runtime hears every menu's toggle on its root as the event is
captured, so a menu an island draws after the runtime attached is placed too, and an open
panel is placed again when the viewport is resized. Consumers do not move panels with CSS.
placement="right" opens beside a side-rail trigger, aligned to its bottom edge;
shared runtime geometry keeps the panel inside its viewport and clipping parent.
A trigger replaces the label inside the summary, and the label still names the menu.
Where the trigger shows the choice in effect, as a filter or a period does, the label
names both, Cơ sở: Holiday Inn, as DatePresetPicker names its own: a name without the
choice the reader sees is one they cannot say to reach it (WCAG 2.5.3).
#API
Generated from the package source. A property without a description has none in the source yet.
#ActionMenuComponent
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
labelrequired | – | string | – |
itemsrequired | – | readonly MenuEntry[] | – |
selectionMode | Checked items represent one selection when single; default preserves checkbox menus. | 'single' | 'multiple' | – |
triggerAppearance | plain leaves the trigger without a frame, padding or fill: a bare hit area whose trigger content draws the face, such as an avatar or a tile matching its neighbours. Focus, open state and the panel stay the menu's. | 'button' | 'plain' | – |
open | – | boolean | – |
align | – | 'start' | 'end' | 'end' |
mobileAlign | Optional alignment below 768px when page actions wrap to the leading edge. | 'start' | 'end' | – |
size | compact sits in a row of list facets at their height. | 'default' | 'compact' | – |
count | How many choices are in effect, shown on the trigger. Zero shows nothing. | number | – |
search | – | MenuSearch | – |
placement | bottom (default) opens below the trigger. top opens above it, for a trigger near the bottom of a container that clips overflow — a fixed modal footer, say — where the panel would otherwise render past the container's edge and be cut off rather than merely overlapping content. right opens beside a rail trigger, aligned to its bottom edge. | 'top' | 'bottom' | 'right' | – |
triggerLabel | – | string | – |
#MenuComponent
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
labelrequired | – | string | – |
itemsrequired | – | readonly MenuEntry[] | – |
selectionMode | Checked items represent one selection when single; default preserves checkbox menus. | 'single' | 'multiple' | – |
trigger | Replaces the label inside the trigger — an icon, say. The label still names it. | JSXChild | – |
triggerAppearance | plain leaves the trigger without a frame, padding or fill: a bare hit area whose trigger content draws the face, such as an avatar or a tile matching its neighbours. Focus, open state and the panel stay the menu's. | 'button' | 'plain' | – |
open | – | boolean | – |
align | – | 'start' | 'end' | 'start' |
mobileAlign | Optional alignment below 768px when page actions wrap to the leading edge. | 'start' | 'end' | – |
size | compact sits in a row of list facets at their height. | 'default' | 'compact' | – |
count | How many choices are in effect, shown on the trigger. Zero shows nothing. | number | – |
search | – | MenuSearch | – |
placement | bottom (default) opens below the trigger. top opens above it, for a trigger near the bottom of a container that clips overflow — a fixed modal footer, say — where the panel would otherwise render past the container's edge and be cut off rather than merely overlapping content. right opens beside a rail trigger, aligned to its bottom edge. | 'top' | 'bottom' | 'right' | 'bottom' |
#Types
#MenuEntry
type MenuEntry = MenuItem | MenuLabel | MenuSeparator | MenuGroup#MenuGroup
A named set of related commands — what a guest in the house needs, what the cashier does. It renders role="group" named by its visible heading, so a screen reader announces the set and not only a line of text, and a separator is drawn before every group that follows another entry, so callers do not place one by hand.
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
kindrequired | – | 'group' | – |
labelrequired | – | string | – |
itemsrequired | – | readonly MenuItem[] | – |
#MenuItem
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
kind | – | 'item' | – |
labelrequired | – | string | – |
href | – | string | – |
name | – | string | – |
value | – | string | – |
form | – | string | – |
leading | – | JSXChild | – |
description | – | string | – |
disabled | – | boolean | – |
destructive | – | boolean | – |
checked | Turns the command into a menuitemcheckbox while preserving server-owned state. | boolean | – |
shortcut | Visible keyboard hint; the browser interaction remains owned by the application. | string | – |
viewport | Shows the item at one width only, as an action's viewport does. | 'phone' | 'wide' | – |
#MenuLabel
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
kindrequired | – | 'label' | – |
labelrequired | – | string | – |
hidden | – | boolean | – |
#MenuProps
The properties of Menu, listed above.
#MenuSeparator
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
kindrequired | – | 'separator' | – |
#Hooks
The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.
menumenu-triggermenu-trigger-countmenu-panelmenu-searchmenu-search-inputmenu-groupmenu-labelmenu-separatormenu-itemmenu-item-leadingmenu-item-copymenu-item-checkmenu-item-shortcut