Skip to content

DropdownMenu

Button-triggered menu for grouped actions.

<DropdownMenu
button={{label: 'Actions'}}
items={[ {icon: Edit, label: 'Edit'}, {icon: Archive, label: 'Archive'}, {type: 'divider'}, {icon: Trash2, label: 'Delete'}, ]}
/>
<DropdownMenu {...args}>
<DropdownMenuItem icon={Edit} label="Edit" />
<DropdownMenuItem icon={Archive} label="Archive" />
<DropdownMenuItem icon={Trash2} label="Delete" />
</DropdownMenu>
function KeepOpenOnSelectStory(
args: React.ComponentProps<typeof DropdownMenu>,
): React.JSX.Element {
const [zoom, setZoom] = useState(100);
return (
<DropdownMenu {...args} button={{label: `Zoom ${zoom}%`}}>
<DropdownMenuItem
hasCloseOnSelect={false}
icon={ZoomIn}
label="Zoom in"
onClick={() => setZoom(current => Math.min(current + 10, 200))}
/>
<DropdownMenuItem
hasCloseOnSelect={false}
icon={ZoomOut}
label="Zoom out"
onClick={() => setZoom(current => Math.max(current - 10, 50))}
/>
<DropdownMenuItem label="Reset" onClick={() => setZoom(100)} />
</DropdownMenu>
);
}
<KeepOpenOnSelectStory {...args} />
function CheckableItemsStory(
args: React.ComponentProps<typeof DropdownMenu>,
): React.JSX.Element {
const [isBookingBlocked, setIsBookingBlocked] = useState(true);
const [isShared, setIsShared] = useState(false);
const [sync, setSync] = useState<string>('busy');
return (
<DropdownMenu {...args} button={{label: 'Calendar options'}}>
<DropdownMenuItem
isSelected={isBookingBlocked}
label="Block client booking"
onClick={() => setIsBookingBlocked(current => !current)}
selectionMode="checkbox"
/>
<DropdownMenuItem
isSelected={isShared}
label="Share with team"
onClick={() => setIsShared(current => !current)}
selectionMode="checkbox"
/>
<Divider />
{syncOptions.map(option => (
<DropdownMenuItem
isSelected={sync === option.value}
key={option.value}
label={option.label}
onClick={() => setSync(option.value)}
selectionMode="radio"
/>
))}
<Divider />
<DropdownMenuItem icon={Trash2} label="Remove calendar" />
</DropdownMenu>
);
}
<CheckableItemsStory {...args} />
function CheckableItemsDataDrivenStory(
args: React.ComponentProps<typeof DropdownMenu>,
): React.JSX.Element {
const [isArchivedShown, setIsArchivedShown] = useState(false);
const [sortBy, setSortBy] = useState('Name');
return (
<DropdownMenu
{...args}
button={{label: 'View options'}}
items={[
{
isSelected: isArchivedShown,
label: 'Show archived',
onClick: () => setIsArchivedShown(current => !current),
selectionMode: 'checkbox',
},
{type: 'divider'},
{
items: sortOptions.map(option => ({
isSelected: sortBy === option,
label: option,
onClick: () => setSortBy(option),
selectionMode: 'radio',
})),
title: 'Sort by',
type: 'section',
},
]}
/>
);
}
<CheckableItemsDataDrivenStory {...args} />
<DropdownMenu
button={{label: 'Assign to'}}
items={clinicians.map(name => ({ label: name, startContent: <Avatar name={name} size="xsmall" />, }))}
/>
function WithAvatarsSelectableStory(
args: React.ComponentProps<typeof DropdownMenu>,
): React.JSX.Element {
const [clinician, setClinician] = useState(clinicians[0]);
return (
<DropdownMenu {...args} button={{label: clinician}}>
{clinicians.map(name => (
<DropdownMenuItem
isSelected={clinician === name}
key={name}
label={name}
onClick={() => setClinician(name)}
selectionMode="radio"
startContent={<Avatar name={name} size="xsmall" />}
/>
))}
</DropdownMenu>
);
}
<WithAvatarsSelectableStory {...args} />
<DropdownMenu
button={{label: 'Actions'}}
alignment="end"
items={[ {icon: Edit, label: 'Edit'}, {icon: Archive, label: 'Archive'}, {type: 'divider'}, {icon: Trash2, label: 'Delete'}, ]}
isMenuOpen
menuWidth={240}
offsetY={8}
placement="below"
/>
<DropdownMenu
button={{label: 'Actions'}}
items={[ {description: 'Modify this item', icon: Edit, label: 'Edit'}, {description: 'Move to archive', icon: Archive, label: 'Archive'}, {type: 'divider'}, {description: 'Permanently remove', icon: Trash2, label: 'Delete'}, ]}
/>
<DropdownMenu
button={{label: 'Actions'}}
items={[ { icon: Edit, label: 'Edit', tooltip: 'Change the item title and details.', }, { icon: Archive, label: 'Archive', tooltip: 'Move the item out of active lists without deleting it.', }, {type: 'divider'}, { icon: Trash2, label: 'Delete', tooltip: 'Permanently remove the item.', }, ]}
/>
<DropdownMenu {...args}>
<DropdownMenuItem
endContent={<Kbd keys="mod+e" />}
icon={Edit}
label="Edit"
/>
<DropdownMenuItem
endContent={<Kbd keys="mod+shift+a" />}
icon={Archive}
label="Archive"
/>
<DropdownMenuItem
endContent={<Kbd keys="backspace" />}
icon={Trash2}
label="Delete"
/>
</DropdownMenu>
<DropdownMenu
button={{label: 'Actions'}}
items={[ {icon: Edit, label: 'Edit'}, {icon: Archive, isDisabled: true, label: 'Archive'}, {type: 'divider'}, {icon: Trash2, isDisabled: true, label: 'Delete'}, ]}
/>
<DropdownMenu
button={{label: 'Actions'}}
items={[ { items: [ {icon: Edit, label: 'Edit'}, {icon: Archive, label: 'Archive'}, ], title: 'Actions', type: 'section', }, { items: [{icon: Trash2, label: 'Delete'}], title: 'Danger', type: 'section', }, ]}
/>
<DropdownMenu
button={{icon: MoreVertical, isIconOnly: true, label: 'More actions'}}
items={[ {icon: Edit, label: 'Edit'}, {icon: Archive, label: 'Archive'}, {type: 'divider'}, {icon: Trash2, label: 'Delete'}, ]}
/>
<div style={{display: 'flex', gap: '1rem'}}>
<DropdownMenu
button={{label: 'Small', size: 'sm'}}
items={[
{icon: Edit, label: 'Edit'},
{icon: Archive, label: 'Archive'},
{type: 'divider'},
{icon: Trash2, label: 'Delete'},
]}
/>
<DropdownMenu
button={{label: 'Medium'}}
items={[
{icon: Edit, label: 'Edit'},
{icon: Archive, label: 'Archive'},
{type: 'divider'},
{icon: Trash2, label: 'Delete'},
]}
/>
<DropdownMenu
button={{label: 'Large', size: 'lg'}}
items={[
{icon: Edit, label: 'Edit'},
{icon: Archive, label: 'Archive'},
{type: 'divider'},
{icon: Trash2, label: 'Delete'},
]}
/>
</div>
<DropdownMenu
button={{label: 'Actions', variant: 'ghost'}}
items={[ {icon: Edit, label: 'Edit'}, {icon: Archive, label: 'Archive'}, ]}
/>

