Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Dropdown Menu

A menu of actions or options that a button opens.

Built on the headless Menu.See its API in Docs

Rendered by React 19.3.1

dropdown-menu.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/dropdown-menu.json

It also adds utils. The app needs its setup first: Installation.

Usage

DropdownMenu holds DropdownMenuTrigger and DropdownMenuContent; inside, DropdownMenuItems grouped with DropdownMenuGroup and DropdownMenuLabel, split by DropdownMenuSeparator, with DropdownMenuShortcut for a key hint. DropdownMenuCheckboxItem toggles, DropdownMenuRadioGroup with DropdownMenuRadioItems picks one, and DropdownMenuSub with DropdownMenuSubTrigger and DropdownMenuSubContent nests a menu. An item takes inset to line up with the checked ones and variant="destructive". The content takes side, align and their offsets. In Angular the template writes uiDropdownMenuPortal around each content. Keyboard, typeahead and focus come from the headless Menu.

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

Examples

Default

An account menu with labels, shortcuts and a submenu.

Its preview and code are at the top of the page.

Checkboxes

Three checkbox items, one ticked and one disabled.

Rendered by React 19.3.1

dropdown-menu-checkboxes.tsx

Radio Group

Three radio items for the panel's position.

Rendered by React 19.3.1

dropdown-menu-radio-group.tsx

API reference

The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Menu's API reference.