Dropdown Menu

A list of actions in a dropdown, enhanced with keyboard navigation.

Installation

pnpm dlx shadcn@latest add @lumi-ui/dropdown-menu

Anatomy

<Dropdown>
  <DropdownMenuTrigger />
  <DropdownMenuContent>
     <DropdownMenuItem />
     <DropdownMenuLinkItem />
     <DropdownMenuItem>
       <DropdownMenuShortcut />
     </DropdownMenuItem>
     <DropdownMenuSeparator />
     <DropdownMenuGroup>
       <DropdownMenuGroupLabel />
     </DropdownMenuGroup>
     <DropdownMenuRadioGroup>
       <DropdownMenuRadioItemContent />
     </DropdownMenuRadioGroup>
     <DropdownMenuCheckboxItemContent />
     <DropdownMenuSubMenu>
       <DropdownMenuSubMenuTriggerGroup />
       <DropdownMenuSubMenuContent>
         {/* Submenu items  */}
       </DropdownMenuSubMenuContent>
     </DropdownMenuSubMenu>
  </DropdownMenuContent>
</Dropdown>

Basic Usage

Features

Matching the Trigger Width

With Arrow

Group labels

Nested menu

Checkbox items

Radio items

Cookbook

Style Trigger when open

Open on hover

Close on click

DropdownMenuLinkItem renders a by default. Use render prop to render link based on your framework.

Open a dialog

Control the dialog state and open it imperatively using the onClick handler on the menu item.

Detached triggers

Multiple triggers

API Reference

A high-level container component that combines the DropdownMenuPortal, DropdownMenuPositioner, and DropdownMenuPopup into a single styled element for the dropdown content.

PropTypeDescription
side"top" | "right" | "bottom" | "left"The preferred side of the anchor to render against when open.
sideOffsetnumberThe distance in pixels from the anchor.
align"start" | "center" | "end"The preferred alignment against the anchor.
alignOffsetnumberAn offset in pixels from the "start" or "end" alignment options.
showArrowbooleanWhether to render the arrow element.
matchAnchorWidthbooleanWhether the popup width should match the anchor width.
classNamestringAdditional CSS classes.
...propsBaseMenu.Popup.PropsPasses all other props to the underlying BaseMenu.Popup component.

A high-level checkbox item component that combines the CheckboxItem and CheckboxItemIndicator into a single styled element with configurable icon positioning.

PropTypeDescription
indicatorPlacement"start" | "end"The position of the indicator icon relative to the content.
indicatorIconReact.ReactNodeThe icon to render as the item indicator.
classNamestringAdditional CSS classes.
...propsDropdownMenuCheckboxItem.PropsPasses all other props to the underlying DropdownMenuCheckboxItem component.

A high-level radio item component that combines the RadioItem and RadioItemIndicator into a single styled element with configurable icon positioning.

PropTypeDescription
indicatorPlacement"start" | "end"The position of the indicator icon relative to the content.
indicatorIconReact.ReactNodeThe icon to render as the item indicator.
classNamestringAdditional CSS classes.
...propsDropdownMenuRadioItem.PropsPasses all other props to the underlying DropdownMenuRadioItem component.

A composite trigger component that renders the trigger content and a chevron icon.

PropTypeDescription
classNamestringAdditional CSS classes.
childrenReact.ReactNodeThe content of the trigger.
...propsBaseMenu.SubmenuTrigger.PropsPasses all other props to the underlying BaseMenu.SubmenuTrigger component.

A composite content component for submenus.

PropTypeDescription
side"top" | "right" | "bottom" | "left"The preferred side of the anchor to render against when open.
sideOffsetnumberThe distance in pixels from the anchor.
align"start" | "center" | "end"The preferred alignment against the anchor.
alignOffsetnumberAn offset in pixels from the "start" or "end" alignment options.
classNamestringAdditional CSS classes.
...propsDropdownMenuContentPropsPasses all other props to the underlying DropdownMenuContent component.