Dropdown Menu

Toggleable menu for displaying lists of links or actions

Primitive

A menu of actions or links that opens from a trigger button. Use it for row actions, a "more options" overflow button, account menus, or any compact list of commands. For a horizontal bar of menus (File, Edit, View), use Menubar instead.

Preview

Installation

Usage

Composition

DropdownMenuContent composes the portal, positioner, and popup internally, so you place items directly inside it.

To control positioning or the popup yourself, compose the parts: DropdownMenuPortal › DropdownMenuPositioner › DropdownMenuPopup. DropdownMenuContent also wraps its items in a DropdownMenuViewport, which crossfades content when detached triggers swap the menu. Leave the viewport out of menus that never swap content: without it Base UI positions the menu with transform, which keeps movement on the compositor.

Examples

With Icons and Shortcuts

Place an icon beside the label and a DropdownMenuShortcut at the end of an item.

With Checkboxes

Use DropdownMenuCheckboxItem for toggleable options. The checkmark sits in a reserved column on the right, so labels stay put as items toggle.

With Switch

Set indicator="switch" on DropdownMenuCheckboxItem to swap the checkmark for a switch. Visual only: the item keeps its menuitemcheckbox role, the row stays the click target, and the menu stays open on toggle.

With Radio Group

Use DropdownMenuRadioGroup with DropdownMenuRadioItem for mutually exclusive options. Radio items use the same right-aligned checkmark as checkbox items.

Aligning Items With and Without Icons

Menu items lay their icon out inline, so an item with no icon starts its label further left than its neighbours. Add inset to the icon-less items to give them the same left padding an icon would have occupied, and every label lines up on one edge.

inset is available on DropdownMenuItem, DropdownMenuLinkItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuGroupLabel, and DropdownMenuSubTrigger. Only reach for it in menus that actually mix the two kinds of item.

With Sub Menu

Nest a DropdownMenuSub to open a submenu on hover.

With Filter

Wrap DropdownMenu in DropdownMenuFilter, then put a DropdownMenuInput above a DropdownMenuList to filter items as you type. Wrap a DropdownMenuSub in its own DropdownMenuFilter to make the submenu searchable too. Pass viewportClassName="p-0" to the content; the field and list bring their own spacing, so the list scrolls to the menu's edges.

Set a width on DropdownMenuContent so the menu doesn't narrow as long items filter out. Items match on their text, ignoring case, accents, and punctuation. Give an item a label when its text isn't what people would type, or pass a filter function (such as startsWith from useDropdownMenuFilter()) to change how items match. Filtering is a preview API in Base UI and may change in a minor release.

Animated (Detached Triggers)

Multiple triggers share one menu that moves between them and slides content in or out based on activation direction.

API Reference

The DropdownMenu component is built on top of Base UI's Menu. All Base UI props are supported. The documentation below only covers custom props and modified defaults specific to our implementation.

For the complete Base UI API, see the Base UI Menu documentation.

One exception: DropdownMenuSub renders Menu.SubmenuRoot, which does not accept modal, openOnHover, handle, triggerId or defaultTriggerId. Those belong on the root DropdownMenu.

Props

Dropdown container with positioning and animations. Composes DropdownMenuPortal, DropdownMenuPositioner, DropdownMenuPopup, and DropdownMenuViewport. Props are forwarded to DropdownMenuPopup.

Positions the menu when you compose the parts yourself. Wraps Base UI's Menu.Positioner with a data-slot and no styles, so give it a z-index (z-50).

Styled menu surface with its entrance and exit. Accepts level and shadowLevel like DropdownMenuContent; other props go to Menu.Popup.

Crossfades content when detached triggers swap what the menu shows, with p-1 around the items. Wraps Base UI's Menu.Viewport.

Individual menu item. Wraps Base UI's Menu.Item.

Menu item that renders as an anchor (<a>) for navigation links. Wraps Base UI's Menu.LinkItem.

Toggleable menu item. Wraps Base UI's Menu.CheckboxItem. The indicator sits in a reserved column on the right, matching Select.

Mutually exclusive menu item. Wraps Base UI's Menu.RadioItem. Uses the same right-aligned checkmark as DropdownMenuCheckboxItem.

Non-interactive label for grouping items.

Label for a menu group. Wraps Base UI's Menu.GroupLabel.

Item that opens a submenu on hover. Wraps Base UI's Menu.SubmenuTrigger.

Submenu container with positioning. Composes Menu.Portal, Menu.Positioner, and Menu.Popup. Props are forwarded to Menu.Popup.

Enables filtering for the DropdownMenu or DropdownMenuSub it wraps. Wraps Base UI's Menu.FilterProvider and renders no element.

Search field drawn like the menu's rows: an icon, Base UI's Menu.Input, and a clear button. It sits above DropdownMenuList, which scrolls on its own with the same edge fade as Combobox's list. Props are forwarded to Menu.Input.

Scrolling list of items below the search field, with an edge fade. Wraps Base UI's Menu.List in a ScrollArea, capped at 20rem and shrinking to fit a short screen. className goes to the scroll area, e.g. max-h-96 to change the cap; other props go to Menu.List.

Shows in place of the items when nothing matches, lined up with their labels. Wraps Base UI's Menu.Empty.

Small icon button that empties the query. Wraps Base UI's Menu.Clear. DropdownMenuInput renders it, so use it directly only with showClear={false}. Its aria-label defaults to "Clear search".