Dropdown menu
Dropdown menu
Actions behind a button: the menu rises off the trigger, one highlight glides between rows, and checkbox rows draw their tick in place.
Dependencies
Interaction states
- open — Rises off the trigger (320ms); flips above if needed.
- move — The highlight glides to the row under the pointer or the key.
- pick — Closes (180ms) and focus returns to the trigger; checkbox rows stay open and draw their tick (280ms).
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/dropdown-menuFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Where it’s used
Row actions
Edit, duplicate, delete on a "…" button.
Account menus
Profile, settings, sign out under an avatar.
View options
Checkable columns or display settings.
Create menus
New doc, new folder, upload.
What it handles
- Gliding highlight — One fill moves between rows (220ms) for pointer and keys alike.
- Keyboard — Enter/Space/↓ open on the first row, ↑ on the last; arrows wrap; typing jumps.
- Checkable rows — A drawn tick, aria-checked, menu stays open.
- Plain data — items: rows, labels and separators as objects.
Usage
Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.
import { DropdownMenu } from "@/components/dropdown-menu";
<DropdownMenu
trigger={<button aria-label="More">…</button>}
items={[
{ id: "rename", label: "Rename", shortcut: "F2", onSelect: rename },
{ type: "separator" },
{ id: "delete", label: "Delete", destructive: true, onSelect: remove },
]}
/>Props
| Prop | Type | Description |
|---|---|---|
| trigger | ReactElement | – · The button that opens it. |
| items | MenuEntry[] | – · Rows ({ id, label, icon, shortcut, destructive, disabled, onSelect }), { type: "checkbox", checked, onCheckedChange }, { type: "label" } and { type: "separator" }. |
| side / align | Side / Align | "bottom" / "start" · Where it sits. |
| open / onOpenChange | boolean / (open) => void | – · Control it. |
| minWidth | number | 200 · Never narrower than the trigger. |
| label | string | – · Accessible name of the menu. |
Accessibility & motion
- Placement, presence and dismissal live in floating.ts, shared by tooltip, popover, dropdown and context menus: they all flip, shift, enter and leave the same way. - role="menu" with menuitem and menuitemcheckbox rows. - Reduced motion: the menu fades; the highlight jumps.
pnpm dlx shadcn@4.21.5 add @cavemio/dropdown-menu