Button-triggered menu for grouped actions.

PropTypeDefaultDescription
alignment"center" | "start" | "end"'start'Alignment along the placement axis.
buttonDropdownMenuButtonProps—Trigger button props.
childrenReactNode—Compound menu content (alternative to items).
classNamestring—Additional CSS class names applied to the menu surface.
data-testidstring—Test ID applied to the trigger button.
hasAutoFocusbooleantrueWhether to auto-focus the first menu item on open.
hasChevronbooleantrueWhether to show a chevron on the trigger button.
isMenuOpenboolean—Controlled open state.
itemsReadonlyArray<DropdownMenuOption>—Data-driven menu items.
menuWidthnumber | string—Width of the menu surface.
offsetXnumber—Gap in pixels between the menu and its trigger along the inline axis.
offsetYnumber—Gap in pixels between the menu and its trigger along the block axis.
onClick() => void—Click handler for the trigger button.
onOpenChange(isOpen: boolean) => void—Called when the menu open state changes.
placement"start" | "end" | "above" | "below"'below'Position relative to the trigger.
refRef<HTMLButtonElement>—Ref forwarded to the trigger button.
styleCSSProperties—Inline styles applied to the menu surface.

Action item inside a `DropdownMenu`.

PropTypeDefaultDescription
aria-keyshortcutsAriaAttributes['aria-keyshortcuts']—Keyboard shortcuts that activate the menu item.
classNamestring—Additional CSS class names applied to the item.
data-testidstring—Test ID applied to the item.
descriptionReactNode—Supporting text shown below the label.
endContentReactNode—Trailing content.
hasCloseOnSelectbooleantrue, or false when `selectionMode` is `'checkbox'`Whether activating the item closes the menu. Set to false for items users flip repeatedly, such as toggles, so the menu stays open with focus on the item.
iconIconComponent—Icon rendered before the label. Ignored when startContent is set.
isDisabledbooleanfalseWhether the item is disabled.
isSelectedbooleanfalseWhether a checkable item is checked. Only applies with selectionMode.
label*string—Item label.
onClick() => void—Called when the item is selected.
refRef<HTMLButtonElement>—Ref forwarded to the item button.
selectionMode"checkbox" | "radio"—Makes the item checkable. It renders as menuitemcheckbox or menuitemradio with aria-checked, and shows a leading check (checkbox) or dot (radio) when isSelected. Bound each radio set with dividers or a section so assistive tech knows which options belong together.
startContentReactNode—Leading visual content, such as an Avatar, rendered before the label in place of icon (when both are set, startContent wins). It is decorative: hidden from assistive tech and from typeahead, so the item's accessible name stays label. Keep it non-interactive. A checkable item still shows its selection indicator before it. An xsmall (24px) Avatar fits every menu size without growing the row.
styleCSSProperties—Inline styles applied to the item.
tooltipReactNode—Tooltip content shown when the item is hovered or focused.