Search

Search documentation

Dropdown Menu

Displays a menu to the user — such as a set of actions or functions — triggered by a button.

Installation

pnpm dlx shadcn@latest add @evolphin/dropdown-menu

Usage

import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
<DropdownMenu>
  <DropdownMenuTrigger>Open</DropdownMenuTrigger>
  <DropdownMenuContent>
    <DropdownMenuLabel>My Account</DropdownMenuLabel>
    <DropdownMenuSeparator />
    <DropdownMenuItem>Profile</DropdownMenuItem>
    <DropdownMenuItem>Billing</DropdownMenuItem>
    <DropdownMenuItem>Team</DropdownMenuItem>
    <DropdownMenuItem>Subscription</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Type Definitions

interface DropdownMenuProps {
  /** The controlled open state of the dropdown menu */
  open?: boolean;
DropdownMenuProps.open?: boolean | undefined

The controlled open state of the dropdown menu

/** The default open state when uncontrolled */ ?: boolean; /** Event handler called when the open state changes */ ?: (: boolean) => void; /** The modality of the dropdown menu */ ?: boolean; }

Examples

Default

Checkboxes

API Reference

PropTypeDefaultDescription
openboolean-The controlled open state of the dropdown menu.
defaultOpenboolean-The default open state when uncontrolled.
onOpenChange(open: boolean) => void-Event handler called when the open state changes.
modalbooleantrueThe modality of the dropdown menu.
PropTypeDefaultDescription
asChildbooleanfalseChange the component to the HTML tag or custom component of the only child.
PropTypeDefaultDescription
side`"top" \"right" \"bottom" \
align`"start" \"center" \"end"`
sideOffsetnumber4The distance in pixels from the trigger.
classNamestring-Additional CSS classes
PropTypeDefaultDescription
disabledbooleanfalseWhether the item is disabled.
onSelect(event: Event) => void-Event handler called when the item is selected.
insetbooleanfalseWhether to indent the item.
PropTypeDefaultDescription
checked`boolean \"indeterminate"`-
onCheckedChange(checked: boolean) => void-Event handler called when the checked state changes.

On this page