# Dropdown Menu

A menu of actions: icons, shortcuts, checkbox and radio entries, submenus, two-line entries, loading and empty states.

- Category: Core Elements
- Page: https://wunderui.com/components/dropdown-menu
- Tier: Free

## Install

```bash
npx wunderui-cli add dropdown-menu
```

## Import

```tsx
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuEmpty, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuLoading, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
```

## Minimal usage

Then use it:

```tsx
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Button } from "@/components/ui/button"
import { ChevronDown } from "lucide-react"

export function ProjectActions() {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger render={<Button variant="plain" />}>
        Options
        <ChevronDown data-icon="inline-end" />
      </DropdownMenuTrigger>
      <DropdownMenuContent>
        <DropdownMenuItem>Rename</DropdownMenuItem>
        <DropdownMenuItem>Duplicate</DropdownMenuItem>
        <DropdownMenuSeparator />
        <DropdownMenuItem variant="destructive">Delete project</DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}
```

Expected result: You see an Options button with a chevron. It opens a small menu with Rename, Duplicate and, after a rule, a red Delete project; a click on an entry or Escape closes it.

## Usage

```tsx
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuShortcut,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Button } from "@/components/ui/button"
import { ChevronDown, Copy, Pencil, Share2, Trash2 } from "lucide-react"

export function Example() {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger render={<Button variant="plain" />}>
        Actions
        <ChevronDown data-icon="inline-end" />
      </DropdownMenuTrigger>
      <DropdownMenuContent className="w-56">
        <DropdownMenuItem icon={<Pencil />} aria-keyshortcuts="F2">
          Rename
          <DropdownMenuShortcut>F2</DropdownMenuShortcut>
        </DropdownMenuItem>
        <DropdownMenuItem icon={<Copy />} aria-keyshortcuts="Meta+D">
          Duplicate
          <DropdownMenuShortcut>⌘D</DropdownMenuShortcut>
        </DropdownMenuItem>
        <DropdownMenuItem icon={<Share2 />}>Share</DropdownMenuItem>
        <DropdownMenuSeparator />
        <DropdownMenuItem icon={<Trash2 />} variant="destructive">
          Delete project
        </DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}
```

## When to use

### Use Dropdown Menu for

- A short list of actions behind a button, such as rename, duplicate and delete on a row
- Options that toggle or choose without leaving the page, such as view settings and sort order
- The account menu behind an avatar

### Use something else

