overlaysdropdown-menu
DropdownMenu
Triggered action menu anchored to its child content.
Import#
Slot Structure#
Wrapper trigger with a floating menu portal containing grouped items.
Use contentProps and itemProps to forward native attributes, refs, and event handlers. Item handlers run before built-in menu behavior and can call preventDefault() to cancel activation.
Menu#
Item internals#
Examples#
Sizes#
Menu item size scale from sm to lg for compact and roomy density.
Account / Team#
An account dropdown with grouped actions, workspace switching, shortcut hints, and a destructive sign-out row.
Editor / View Options#
A workspace-style menu with recent files, nested submenus, checkbox toggles, and theme selection for keyboard and pointer testing.
Project / Release Actions#
A heavier project menu with move flows, release actions, mixed-content labels, and destructive project operations.
API Reference#
Attributes#
Slot
trigger6 attributesElement users activate to open the menu.
Data Attributes
| Data Attribute | Description |
|---|---|
| data-closed | State or slot attribute exposed for styling hooks and selectors. |
| data-disabled | Present when the component or item is disabled. |
| data-expanded | State or slot attribute exposed for styling hooks and selectors. |
ARIA Attributes
| ARIA Attribute | Description |
|---|---|
| aria-controls | References the controlled element while the related content is mounted. |
| aria-expanded | Indicates whether the controlled content is expanded. |
| aria-haspopup | Accessibility attribute forwarded by the rendered component. |
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
| checkedIcon | IconT.Name | icon-check | Icon used for checked checkbox items. |
| children | JSX.Element | — | Trigger content used to open the dropdown menu. |
| class | ClassValue | — | Class applied to the component root or trigger element. |
| classes | (OverlayMenuSharedClasses & DropdownMenuT.Classes) | undefined | — | Slot class overrides for menu sections. |
| contentBottom | OverlayMenuContentSlot | undefined | — | Content rendered after the resolved item groups. |
| contentProps | ElementProps<HTMLDivElement> | undefined | — | Additional attributes for each menu layer content element. |
| contentTop | OverlayMenuContentSlot | undefined | — | Content rendered before the resolved item groups. |
| defaultOpen | boolean | undefined | false | Initial open state when the component is uncontrolled. |
| disabled | boolean | undefined | false | Whether trigger interactions should be ignored. |
| gutter | number | undefined | 0 | Gap between the anchor and the content. |
| id | string | undefined | — | Unique base id used to derive trigger and content ids. |
| itemProps | ((props: DropdownMenuT.ItemRenderProps) => ElementProps<HTMLDivElement> | undefined) | undefined | — | Additional attributes for an interactive menu item. |
| itemRender | ComponentOrElement<DropdownMenuT.ItemRenderProps> | undefined | — | Custom renderer for individual items. |
| items | DropdownMenuT.Item[] | undefined | — | Items rendered in the menu body. |
| onClick | JSX.EventHandlerUnion<HTMLSpanElement, MouseEvent> | undefined | — | Root trigger click handler. |
| onKeyDown | JSX.EventHandlerUnion<HTMLSpanElement, KeyboardEvent> | undefined | — | Root trigger keyboard handler. |
| onOpenChange | ((open: boolean) => void) | undefined | — | Called whenever the menu requests an open state change. |
| open | boolean | undefined | — | Controlled open state of the menu. |
| overflowPadding | number | undefined | 4 | Padding applied to the overflow area when calculating the menu's position. |
| placement | OverlayMenuPlacement | undefined | — | Preferred content placement relative to the trigger or anchor point. |
| preventScroll | boolean | undefined | true | Whether body scroll should be locked while the menu is open. |
| ref | JSX.HTMLElementTags["span"] extends { ref?: infer Ref; } ? Ref : never | undefined | — | — |
| size | "sm" | "md" | "lg" | undefined | md | Menu item size variant. |
| style | JSX.CSSProperties | undefined | — | — |
| styles | (OverlayMenuSharedStyles & DropdownMenuT.Styles) | undefined | — | Slot style overrides for menu sections. |
| submenuIcon | IconT.Name | icon-chevron-right | Icon used for submenu trigger items. |
Items#
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | undefined | — | Controlled checked state for checkbox and radio items. |
| children | DropdownMenuT.Item[] | undefined | — | Nested menu items for creating submenus. |
| color | NonNullable<"default" | "destructive" | undefined> | undefined | — | Color theme variant for the menu item. |
| defaultChecked | boolean | undefined | — | Initial checked state for uncontrolled checkbox and radio items. |
| defaultOpen | boolean | undefined | — | Initial open state for submenus. |
| description | JSX.Element | — | Secondary description text displayed below the label. |
| disabled | boolean | undefined | false | Whether the item is non-interactive. |
| group | string | undefined | — | Radio group identifier. Radio items with the same group are mutually exclusive. |
| icon | IconT.Name | — | Icon name or custom element to display at the start of the item. |
| kbds | string[] | undefined | — | Array of keyboard shortcuts to display as keys. |
| label | JSX.Element | — | Primary label text or element. |
| onCheckedChange | ((checked: boolean) => void) | undefined | — | Event handler called when a checkbox item's state changes. |
| onSelect | (() => void) | undefined | — | Event handler called when the item is activated. |
| onValueChange | ((value: string) => void) | undefined | — | Event handler called when a radio item is selected. |
| open | boolean | undefined | — | Controlled open state for submenus. |
| type | OverlayMenuItemType | undefined | item | The type of menu item to render. |
| value | string | undefined | — | Radio item value reported by onValueChange and used for grouped selection. |