Installation
$ pnpm dlx shadcn@latest add @synccn/dropdown-menuFirst time in this project? Connect synccn with one command.
Usage
import { DropdownMenu } from "@/components/ui/dropdown-menu";<DropdownMenu trigger={<Button>Menu</Button>} items={items} />API reference
Generated from the component's TypeScript types, so it always matches the code.
DropdownMenu
items: [ { label, icon?, shortcut?, onSelect?, destructive?, disabled? } | { type: "separator" } | { type: "label", label } | { type: "checkbox", label, checked, onCheckedChange } ]
PropTypeDescription
- triggerrequired
React.ReactNodeElement that opens the menu.
- itemsrequired
DropdownMenuItem[]Menu entries.
- align
"start" | "end"Default
"start"Which edge of the trigger the menu lines up with.
- contentClassName
stringExtra classes for the menu panel.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for Check, ChevronRight
Keyboard
- ↓or↑Move between items
- HomeorEndJump to the first or last item
- EnterorSpaceRun the item, or toggle a checkbox item
- EscClose the menu
- TabClose the menu and move focus on
Accessibility
- Uses the menu role; checkbox items expose aria-checked.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: it, menu, separator
- ARIA attributes: aria-checked, aria-disabled
- Keys handled: ArrowUp, ArrowDown, Home, End, Enter, Tab, Space
- Closes with Escape
- Closes when you click or tap outside
- Flips to whichever side has room, so it stays on screen
More overlays
DialogModal with focus trap, scroll lock and Escape to close.SheetPanel that slides in from the left, right or bottom.Context MenuRight-click menu that also opens on long-press.PopoverFloating panel anchored to a trigger.TooltipLabel on hover and focus, on any side.CommandSearchable, grouped command list — the engine behind ⌘K.