- [Select](https://wunderui.com/components/select) for picking one value for a form field
- [Context Menu](https://wunderui.com/components/context-menu) for actions on a right click or a long press
- [Popover](https://wunderui.com/components/popover) for content with controls of its own, not a list of actions

## Keyboard

The trigger is a native button, so the browser provides focus and activation. Once the menu is open, focus is inside it and the arrow keys move between the entries.

| Key | Action |
|---|---|
| `Enter` or `Space` or `ArrowDown` | On the trigger: opens the menu and moves focus to its first entry. Arrow Up opens it and moves focus to the last entry. |
| `ArrowDown` or `ArrowUp` | Moves focus to the next or previous entry. Disabled entries are reached too, and focus wraps at the ends. |
| `Home` or `End` | Moves focus to the first or the last entry. |
| `A–Z` | Type-ahead: typing the start of a label moves focus to the next entry that begins with it. |
| `Enter` or `Space` | Runs the focused entry and closes the menu. A checkbox or radio entry with `closeOnClick={false}` toggles and keeps the menu open. |
| `ArrowRight` | On a submenu entry: opens the submenu and moves focus into it. Arrow Left closes it and returns to the entry. The directions swap in right-to-left layouts. |
| `Escape` | Closes the current level, the submenu first and then the menu, and returns focus to the trigger. |
| `Tab` | Closes the menu when focus leaves it. |

## Behavior

What the menu does with focus, state, content and motion.

- **Entries and activation:** Entries are menu items, checkbox items or radio items. A click or Enter runs the entry and closes the menu, and checkbox and radio entries do the same unless you keep the menu open.
- **Disabled entries:** A disabled entry is dimmed and cannot run, but it stays focusable and is announced as unavailable, as the WAI-ARIA menu pattern asks. Keyboard and screen reader users still see the action.
- **Focus:** Focus moves into the menu when it opens and returns to the trigger when it closes. You can send it somewhere else on close.
- **Modal:** A menu is modal by default: the page behind it is inert and does not scroll while it is open. You can turn that off to leave the page usable.
- **Position and size:** The menu opens 4 px below the trigger, aligned to its start, and flips to the other side when there is no room. It is as wide as its longest entry and scrolls when the room runs out.
- **Submenus:** A submenu opens on hover after 100 ms, and moving diagonally towards it does not close it. Arrow Right or Enter opens it at once, and in right-to-left layouts its side flips.
- **Selection:** A checkbox entry reports its checked state, and an indeterminate one shows a dash and counts as mixed. A radio group reports the chosen value, and the check fades in instantly.
- **Previews in these docs:** The menu is portalled to the end of the document and floats over the page. The previews here draw it inside the card and show it only while the whole card is on screen.
- **Opening and closing:** The menu fades in and scales up from the trigger while sliding 4 px in from its side, and closes a step faster. A submenu opens faster too, and one opened with the keyboard skips the transition.
- **Reduced motion:** With reduced motion the transition is off and the menu appears and disappears at once.

## Anatomy

- `DropdownMenu`: Holds the open state and links the trigger to the menu. Control it or leave it uncontrolled; it renders nothing itself.
- `DropdownMenuTrigger`: The element that opens the menu, usually a button. It opens on click, Enter, Space or Arrow Down and reports that it has a popup and whether it is expanded.
- `DropdownMenuContent`: The menu, with its own portal and positioner. It is as wide as its longest entry (8 to 20 rem), never taller than the room left, and hides when its trigger scrolls out of view.
- `DropdownMenuGroup`: Groups related entries. A label inside it becomes the accessible name of the group.
- `DropdownMenuLabel`: A heading for a group of entries. Inside a group it names the group, on its own it is a plain heading, and it is not an entry, so arrow keys skip it.
- `DropdownMenuItem`: An action that runs on click and closes the menu, with an optional icon, avatar, description or red destructive look. A disabled entry stays focusable so people can find it.
- `DropdownMenuShortcut`: The visible shortcut hint at the right of an entry. It is hidden from screen readers, so put the binding on the entry itself.
- `DropdownMenuSub`: Holds the open state of one submenu. It renders nothing itself.
- `DropdownMenuSubTrigger`: The entry that opens a submenu, with a chevron at the right. It opens on hover after 100 ms, with Arrow Right or with Enter.
- `DropdownMenuSubContent`: The submenu, flush against its entry on the side the text ends. It is smaller, so it opens a step faster than the main menu.
- `DropdownMenuCheckboxItem`: An entry that toggles an option, with a check at the right. An indeterminate state shows a dash for a select-all entry, and the menu can stay open while people toggle.
- `DropdownMenuRadioGroup`: Holds the chosen value of a set of radio entries and reports a change.
- `DropdownMenuRadioItem`: One choice of a radio group, with a check at the right while it is chosen.
- `DropdownMenuSeparator`: A one pixel rule between two sets of entries. Put the destructive entry after one.
- `DropdownMenuLoading`: A status line with a spinner for entries that are still loading. It is not an entry, so arrow keys skip it, and the content should be marked busy while it shows.
- `DropdownMenuEmpty`: A centred line for a menu with nothing to show, so it never opens as an empty box.
- `DropdownMenuPortal`: Moves the menu to the end of the document. The content already renders it, so you only need it for a custom container.
- `Checkbox Item Indicator`
- `Checkbox Item Mixed`
- `Item Avatar`
- `Radio Item Indicator`

## Best practices

### Do

- Name destructive entries after the action and the object, and use the destructive variant: Delete project, not Delete. The colour is a second cue, never the only one.
- Put the destructive entry last, after a separator, and the most used entries first.
- Disable an entry that does not apply right now instead of removing it. Arrow keys still reach it, so screen reader users learn that the action exists.
- Show a loading line while entries load and an empty line when there are none, with the content marked busy while loading. The menu never opens as an empty box.
- Put the shortcut in the shortcut part and the binding in aria-keyshortcuts, so a screen reader says Copy without reading out the keys.

### Don't

- Don't put links to pages in a Dropdown Menu. It is a menu of actions; navigation belongs in the Navbar menu or in plain links.
- Don't use it to pick a value for a form field. A Select or a Combobox shows the chosen value in the field itself.
- Don't pile up entries. Past seven or eight, split the menu into labelled groups, and never nest more than one submenu.

## API reference

### DropdownMenu

| Prop | Type | Default | Description |
|---|---|---|---|
| actionsRef | React.RefObject<MenuRoot.Actions \| null> |  | A ref to imperative actions. - `unmount`: Manually unmounts the menu. Call this after any externally controlled closing animation finishes. - `close`: When specified, the menu can be closed imperatively. |
| children | React.ReactNode \| PayloadChildRenderFunction<Payload> |  | The content of the menu. This can be a regular React node or a render function that receives the `payload` of the active trigger. |
| closeParentOnEsc | boolean | false | When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu. |
| defaultOpen | boolean | false | Whether the menu is initially open. To render a controlled menu, use the `open` prop instead. |
| defaultTriggerId | string \| null |  | ID of the trigger that the menu is associated with. This is useful in conjunction with the `defaultOpen` prop to create an initially open menu. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| handle | MenuHandle<Payload> |  | A handle to associate the menu with a trigger. If specified, allows external triggers to control the menu's open state. |
| highlightItemOnHover | boolean | true | Whether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state. |
| loopFocus | boolean | true | Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys. |
| modal | boolean | true | Determines if the menu enters a modal state when open. - `true`: user interaction is limited to the menu: document page scroll is locked and pointer interactions on outside elements are disabled. - `false`: user interaction with the rest o… |
| onOpenChange | ((open: boolean, eventDetails: MenuRoot.ChangeEventDetails) => void) |  | Event handler called when the menu is opened or closed. |
| onOpenChangeComplete | ((open: boolean) => void) |  | Event handler called after any animations complete when the menu is opened or closed. |
| open | boolean |  | Whether the menu is currently open. |
| orientation | "horizontal" \| "vertical" | 'vertical' | The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys. |
| triggerId | string \| null |  | ID of the trigger that the menu is associated with. This is useful in conjunction with the `open` prop to create a controlled menu. There's no need to specify this prop when the menu is uncontrolled (that is, when the `open` prop is not se… |

### DropdownMenuCheckboxItem

| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean |  | Whether the checkbox item is currently ticked. To render an uncontrolled checkbox item, use the `defaultChecked` prop instead. |
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| closeOnClick | boolean | false | Whether to close the menu when the item is clicked. |
| defaultChecked | boolean | false | Whether the checkbox item is initially ticked. To render a controlled checkbox item, use the `checked` prop instead. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| id | string |  |  |
| indeterminate | boolean |  | The mixed state: shows a dash and sets `aria-checked="mixed"`, and ignores `checked`. A click still reports `true`, so the parent turns everything on. |
| inset | boolean |  | Indents the entry to line up with entries that have an icon. |
| label | string |  | Overrides the text label to use when the item is matched during keyboard text navigation. |
| nativeButton | boolean | false | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button. |
| onCheckedChange | ((checked: boolean, eventDetails: MenuCheckboxItem.ChangeEventDetails) => void) |  | Event handler called when the checkbox item is ticked or unticked. |
| onClick | BaseUIComponentProps<'div', MenuCheckboxItemState>['onClick'] |  | The click handler for the menu item. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuContent

| Prop | Type | Default | Description |
|---|---|---|---|
| align | UseAnchorPositioningSharedParameters['align'] | "start" | How to align the popup relative to the specified side. Submenus and menubars default to `'start'`. |
| alignOffset | number \| OffsetFunction | 0 | Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object param… |
| children | React.ReactNode |  |  |
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| finalFocus | boolean \| React.RefObject<HTMLElement \| null> \| ((closeType: InteractionType) => boolean \| HTMLElement \| null \| void) |  | Determines the element to focus when the menu is closed. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (trigger or previously focused element). - `RefObject`: Move focus to the ref element. - `function`:… |
| id | string |  |  |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| side | UseAnchorPositioningSharedParameters['side'] | "bottom" | Which side of the anchor element to align the popup against. May automatically change to avoid collisions. Submenus and vertical menubars default to `'inline-end'`. |
| sideOffset | number \| OffsetFunction | 4 | Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object para… |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |
| submenu | boolean | false | Styles the content as a submenu: smaller shadow and a faster open. `DropdownMenuSubContent` sets it for you. |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuEmpty

| Prop | Type | Default |
|---|---|---|


Also accepts React.HTMLAttributes attributes.

### DropdownMenuGroup

| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode |  | The content of the component. |
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuItem

| Prop | Type | Default | Description |
|---|---|---|---|
| avatar | React.ReactNode |  | A leading 24 px avatar for an entry that stands for a person or a workspace. It takes the place of the icon, and the row stays 32 px. |
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| closeOnClick | boolean | true | Whether to close the menu when the item is clicked. |
| description | React.ReactNode |  | A second line under the label. The label names the entry and the line describes it; screen readers read them apart. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| icon | React.ReactNode |  | A leading icon, decorative and hidden from assistive technology. Pass a Lucide icon. |
| id | string |  |  |
| inset | boolean |  | Indents the entry to line up with entries that have a check or an icon. |
| label | string |  | Overrides the text label to use when the item is matched during keyboard text navigation. |
| nativeButton | boolean | false | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button. |
| onClick | BaseUIComponentProps<'div', MenuItemState>['onClick'] |  | The click handler for the menu item. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |
| variant | "default" \| "destructive" | "default" | `default` or `destructive`. The destructive look is red; also say it in the label. |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuLabel

| Prop | Type | Default | Description |
|---|---|---|---|
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| inset | boolean |  | Indents the label to line up with inset entries. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuLoading

| Prop | Type | Default |
|---|---|---|


Also accepts React.HTMLAttributes attributes.

### DropdownMenuPortal

| Prop | Type | Default | Description |
|---|---|---|---|
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| container | HTMLElement \| ShadowRoot \| React.RefObject<HTMLElement \| ShadowRoot \| null> \| null |  | A parent element to render the portal element into. |
| keepMounted | boolean | false | Whether to keep the portal mounted in the DOM while the popup is hidden. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuRadioGroup

| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode |  | The content of the component. |
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| defaultValue | any |  | The uncontrolled value of the radio item that should be initially selected. To render a controlled radio group, use the `value` prop instead. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| onValueChange | ((value: any, eventDetails: MenuRadioGroup.ChangeEventDetails) => void) |  | Function called when the selected value changes. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |
| value | any |  | The controlled value of the radio item that should be currently selected. To render an uncontrolled radio group, use the `defaultValue` prop instead. |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuRadioItem

| Prop | Type | Default | Description |
|---|---|---|---|
| value* | any |  | Value of the radio item. This is the value that will be set in the MenuRadioGroup when the item is selected. |
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| closeOnClick | boolean | false | Whether to close the menu when the item is clicked. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| id | string |  |  |
| inset | boolean |  | Indents the entry to line up with entries that have an icon. |
| label | string |  | Overrides the text label to use when the item is matched during keyboard text navigation. |
| nativeButton | boolean | false | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button. |
| onClick | BaseUIComponentProps<'div', MenuRadioItemState>['onClick'] |  | The click handler for the menu item. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuSeparator

| Prop | Type | Default | Description |
|---|---|---|---|
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| orientation | "horizontal" \| "vertical" | 'horizontal' | The orientation of the separator. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuShortcut

| Prop | Type | Default |
|---|---|---|


Also accepts React.HTMLAttributes attributes.

### DropdownMenuSub

| Prop | Type | Default | Description |
|---|---|---|---|
| actionsRef | React.RefObject<MenuRoot.Actions \| null> |  | A ref to imperative actions. - `unmount`: Manually unmounts the menu. Call this after any externally controlled closing animation finishes. - `close`: When specified, the menu can be closed imperatively. |
| children | React.ReactNode |  | The content of the submenu. |
| closeParentOnEsc | boolean | false | When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu. |
| defaultOpen | boolean | false | Whether the menu is initially open. To render a controlled menu, use the `open` prop instead. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| highlightItemOnHover | boolean | true | Whether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state. |
| loopFocus | boolean | true | Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys. |
| onOpenChange | ((open: boolean, eventDetails: MenuSubmenuRoot.ChangeEventDetails) => void) |  | Event handler called when the menu is opened or closed. |
| onOpenChangeComplete | ((open: boolean) => void) |  | Event handler called after any animations complete when the menu is opened or closed. |
| open | boolean |  | Whether the menu is currently open. |
| orientation | "horizontal" \| "vertical" | 'vertical' | The visual orientation of the menu. Controls whether roving focus uses up/down or left/right arrow keys. |

### DropdownMenuSubContent

| Prop | Type | Default | Description |
|---|---|---|---|
| align | UseAnchorPositioningSharedParameters['align'] | "start" | How to align the popup relative to the specified side. Submenus and menubars default to `'start'`. |
| alignOffset | number \| OffsetFunction | -5 | Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object param… |
| children | React.ReactNode |  |  |
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| finalFocus | boolean \| React.RefObject<HTMLElement \| null> \| ((closeType: InteractionType) => boolean \| HTMLElement \| null \| void) |  | Determines the element to focus when the menu is closed. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (trigger or previously focused element). - `RefObject`: Move focus to the ref element. - `function`:… |
| id | string |  |  |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| side | UseAnchorPositioningSharedParameters['side'] | "inline-end" | Which side of the anchor element to align the popup against. May automatically change to avoid collisions. Submenus and vertical menubars default to `'inline-end'`. |
| sideOffset | number \| OffsetFunction | 0 | Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a `data` object para… |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |
| submenu | boolean |  | Submenus are smaller, so they open a step faster (duration-fast). |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuSubTrigger

| Prop | Type | Default | Description |
|---|---|---|---|
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| closeDelay | number | 0 | How long to wait before closing the menu that was opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
| delay | number | 100 | How long to wait before the menu may be opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| id | string |  |  |
| inset | boolean |  | Indents the entry to line up with entries that have an icon. |
| label | string |  | Overrides the text label to use when the item is matched during keyboard text navigation. |
| nativeButton | boolean | false | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button. |
| onClick | BaseUIComponentProps<'div', MenuSubmenuTriggerState>['onClick'] |  |  |
| openOnHover | boolean | true | Whether the menu should also open when the trigger is hovered. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |

Also accepts React.HTMLAttributes attributes.

### DropdownMenuTrigger

| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode |  |  |
| className | string \| ((state: State) => string \| undefined) |  | CSS class applied to the element, or a function that returns a class based on the component's state. |
| closeDelay | number | 0 | How long to wait before closing the menu that was opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
| delay | number | 100 | How long to wait before the menu may be opened on hover. Specified in milliseconds. Requires the `openOnHover` prop. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| handle | MenuHandle<Payload> |  | A handle to associate the trigger with a menu. |
| nativeButton | boolean | true | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`). |
| openOnHover | boolean |  | Whether the menu should also open when the trigger is hovered. |
| payload | Payload |  | A payload to pass to the menu when it is opened. |
| render | React.ReactElement \| ComponentRenderFn<RenderFunctionProps, State> |  | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
| style | React.CSSProperties \| ((state: State) => React.CSSProperties \| undefined) |  | Style applied to the element, or a function that returns a style object based on the component's state. |

Also accepts React.ButtonHTMLAttributes attributes.

## Examples

### Trigger: a button, an icon button or an avatar

```tsx
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Button } from "@/components/ui/button"
import { ChevronDown, Copy, Pencil, Share2 } from "lucide-react"

export function Example() {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger render={<Button variant="plain" />}>
        Options
        <ChevronDown data-icon="inline-end" />
      </DropdownMenuTrigger>
      <DropdownMenuContent className="w-48">
        <DropdownMenuItem icon={<Pencil />}>Edit</DropdownMenuItem>
        <DropdownMenuItem icon={<Copy />}>Duplicate</DropdownMenuItem>
        <DropdownMenuItem icon={<Share2 />}>Share</DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}
```

### Items: plain, with an icon, a shortcut, a second line or an avatar

```tsx
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Button } from "@/components/ui/button"
import { ChevronDown, Copy, Pencil, Share2 } from "lucide-react"

export function Example() {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger render={<Button variant="plain" />}>
        Options
        <ChevronDown data-icon="inline-end" />
      </DropdownMenuTrigger>
      <DropdownMenuContent className="w-48">
        <DropdownMenuItem icon={<Pencil />}>Edit</DropdownMenuItem>
        <DropdownMenuItem icon={<Copy />}>Duplicate</DropdownMenuItem>
        <DropdownMenuItem icon={<Share2 />}>Share</DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}
```

### Structure: separators, labelled groups and a submenu

```tsx
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Button } from "@/components/ui/button"
import { ChevronDown, Copy, Pencil, Trash2 } from "lucide-react"

