Menu
The <Menu>
component allows you to define a menu element. It's useful when you want a list with options or actions.
It is structured in two parts <Menu>
and <Menu.Item>
. The <Menu>
contains the trigger and the button per default. You also can use the <Menu.Section>
which you can use to separate the menu items from each other.
There is also a companion component called <ActionMenu>
which you can use if you want to take some actions. You can have a look on how it works in the examples. It works quiet similar to the normal <Menu>
component. All you have to add are the <Menu.Item>
s.
Anatomy

-
Menu trigger: The element, such as a button or icon, that opens or activates the menu.
-
Section: Menus are made up of a section or multiple sections.
-
Section header: Contains a heading to name a section of a group of similar menu items.
-
Menu item: Represent an individual option or action within a Menu component.
Appearance
The appearance of a component can be customized using the variant
and size
props. These props adjust the visual style and dimensions of the component, available values are based on the active theme.
Property | Type | Description |
---|---|---|
variant | secondary | ghost | The available variants of this component. |
size | default | small | large | icon | The available sizes of this component. |
Usage
In general, Menus are used to hide less frequently used or advanced options until users specifically need them. This keeps the interface clean and focused on essential elements.
Menus are ideal for interactive UI elements, it is distincit from <Select>
, which is meant for form inputs and value selection.
Menus can speed up interactions for advanced users who are already familiar with the application. These users often rely on shortcuts and context-specific actions to work more efficiently.
Write menu label that is clear, concise (max. 24 characters) and avoid unnecessary verbs.
Organise your menu items based on priority, and put the most used items at the start of the menu.
Simple Menu with Action
In this example you can see a simple <Menu>
with some items to select. it is used when you need a to provide users with a set of of options that will result in a specific action being performed.
Menu with Sections
When you have mutliple menu items that can be categorized under different headings. This is particularly useful in complext menus with many options, you can use <Menu.Section>
and pass title
for the group name.
Disabled Menu Items
In this example the <Menu>
has set its prop disabeldKeys
. So you can't interact with the <Menu.Item>
anymore. Keep in mind, that you have to set an id to the <Menu.Item>
.
ActionMenu
The <ActionMenu>
is typically used to provide quick, context-specific actions related to an item or interface element. It is particularly useful in scenarios where speed and efficiency in selecting an action are crucial.
In this example, the <ActionMenu>
is used within a table to allow users to perform actions like viewing details of a ticket or deleting a ticket. When "View Details" is selected, a dialog displays key information about the selected ticket, including its ID, event name, and status. The "Delete" option removes the ticket from the list.
The example shows that the <ActionMenu>
is very similar to the standard <Menu>
component, offering flexibility and ease of use in various contexts.
ID | Event Name | Status | Action |
---|---|---|---|
TCK-001 | Champions League Final | Confirmed | |
TCK-002 | Rock Concert | Pending | |
TCK-003 | Broadway Show | Cancelled |
Menu with onOpenChange
property
Here you can see how the properties open
and onOpenChange
are used together with a <Button>
. A function handles the state for the menu. You just can open the <Menu>
with the external <Button>
component, not with the menu button.
A common use Case is also to open the <Menu>
with the keyboard.
Menu item opens Dialog
This Example shows how to open a <Dialog>
from a <Menu.Item>
. It is useful when a menu action requires additional user input or confirmation. Selecting the item opens a Dialog
where users can provide the necessary information or confirm their choice, making the interaction smooth and efficient.
Menu selection mode
Use multiple
selection mode when you want to allow users to select multiple options at once, providing flexibility in situations where multiple choices are valid and necessary.
Here you can see how the selectionMode
from <Menu>
works. In this example the selectionMode
is set to multiple
. If you open the items you can see a selected item.
Your preferences are : newsletter
Props
Menu
aria-describedby?
string;
aria-details?
string;
aria-label?
string;
aria-labelledby?
string;
autoFocus?
boolean | FocusStrategy;
children?
ReactNode;
defaultOpen?
boolean;
defaultSelectedKeys?
Iterable<Key> | "all";
dependencies?
readonly any[]
dir?
string;
disabled?
boolean;
disabledKeys?
Iterable<Key>;
disallowEmptySelection?
boolean;
escapeKeyBehavior?
"clearSelection" | "none";
'clearSelection'
hidden?
boolean;
id?
string;
inert?
boolean;
items?
Iterable<object>;
label?
ReactNode;
lang?
string;
onAction?
(key: Key) => void;
onAnimationEnd?
AnimationEventHandler<HTMLDivElement>;
onAnimationEndCapture?
AnimationEventHandler<HTMLDivElement>;
onAnimationIteration?
AnimationEventHandler<HTMLDivElement>;
onAnimationIterationCapture?
AnimationEventHandler<HTMLDivElement>;
onAnimationStart?
AnimationEventHandler<HTMLDivElement>;
onAnimationStartCapture?
AnimationEventHandler<HTMLDivElement>;
onAuxClick?
MouseEventHandler<HTMLDivElement>;
onAuxClickCapture?
MouseEventHandler<HTMLDivElement>;
onClick?
MouseEventHandler<HTMLDivElement>;
onClickCapture?
MouseEventHandler<HTMLDivElement>;
onClose?
() => void;
onContextMenu?
MouseEventHandler<HTMLDivElement>;
onContextMenuCapture?
MouseEventHandler<HTMLDivElement>;
onDoubleClick?
MouseEventHandler<HTMLDivElement>;
onDoubleClickCapture?
MouseEventHandler<HTMLDivElement>;
onGotPointerCapture?
PointerEventHandler<HTMLDivElement>;
onGotPointerCaptureCapture?
PointerEventHandler<HTMLDivElement>;
onLostPointerCapture?
PointerEventHandler<HTMLDivElement>;
onLostPointerCaptureCapture?
PointerEventHandler<HTMLDivElement>;
onMouseDown?
MouseEventHandler<HTMLDivElement>;
onMouseDownCapture?
MouseEventHandler<HTMLDivElement>;
onMouseEnter?
MouseEventHandler<HTMLDivElement>;
onMouseLeave?
MouseEventHandler<HTMLDivElement>;
onMouseMove?
MouseEventHandler<HTMLDivElement>;
onMouseMoveCapture?
MouseEventHandler<HTMLDivElement>;
onMouseOut?
MouseEventHandler<HTMLDivElement>;
onMouseOutCapture?
MouseEventHandler<HTMLDivElement>;
onMouseOver?
MouseEventHandler<HTMLDivElement>;
onMouseOverCapture?
MouseEventHandler<HTMLDivElement>;
onMouseUp?
MouseEventHandler<HTMLDivElement>;
onMouseUpCapture?
MouseEventHandler<HTMLDivElement>;
onOpenChange?
(isOpen: boolean) => void;
onPointerCancel?
PointerEventHandler<HTMLDivElement>;
onPointerCancelCapture?
PointerEventHandler<HTMLDivElement>;
onPointerDown?
PointerEventHandler<HTMLDivElement>;
onPointerDownCapture?
PointerEventHandler<HTMLDivElement>;
onPointerEnter?
PointerEventHandler<HTMLDivElement>;
onPointerLeave?
PointerEventHandler<HTMLDivElement>;
onPointerMove?
PointerEventHandler<HTMLDivElement>;
onPointerMoveCapture?
PointerEventHandler<HTMLDivElement>;
onPointerOut?
PointerEventHandler<HTMLDivElement>;
onPointerOutCapture?
PointerEventHandler<HTMLDivElement>;
onPointerOver?
PointerEventHandler<HTMLDivElement>;
onPointerOverCapture?
PointerEventHandler<HTMLDivElement>;
onPointerUp?
PointerEventHandler<HTMLDivElement>;
onPointerUpCapture?
PointerEventHandler<HTMLDivElement>;
onScroll?
UIEventHandler<HTMLDivElement>;
onScrollCapture?
UIEventHandler<HTMLDivElement>;
onSelectionChange?
(keys: Selection) => void;
onTouchCancel?
TouchEventHandler<HTMLDivElement>;
onTouchCancelCapture?
TouchEventHandler<HTMLDivElement>;
onTouchEnd?
TouchEventHandler<HTMLDivElement>;
onTouchEndCapture?
TouchEventHandler<HTMLDivElement>;
onTouchMove?
TouchEventHandler<HTMLDivElement>;
onTouchMoveCapture?
TouchEventHandler<HTMLDivElement>;
onTouchStart?
TouchEventHandler<HTMLDivElement>;
onTouchStartCapture?
TouchEventHandler<HTMLDivElement>;
onTransitionCancel?
TransitionEventHandler<HTMLDivElement>;
onTransitionCancelCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionEnd?
TransitionEventHandler<HTMLDivElement>;
onTransitionEndCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionRun?
TransitionEventHandler<HTMLDivElement>;
onTransitionRunCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionStart?
TransitionEventHandler<HTMLDivElement>;
onTransitionStartCapture?
TransitionEventHandler<HTMLDivElement>;
onWheel?
WheelEventHandler<HTMLDivElement>;
onWheelCapture?
WheelEventHandler<HTMLDivElement>;
open?
boolean;
"false"
placement?
Placement;
'bottom'
renderEmptyState?
() => ReactNode;
selectedKeys?
Iterable<Key> | "all";
selectionMode?
SelectionMode;
shouldFocusWrap?
boolean;
slot?
string | null;
null
value indicates that the local props completely override all props received from a parent.translate?
"yes" | "no";
trigger?
MenuTriggerType;
'press'
Menu.Item
aria-label?
string;
children?
ChildrenOrFunction<MenuItemRenderProps>;
dir?
string;
download?
string | boolean;
hidden?
boolean;
href?
string;
hrefLang?
string;
id?
Key;
inert?
boolean;
isDisabled?
boolean;
lang?
string;
onAction?
() => void;
onAnimationEnd?
AnimationEventHandler<HTMLDivElement>;
onAnimationEndCapture?
AnimationEventHandler<HTMLDivElement>;
onAnimationIteration?
AnimationEventHandler<HTMLDivElement>;
onAnimationIterationCapture?
AnimationEventHandler<HTMLDivElement>;
onAnimationStart?
AnimationEventHandler<HTMLDivElement>;
onAnimationStartCapture?
AnimationEventHandler<HTMLDivElement>;
onAuxClick?
MouseEventHandler<HTMLDivElement>;
onAuxClickCapture?
MouseEventHandler<HTMLDivElement>;
onClick?
(e: MouseEvent<FocusableElement, MouseEvent>) => void;
onPress
instead. onClick
is an alias for onPress
provided for compatibility with other libraries. onPress
provides
additional event details for non-mouse interactions.onClickCapture?
MouseEventHandler<HTMLDivElement>;
onContextMenu?
MouseEventHandler<HTMLDivElement>;
onContextMenuCapture?
MouseEventHandler<HTMLDivElement>;
onDoubleClick?
MouseEventHandler<HTMLDivElement>;
onDoubleClickCapture?
MouseEventHandler<HTMLDivElement>;
onGotPointerCapture?
PointerEventHandler<HTMLDivElement>;
onGotPointerCaptureCapture?
PointerEventHandler<HTMLDivElement>;
onHoverChange?
(isHovering: boolean) => void;
onHoverEnd?
(e: HoverEvent) => void;
onHoverStart?
(e: HoverEvent) => void;
onLostPointerCapture?
PointerEventHandler<HTMLDivElement>;
onLostPointerCaptureCapture?
PointerEventHandler<HTMLDivElement>;
onMouseDown?
MouseEventHandler<HTMLDivElement>;
onMouseDownCapture?
MouseEventHandler<HTMLDivElement>;
onMouseEnter?
MouseEventHandler<HTMLDivElement>;
onMouseLeave?
MouseEventHandler<HTMLDivElement>;
onMouseMove?
MouseEventHandler<HTMLDivElement>;
onMouseMoveCapture?
MouseEventHandler<HTMLDivElement>;
onMouseOut?
MouseEventHandler<HTMLDivElement>;
onMouseOutCapture?
MouseEventHandler<HTMLDivElement>;
onMouseOver?
MouseEventHandler<HTMLDivElement>;
onMouseOverCapture?
MouseEventHandler<HTMLDivElement>;
onMouseUp?
MouseEventHandler<HTMLDivElement>;
onMouseUpCapture?
MouseEventHandler<HTMLDivElement>;
onPointerCancel?
PointerEventHandler<HTMLDivElement>;
onPointerCancelCapture?
PointerEventHandler<HTMLDivElement>;
onPointerDown?
PointerEventHandler<HTMLDivElement>;
onPointerDownCapture?
PointerEventHandler<HTMLDivElement>;
onPointerEnter?
PointerEventHandler<HTMLDivElement>;
onPointerLeave?
PointerEventHandler<HTMLDivElement>;
onPointerMove?
PointerEventHandler<HTMLDivElement>;
onPointerMoveCapture?
PointerEventHandler<HTMLDivElement>;
onPointerOut?
PointerEventHandler<HTMLDivElement>;
onPointerOutCapture?
PointerEventHandler<HTMLDivElement>;
onPointerOver?
PointerEventHandler<HTMLDivElement>;
onPointerOverCapture?
PointerEventHandler<HTMLDivElement>;
onPointerUp?
PointerEventHandler<HTMLDivElement>;
onPointerUpCapture?
PointerEventHandler<HTMLDivElement>;
onPress?
(e: PressEvent) => void;
onPressChange?
(isPressed: boolean) => void;
onPressEnd?
(e: PressEvent) => void;
onPressStart?
(e: PressEvent) => void;
onPressUp?
(e: PressEvent) => void;
onScroll?
UIEventHandler<HTMLDivElement>;
onScrollCapture?
UIEventHandler<HTMLDivElement>;
onTouchCancel?
TouchEventHandler<HTMLDivElement>;
onTouchCancelCapture?
TouchEventHandler<HTMLDivElement>;
onTouchEnd?
TouchEventHandler<HTMLDivElement>;
onTouchEndCapture?
TouchEventHandler<HTMLDivElement>;
onTouchMove?
TouchEventHandler<HTMLDivElement>;
onTouchMoveCapture?
TouchEventHandler<HTMLDivElement>;
onTouchStart?
TouchEventHandler<HTMLDivElement>;
onTouchStartCapture?
TouchEventHandler<HTMLDivElement>;
onTransitionCancel?
TransitionEventHandler<HTMLDivElement>;
onTransitionCancelCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionEnd?
TransitionEventHandler<HTMLDivElement>;
onTransitionEndCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionRun?
TransitionEventHandler<HTMLDivElement>;
onTransitionRunCapture?
TransitionEventHandler<HTMLDivElement>;
onTransitionStart?
TransitionEventHandler<HTMLDivElement>;
onTransitionStartCapture?
TransitionEventHandler<HTMLDivElement>;
onWheel?
WheelEventHandler<HTMLDivElement>;
onWheelCapture?
WheelEventHandler<HTMLDivElement>;
ping?
string;
referrerPolicy?
HTMLAttributeReferrerPolicy;
rel?
string;
routerOptions?
undefined;
target?
HTMLAttributeAnchorTarget;
textValue?
string;
translate?
"yes" | "no";
value?
object;
Menu.Section
aria-label?
string;
children
ReactNode;
dependencies?
readonly any[]
dir?
string;
hidden?
boolean;
id?
Key;
inert?
boolean;
items?
Iterable<object>;
lang?
string;
onAnimationEnd?
AnimationEventHandler<HTMLElement>;
onAnimationEndCapture?
AnimationEventHandler<HTMLElement>;
onAnimationIteration?
AnimationEventHandler<HTMLElement>;
onAnimationIterationCapture?
AnimationEventHandler<HTMLElement>;
onAnimationStart?
AnimationEventHandler<HTMLElement>;
onAnimationStartCapture?
AnimationEventHandler<HTMLElement>;
onAuxClick?
MouseEventHandler<HTMLElement>;
onAuxClickCapture?
MouseEventHandler<HTMLElement>;
onClick?
MouseEventHandler<HTMLElement>;
onClickCapture?
MouseEventHandler<HTMLElement>;
onContextMenu?
MouseEventHandler<HTMLElement>;
onContextMenuCapture?
MouseEventHandler<HTMLElement>;
onDoubleClick?
MouseEventHandler<HTMLElement>;
onDoubleClickCapture?
MouseEventHandler<HTMLElement>;
onGotPointerCapture?
PointerEventHandler<HTMLElement>;
onGotPointerCaptureCapture?
PointerEventHandler<HTMLElement>;
onLostPointerCapture?
PointerEventHandler<HTMLElement>;
onLostPointerCaptureCapture?
PointerEventHandler<HTMLElement>;
onMouseDown?
MouseEventHandler<HTMLElement>;
onMouseDownCapture?
MouseEventHandler<HTMLElement>;
onMouseEnter?
MouseEventHandler<HTMLElement>;
onMouseLeave?
MouseEventHandler<HTMLElement>;
onMouseMove?
MouseEventHandler<HTMLElement>;
onMouseMoveCapture?
MouseEventHandler<HTMLElement>;
onMouseOut?
MouseEventHandler<HTMLElement>;
onMouseOutCapture?
MouseEventHandler<HTMLElement>;
onMouseOver?
MouseEventHandler<HTMLElement>;
onMouseOverCapture?
MouseEventHandler<HTMLElement>;
onMouseUp?
MouseEventHandler<HTMLElement>;
onMouseUpCapture?
MouseEventHandler<HTMLElement>;
onPointerCancel?
PointerEventHandler<HTMLElement>;
onPointerCancelCapture?
PointerEventHandler<HTMLElement>;
onPointerDown?
PointerEventHandler<HTMLElement>;
onPointerDownCapture?
PointerEventHandler<HTMLElement>;
onPointerEnter?
PointerEventHandler<HTMLElement>;
onPointerLeave?
PointerEventHandler<HTMLElement>;
onPointerMove?
PointerEventHandler<HTMLElement>;
onPointerMoveCapture?
PointerEventHandler<HTMLElement>;
onPointerOut?
PointerEventHandler<HTMLElement>;
onPointerOutCapture?
PointerEventHandler<HTMLElement>;
onPointerOver?
PointerEventHandler<HTMLElement>;
onPointerOverCapture?
PointerEventHandler<HTMLElement>;
onPointerUp?
PointerEventHandler<HTMLElement>;
onPointerUpCapture?
PointerEventHandler<HTMLElement>;
onScroll?
UIEventHandler<HTMLElement>;
onScrollCapture?
UIEventHandler<HTMLElement>;
onTouchCancel?
TouchEventHandler<HTMLElement>;
onTouchCancelCapture?
TouchEventHandler<HTMLElement>;
onTouchEnd?
TouchEventHandler<HTMLElement>;
onTouchEndCapture?
TouchEventHandler<HTMLElement>;
onTouchMove?
TouchEventHandler<HTMLElement>;
onTouchMoveCapture?
TouchEventHandler<HTMLElement>;
onTouchStart?
TouchEventHandler<HTMLElement>;
onTouchStartCapture?
TouchEventHandler<HTMLElement>;
onTransitionCancel?
TransitionEventHandler<HTMLElement>;
onTransitionCancelCapture?
TransitionEventHandler<HTMLElement>;
onTransitionEnd?
TransitionEventHandler<HTMLElement>;
onTransitionEndCapture?
TransitionEventHandler<HTMLElement>;
onTransitionRun?
TransitionEventHandler<HTMLElement>;
onTransitionRunCapture?
TransitionEventHandler<HTMLElement>;
onTransitionStart?
TransitionEventHandler<HTMLElement>;
onTransitionStartCapture?
TransitionEventHandler<HTMLElement>;
onWheel?
WheelEventHandler<HTMLElement>;
onWheelCapture?
WheelEventHandler<HTMLElement>;
title?
string;
translate?
"yes" | "no";
value?
object;