Dropdown Menu
A zero-dependency portaled dropdown menu with a spring-gliding item highlight, stroke-draw checkbox items, automatic flip positioning, and keyboard typeahead.
Customize
Installation
npx shadcn@latest add @kinetic/dropdown-menuUsage
Compose DropdownMenu, DropdownMenuTrigger and DropdownMenuContent with items.
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuTrigger,
} from "@/components/kinetic/ui/dropdown-menu";
export function AccountMenu() {
return (
<DropdownMenu>
<DropdownMenuTrigger>Account</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuLabel>My account</DropdownMenuLabel>
<DropdownMenuItem>
Profile <DropdownMenuShortcut>Ctrl+P</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem variant="destructive">Sign out</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
}DropdownMenuTrigger accepts asChild to render your own element.
Placement
Set side (top or bottom), align (start, center, end), sideOffset, alignOffset and collisionPadding on DropdownMenuContent. The menu flips automatically when there is not enough room.
<DropdownMenuContent side="top" align="end" sideOffset={8}>
...
</DropdownMenuContent>Portal
DropdownMenuContent mounts into document.body automatically. Wrap it in DropdownMenuPortal and pass container to portal into a custom DOM node cleanly without double-portaling.
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuPortal,
DropdownMenuTrigger,
} from "@/components/kinetic/ui/dropdown-menu";
<DropdownMenu>
<DropdownMenuTrigger>Actions</DropdownMenuTrigger>
<DropdownMenuPortal container={portalContainer}>
<DropdownMenuContent>
<DropdownMenuItem>Duplicate</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenuPortal>
</DropdownMenu>Items
DropdownMenuItem supports variant (default or destructive), inset, disabled, closeOnSelect and onSelect. Use DropdownMenuGroup to group related items.
<DropdownMenuItem inset closeOnSelect={false} onSelect={() => refresh()}>
Refresh
</DropdownMenuItem>Checkbox items
DropdownMenuCheckboxItem draws its check mark with an SVG stroke. Use checked with onCheckedChange, or defaultChecked.
<DropdownMenuCheckboxItem checked={showGrid} onCheckedChange={setShowGrid}>
Show grid
</DropdownMenuCheckboxItem>Radio items
Wrap DropdownMenuRadioItem elements, each with a value, in a DropdownMenuRadioGroup.
<DropdownMenuRadioGroup value={density} onValueChange={setDensity}>
<DropdownMenuRadioItem value="compact">Compact</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="comfortable">Comfortable</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>Submenus
Nest DropdownMenuSub, DropdownMenuSubTrigger and DropdownMenuSubContent inside the content. DropdownMenuSub accepts openDelay and closeDelay.
<DropdownMenuSub>
<DropdownMenuSubTrigger>Share</DropdownMenuSubTrigger>
<DropdownMenuSubContent>
<DropdownMenuItem>Copy link</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuSub>Keyboard
Arrow keys move the highlight, Home and End jump to the first and last item, typing characters jumps to a matching item, and Escape closes the menu and returns focus to the trigger.
Motion preferences
The item highlight glides on a spring. Tune it with speed, stiffness, damping and blurPx on DropdownMenu. Timing follows the current Kinetic tempo, and motion is simplified when reduced motion is enabled.
API Reference
DropdownMenu
Zero-dependency dropdown menu root managing open state, spring highlight physics, and timing.
| Prop | Type | Default | Description |
|---|---|---|---|
open / defaultOpen / onOpenChange | boolean / (open: boolean) => void | - | Controlled or uncontrolled menu visibility. |
speed | number | 1 | Playback speed multiplier for menu reveal and highlight spring. |
stiffness / damping | number | 420 / 32 | Spring parameters for the gliding row highlight. |
DropdownMenuContent
Portaled menu panel with auto top/bottom flip, origin scale reveal, and keyboard typeahead.
| Prop | Type | Default | Description |
|---|---|---|---|
side | "top" | "bottom" | "bottom" | Preferred vertical side relative to trigger. |
align | "start" | "center" | "end" | "start" | Horizontal alignment relative to trigger. |
sideOffset | number | 6 | Pixel gap between trigger and menu content. |
DropdownMenuPortal / DropdownMenuTrigger
Optional explicit portal wrapper with custom container target and asChild trigger button.
| Prop | Type | Default | Description |
|---|---|---|---|
container (DropdownMenuPortal) | Element | null | document.body | DOM element where DropdownMenuContent is mounted when wrapped in DropdownMenuPortal. |
asChild (DropdownMenuTrigger) | boolean | false | Merges menu trigger attributes and click/keyboard handlers onto a child element. |
DropdownMenuItem / DropdownMenuCheckboxItem
Action and checkable rows with spring highlight tracking and SVG stroke-draw checkmarks.
| Prop | Type | Default | Description |
|---|---|---|---|
variant (DropdownMenuItem) | "default" | "destructive" | "default" | Switches row and highlight tint for destructive actions. |
checked / onCheckedChange (CheckboxItem) | boolean / (checked: boolean) => void | - | Controlled toggle state for checkable menu items. |