export function Example() {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger render={<Button variant="plain" />}>
        Project
        <ChevronDown data-icon="inline-end" />
      </DropdownMenuTrigger>
      <DropdownMenuContent className="w-48">
        <DropdownMenuItem icon={<Pencil />}>Rename</DropdownMenuItem>
        <DropdownMenuItem icon={<Copy />}>Duplicate</DropdownMenuItem>
        <DropdownMenuSeparator />
        <DropdownMenuItem icon={<Trash2 />} variant="destructive">
          Delete project
        </DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}
```

### Selection: checkbox, select all and radio entries

```tsx
import { useState } from "react"
import {
  DropdownMenu,
  DropdownMenuCheckboxItem,
  DropdownMenuContent,
  DropdownMenuGroup,
  DropdownMenuLabel,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Button } from "@/components/ui/button"
import { ChevronDown } from "lucide-react"

export function Example() {
  const [view, setView] = useState({ toolbar: true, sidebar: true, status: false })

  return (
    <DropdownMenu>
      <DropdownMenuTrigger render={<Button variant="plain" />}>
        View
        <ChevronDown data-icon="inline-end" />
      </DropdownMenuTrigger>
      <DropdownMenuContent className="w-48">
        <DropdownMenuGroup>
          <DropdownMenuLabel>Show</DropdownMenuLabel>
          <DropdownMenuCheckboxItem checked={view.toolbar} onCheckedChange={(checked) => setView({ ...view, toolbar: checked })} closeOnClick={false}>
            Toolbar
          </DropdownMenuCheckboxItem>
          <DropdownMenuCheckboxItem checked={view.sidebar} onCheckedChange={(checked) => setView({ ...view, sidebar: checked })} closeOnClick={false}>
            Sidebar
          </DropdownMenuCheckboxItem>
          <DropdownMenuCheckboxItem checked={view.status} onCheckedChange={(checked) => setView({ ...view, status: checked })} closeOnClick={false}>
            Status bar
          </DropdownMenuCheckboxItem>
        </DropdownMenuGroup>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}
```

### States: destructive, disabled, loading and empty

```tsx
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Button } from "@/components/ui/button"
import { ChevronDown, Mail, User, UserMinus } from "lucide-react"

