Dropdown Menu
NavigationContext menu with items, separators, and keyboard navigation.
Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.
"use client";
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuItem,
DropdownMenuCheckboxItem,
DropdownMenuShortcut,
} from "@dashboardpack/core/components/ui/dropdown-menu";
import { Button } from "@dashboardpack/core/components/ui/button";
import { useState } from "react";
export default function DropdownMenuExample() {
const [notifications, setNotifications] = useState(true);
const [message, setMessage] = useState("No action selected");
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline">Workspace actions</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuLabel>My workspace</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={() => setMessage("New project selected")}>
New project<DropdownMenuShortcut>⌘N</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuCheckboxItem
checked={notifications}
onCheckedChange={setNotifications}
>
Notifications
</DropdownMenuCheckboxItem>
<DropdownMenuItem disabled>Transfer ownership</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
onSelect={() => setMessage("Archive selected — preview only")}
>
Archive workspace
</DropdownMenuItem>
<DropdownMenuLabel className="font-normal text-muted-foreground">
{message}
</DropdownMenuLabel>
</DropdownMenuContent>
</DropdownMenu>
);
}Usage
Use menus for actions, checkable settings, and grouped commands. Handle onSelect on menu items. Displayed shortcuts are visual hints; register keyboard shortcuts separately if needed.
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuItem,
DropdownMenuCheckboxItem,
DropdownMenuShortcut,
} from "@dashboardpack/core/components/ui/dropdown-menu";Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.
API reference
Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.
| Prop | Type / Default | Description |
|---|---|---|
| onSelect (DropdownMenuItem) | (event: Event) => voidDefault: — | Respond to an action selection. |
| checked / onCheckedChange (CheckboxItem) | boolean | "indeterminate" / callbackDefault: — | Control a checkable menu item. |
| disabled (DropdownMenuItem) | booleanDefault: false | Prevent selection. |
| align (DropdownMenuContent) | start | center | endDefault: center | Popup alignment. |