Skip to main content
PROYECTOVIVIANA

Menu

Menus display a list of actions or options that a user can choose. They're triggered by a button and appear as a popover.

Import

import {
  Menu,
  MenuItem,
  MenuTrigger,
  MenuButton,
  MenuSeparator
} from '@proyecto-viviana/solid-spectrum';

Basic Usage

A simple menu with action items.

<MenuTrigger>
  <MenuButton>Actions</MenuButton>
  <Menu items={items}>
    {(item) => <MenuItem id={item.id}>{item.label}</MenuItem>}
  </Menu>
</MenuTrigger>

With Separators

Use separators to group related menu items.

<Menu items={items}>
  {(item) => item.isSeparator ? <MenuSeparator /> : <MenuItem id={item.id}>{item.label}</MenuItem>}
</Menu>

Disabled Items

Individual menu items can be disabled.

<MenuItem id="paste" isDisabled>
  Paste (clipboard empty)
</MenuItem>

Custom Trigger

Use any button as the menu trigger.

<MenuTrigger>
  <Button variant="accent">Open Menu</Button>
  <Menu items={items}>...</Menu>
</MenuTrigger>

Destructive Actions

Use the negative variant for destructive actions.

<MenuItem id="delete" isDestructive>
  Delete permanently
</MenuItem>

Last action: None

MenuTrigger Props

Props

PropTypeDefaultDescription
isOpenbooleanWhether the menu is open (controlled)
defaultOpenbooleanfalseWhether the menu is open by default
onOpenChange(isOpen: boolean) => voidHandler called when open state changes
childrenJSX.ElementTrigger button and Menu component

Menu Props

Props

PropTypeDefaultDescription
itemsT[]Collection of menu items
onAction(key: string) => voidHandler called when an item is selected
onClose() => voidHandler called when menu closes
disabledKeysIterable<string>Keys of disabled items
children(item: T) => JSX.ElementRender function for MenuItem/MenuSeparator

MenuItem Props

Props

PropTypeDefaultDescription
idstringUnique identifier for the item
textValuestringText value for typeahead
isDisabledbooleanfalseWhether the item is disabled
onAction() => voidHandler called when item is selected
childrenJSX.ElementItem content

Accessibility

  • Uses ARIA menu pattern with menu and menuitem roles
  • Arrow keys navigate between items
  • Home/End keys jump to first/last item
  • Escape closes the menu and returns focus to trigger
  • Type-ahead search jumps to matching items
  • Disabled items are focusable but not actionable (for context)