ActionMenu (legacy)
- Deprecated
- Not reviewed for accessibility
An ActionMenu is an ActionList-based component for creating a menu of actions that expands through a trigger button.
Use new version of ActionMenu with composable API, design updates and accessibility fixes.
<ActionMenuanchorContent="Menu"onAction={fn}items={[{text: 'New file'},{text: 'Copy link'},{text: 'Edit file'},ActionMenu.Divider,{text: 'Delete file', variant: 'danger'},]}overlayProps={{width: 'small'}}/>
<ActionMenu><ActionMenu.Button>Menu</ActionMenu.Button><ActionMenu.Overlay width="small"><ActionList><ActionList.Item onSelect={fn}>New file</ActionList.Item><ActionList.Item>Copy link</ActionList.Item><ActionList.Item>Edit file</ActionList.Item><ActionList.Divider /><ActionList.Item variant="danger">Delete file</ActionList.Item></ActionList></ActionMenu.Overlay></ActionMenu>
Or continue using deprecated API:
import {ActionMenu} from '@primer/react/deprecated'
| Name | Type | Default | Description | 
|---|---|---|---|
| items | ItemProps[] | undefined | Required. A list of item objects conforming to the ActionList.Itemprops interface. | 
| renderItem | (props: ItemProps) => JSX.Element | ActionList.Item | Optional. If defined, each item in itemswill be passed to this function, allowing forActionList-wide custom item rendering. | 
| groupMetadata | GroupProps[] | undefined | Optional. If defined, ActionListwill groupitemsintoActionList.Groups separated byActionList.Divideraccording to theirgroupIdproperty. | 
| renderAnchor | (props: ButtonProps) => JSX.Element | Button | Optional. If defined, provided component will be used to render the menu anchor. Will receive the selected Itemtext aschildrenprop when an item is activated. | 
| anchorContent | React.ReactNode | undefined | Optional. If defined, it will be passed to the trigger as the elements child. | 
| onAction | (props: ItemProps) => void | undefined | Optional. If defined, this function will be called when a menu item is activated either by a click or a keyboard press. | 
| open | boolean | undefined | Optional. If defined, ActionMenu will use this to control the open/closed state of the Overlay instead of controlling the state internally. Should be used in conjunction with the setOpenprop. | 
| setOpen | (state: boolean) => void | undefined | Optional. If defined, ActionMenu will use this to control the open/closed state of the Overlay instead of controlling the state internally. Should be used in conjunction with the openprop. |