export function Example() {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger render={<Button variant="plain" />}>
        Member
        <ChevronDown data-icon="inline-end" />
      </DropdownMenuTrigger>
      <DropdownMenuContent className="w-56">
        <DropdownMenuItem icon={<User />}>View profile</DropdownMenuItem>
        <DropdownMenuItem icon={<Mail />}>Send message</DropdownMenuItem>
        <DropdownMenuSeparator />
        <DropdownMenuItem icon={<UserMinus />} variant="destructive">
          Remove from workspace
        </DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}
```

## In context

### Row actions in a table

An icon button at the end of each row opens that row's actions. Delete is last, after a separator, and names the project.

```tsx
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { IconButton } from "@/components/ui/icon-button"
import { Copy, Link2, MoreHorizontal, Pencil, Trash2 } from "lucide-react"

export function RowActions() {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger render={<IconButton variant="plain" aria-label="Actions for Q4 roadmap" />}>
        <MoreHorizontal />
      </DropdownMenuTrigger>
      <DropdownMenuContent align="end" className="w-48">
        <DropdownMenuItem icon={<Pencil />}>Rename</DropdownMenuItem>
        <DropdownMenuItem icon={<Link2 />}>Copy link</DropdownMenuItem>
        <DropdownMenuItem icon={<Copy />}>Duplicate</DropdownMenuItem>
        <DropdownMenuSeparator />
        <DropdownMenuItem icon={<Trash2 />} variant="destructive">
          Delete project
        </DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}
