Component guideEditable source

Dropdown Menu

A button-triggered menu of actions and selectable settings.

Original component docs
On this page7 sectionsBack to top

Use Dropdown Menu for commands associated with a button. Use Select for a form value. A menu item runs an application action; opening the menu does not fetch or save data.

Live preview
Loading preview...

#Installation

Complete the base setup. The CLI resolves dependencies. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/dropdown-menu.json

The trigger example also uses Button.

#Usage

"use client";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import {
  DropdownMenu,
  DropdownMenuTrigger,
  DropdownMenuContent,
  DropdownMenuItem,
} from "@/components/ui/dropdown-menu";

export default function ProjectActions() {
  const [message, setMessage] = useState("No action selected.");
  return (
    <div className="grid gap-3">
      <DropdownMenu>
        <DropdownMenuTrigger render={<Button variant="outline" />}>
          Project actions
        </DropdownMenuTrigger>
        <DropdownMenuContent>
          <DropdownMenuItem onClick={() => setMessage("Rename selected in this preview.")}>
            Rename
          </DropdownMenuItem>
          <DropdownMenuItem disabled>Export</DropdownMenuItem>
        </DropdownMenuContent>
      </DropdownMenu>
      <p role="status">{message}</p>
    </div>
  );
}

#API reference

Prop / partPurposeDefault
DropdownMenu.open / onOpenChangeControlled visibilityUncontrolled
DropdownMenuTrigger.renderCompose the trigger buttonPrimitive button
DropdownMenuContent.side / alignPopup positionbottom / center
DropdownMenuItem.onClick / disabledAction and availability— / false
DropdownMenuCheckboxItem.checked / onCheckedChangeIndependent checked stateUncontrolled
DropdownMenuRadioGroup.value / onValueChangeMutually exclusive choiceUncontrolled
DropdownMenuSubNested menu—
DropdownMenuContent.alignOffset / arrowPadding / collisionPaddingAlignment, arrow, and collision-boundary spacing, in pixels0
DropdownMenuContent.sideOffsetTrigger-to-popup gap, in pixels4
DropdownMenuSubContent.side / alignPreferred submenu placement and alignmentright / start
DropdownMenuSubContent.alignOffset / sideOffsetSubmenu alignment adjustment and gap, in pixels-3 / 0
DropdownMenuItem.variantItem appearance: default or destructivedefault
DropdownMenuCheckboxItem.closeOnClick / DropdownMenuRadioItem.closeOnClickClose after selecting a stateful itemtrue

#Accessibility

Use an explicit trigger name and clear action labels. Arrow keys navigate items, Enter selects, and Escape dismisses. Displayed shortcut text does not implement a shortcut. For destructive actions, describe the consequence and use confirmation when warranted. Do not turn a menu into a complex form with unrelated focusable controls.

Menu content is bounded by Base UI's available height. Long menus scroll so pointer users and keyboard users can reach every item.

#Examples

#Checkboxes

Loading preview...

#Radio options

Loading preview...