GitHub

Dropdown Menu

Dropdown menu triggered by a button

Basic Usage

Loading...

Installation

pnpm add @corew500/ui

Usage

import { DropdownMenu } from "@corew500/ui/dropdown-menu"

<DropdownMenu>Content</DropdownMenu>

CMS Integration

CMSPayload CMS Integration
This component supports CMS-driven content via @corew500/cms-payload.
Loading...

API Reference

Props

PropTypeDefaultDescription
defaultOpenenumfalseWhether the menu is initially open. To render a controlled menu, use the `open` prop instead.
loopFocusenumtrueWhether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.
highlightItemOnHoverenumtrueWhether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state.
modalenumtrueDetermines if the menu enters a modal state when open. - `true`: user interaction is limited to the menu: document page scroll is locked and pointer interactions on outside elements are disabled. - `false`: user interaction with the rest of the document is allowed.
onOpenChange(open: boolean, eventDetails: MenuRootChangeEventDetails) => voidEvent handler called when the menu is opened or closed.
onOpenChangeComplete(open: boolean) => voidEvent handler called after any animations complete when the menu is closed.
openenumWhether the menu is currently open.
orientationenum'vertical'The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys.
disabledenumfalseWhether the component should ignore user interaction.
closeParentOnEscenumfalseWhen in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu.
actionsRefRefObject<MenuRootActions>A ref to imperative actions. - `unmount`: When specified, the menu will not be unmounted when closed. Instead, the `unmount` function must be called to unmount the menu manually. Useful when the menu's animation is controlled by an external library. - `close`: When specified, the menu can be closed imperatively.
triggerIdstringID of the trigger that the popover is associated with. This is useful in conjunction with the `open` prop to create a controlled popover. There's no need to specify this prop when the popover is uncontrolled (i.e. when the `open` prop is not set).
defaultTriggerIdstringID of the trigger that the popover is associated with. This is useful in conjunction with the `defaultOpen` prop to create an initially open popover.
handleMenuHandle<unknown>A handle to associate the menu with a trigger. If specified, allows external triggers to control the menu's open state.

Accessibility

Keyboard Navigation

  • - Full keyboard navigation (Arrow keys, Enter, Escape)
  • Focus management with roving tabindex
  • Submenus accessible via right arrow key

Screen Readers

  • ARIA menu role with proper item roles
  • Checkbox/radio items announce checked state

Localization

Translatable Content

  • - Pass translated strings to DropdownMenuItem children
  • DropdownMenuLabel should contain localized group titles

Additional

  • Keyboard shortcuts in DropdownMenuShortcut are typically not localized

Related

Related Components