```

### Account menu in the app bar

An avatar opens the account menu: who is signed in, the places to go and Log out. The menu is right-aligned to the edge of the bar.

```tsx
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuGroup,
  DropdownMenuItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuShortcut,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { IconButton } from "@/components/ui/icon-button"
import { Keyboard, LogOut, Settings, User } from "lucide-react"

export function AccountMenu() {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger render={<IconButton variant="plain" aria-label="Account" />}>
        <Avatar size="sm">
          <AvatarFallback>NL</AvatarFallback>
        </Avatar>
      </DropdownMenuTrigger>
      <DropdownMenuContent align="end" className="w-64">
        <DropdownMenuGroup>
          <DropdownMenuLabel className="flex items-center gap-2 py-2">
            <Avatar size="sm">
              <AvatarFallback>NL</AvatarFallback>
            </Avatar>
            <span className="flex flex-col">
              <span className="text-label-sm text-foreground">Nora Lindgren</span>
              <span className="font-normal">info@wunderui.com</span>
            </span>
          </DropdownMenuLabel>
        </DropdownMenuGroup>
        <DropdownMenuSeparator />
        <DropdownMenuItem icon={<User />}>Profile</DropdownMenuItem>
        <DropdownMenuItem icon={<Settings />}>Settings</DropdownMenuItem>
        <DropdownMenuItem icon={<Keyboard />} aria-keyshortcuts="Meta+/">
          Keyboard shortcuts
          <DropdownMenuShortcut>⌘/</DropdownMenuShortcut>
        </DropdownMenuItem>
        <DropdownMenuSeparator />
        <DropdownMenuItem icon={<LogOut />}>Log out</DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}
