DropdownMenu
Button-triggered menu for grouped actions.
Examples
Section titled “Examples”Data Driven
Section titled “Data Driven”<DropdownMenu button={{label: 'Actions'}} items={[ {icon: Edit, label: 'Edit'}, {icon: Archive, label: 'Archive'}, {type: 'divider'}, {icon: Trash2, label: 'Delete'}, ]}/>Compound
Section titled “Compound”<DropdownMenu {...args}> <DropdownMenuItem icon={Edit} label="Edit" /> <DropdownMenuItem icon={Archive} label="Archive" /> <DropdownMenuItem icon={Trash2} label="Delete" /></DropdownMenu>Keep Open On Select
Section titled “Keep Open On Select”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} />Checkable Items
Section titled “Checkable Items”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} />Checkable Items Data Driven
Section titled “Checkable Items Data Driven”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} />With Avatars
Section titled “With Avatars”<DropdownMenu button={{label: 'Assign to'}} items={clinicians.map(name => ({ label: name, startContent: <Avatar name={name} size="xsmall" />, }))}/>With Avatars Selectable
Section titled “With Avatars Selectable”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} />End Aligned
Section titled “End Aligned”<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"/>With Descriptions
Section titled “With Descriptions”<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'}, ]}/>With Tooltips
Section titled “With Tooltips”<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.', }, ]}/>With Shortcuts
Section titled “With Shortcuts”<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>With Disabled Items
Section titled “With Disabled Items”<DropdownMenu button={{label: 'Actions'}} items={[ {icon: Edit, label: 'Edit'}, {icon: Archive, isDisabled: true, label: 'Archive'}, {type: 'divider'}, {icon: Trash2, isDisabled: true, label: 'Delete'}, ]}/>Sections
Section titled “Sections”<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', }, ]}/>Icon Only Trigger
Section titled “Icon Only Trigger”More actions
<DropdownMenu button={{icon: MoreVertical, isIconOnly: true, label: 'More actions'}} items={[ {icon: Edit, label: 'Edit'}, {icon: Archive, label: 'Archive'}, {type: 'divider'}, {icon: Trash2, label: 'Delete'}, ]}/>Size Variants
Section titled “Size Variants”<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>Ghost Trigger
Section titled “Ghost Trigger”<DropdownMenu button={{label: 'Actions', variant: 'ghost'}} items={[ {icon: Edit, label: 'Edit'}, {icon: Archive, label: 'Archive'}, ]}/>DropdownMenu
Section titled “DropdownMenu”Button-triggered menu for grouped actions.
| Prop | Type | Default | Description |
|---|---|---|---|
alignment | "center" | "start" | "end" | 'start' | Alignment along the placement axis. |
button | DropdownMenuButtonProps | — | Trigger button props. |
children | ReactNode | — | Compound menu content (alternative to items). |
className | string | — | Additional CSS class names applied to the menu surface. |
data-testid | string | — | Test ID applied to the trigger button. |
hasAutoFocus | boolean | true | Whether to auto-focus the first menu item on open. |
hasChevron | boolean | true | Whether to show a chevron on the trigger button. |
isMenuOpen | boolean | — | Controlled open state. |
items | ReadonlyArray<DropdownMenuOption> | — | Data-driven menu items. |
menuWidth | number | string | — | Width of the menu surface. |
offsetX | number | — | Gap in pixels between the menu and its trigger along the inline axis. |
offsetY | number | — | 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. |
ref | Ref<HTMLButtonElement> | — | Ref forwarded to the trigger button. |
style | CSSProperties | — | Inline styles applied to the menu surface. |
DropdownMenuItem
Section titled “DropdownMenuItem”Action item inside a `DropdownMenu`.
| Prop | Type | Default | Description |
|---|---|---|---|
aria-keyshortcuts | AriaAttributes['aria-keyshortcuts'] | — | Keyboard shortcuts that activate the menu item. |
className | string | — | Additional CSS class names applied to the item. |
data-testid | string | — | Test ID applied to the item. |
description | ReactNode | — | Supporting text shown below the label. |
endContent | ReactNode | — | Trailing content. |
hasCloseOnSelect | boolean | true, 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. |
icon | IconComponent | — | Icon rendered before the label. Ignored when startContent is set. |
isDisabled | boolean | false | Whether the item is disabled. |
isSelected | boolean | false | Whether a checkable item is checked. Only applies with selectionMode. |
label* | string | — | Item label. |
onClick | () => void | — | Called when the item is selected. |
ref | Ref<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. |
startContent | ReactNode | — | 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. |
style | CSSProperties | — | Inline styles applied to the item. |
tooltip | ReactNode | — | Tooltip content shown when the item is hovered or focused. |