```

### Sort and show archived

A radio group picks the order and a checkbox switches archived projects on. The menu stays open while you choose and the list behind it updates at once.

```tsx
import { useState } from "react"
import {
  DropdownMenu,
  DropdownMenuCheckboxItem,
  DropdownMenuContent,
  DropdownMenuLabel,
  DropdownMenuRadioGroup,
  DropdownMenuRadioItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Button } from "@/components/ui/button"
import { ChevronDown } from "lucide-react"

export function SortProjects() {
  const [sort, setSort] = useState("newest")
  const [archived, setArchived] = useState(false)

  return (
    <DropdownMenu>
      <DropdownMenuTrigger render={<Button variant="plain" />}>
        Sort
        <ChevronDown data-icon="inline-end" />
      </DropdownMenuTrigger>
      <DropdownMenuContent align="end" className="w-56">
        <DropdownMenuRadioGroup value={sort} onValueChange={setSort}>
          <DropdownMenuLabel>Sort by</DropdownMenuLabel>
          <DropdownMenuRadioItem value="newest" closeOnClick={false}>
            Newest first
          </DropdownMenuRadioItem>
          <DropdownMenuRadioItem value="oldest" closeOnClick={false}>
            Oldest first
          </DropdownMenuRadioItem>
          <DropdownMenuRadioItem value="name" closeOnClick={false}>
            Name A to Z
          </DropdownMenuRadioItem>
        </DropdownMenuRadioGroup>
        <DropdownMenuSeparator />
        <DropdownMenuCheckboxItem checked={archived} onCheckedChange={setArchived} closeOnClick={false}>
          Show archived
        </DropdownMenuCheckboxItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}
```

### Sort menu

Pick one order for a list with radio rows in a menu.

```tsx
<DropdownMenuRadioGroup value={sort} onValueChange={setSort}>
  <DropdownMenuRadioItem value="name">Name</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
```

### File menu

Rows that open a nested menu for recent files and export formats.

```tsx
<DropdownMenuSub>
  <DropdownMenuSubTrigger>Open recent</DropdownMenuSubTrigger>
  <DropdownMenuSubContent>
    <DropdownMenuItem>Q4 roadmap.fig</DropdownMenuItem>
  </DropdownMenuSubContent>
</DropdownMenuSub>
```

## For AI agents

`get_component("dropdown-menu")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
