A menu of actions for rows, the user menu and bulk actions, with full keyboard support.
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuLabel, DropdownMenuSeparator } from "kivu-ui"On this page
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuLabel, DropdownMenuSeparator } from "kivu-ui";last action: nothing yet
import { useState } from "react";
import {
DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel,
DropdownMenuSeparator, DropdownMenuTrigger, IconButton,
} from "kivu-ui";
const Dots = (
<svg viewBox="0 0 16 16" fill="currentColor"><circle cx="3.5" cy="8" r="1.25" /><circle cx="8" cy="8" r="1.25" /><circle cx="12.5" cy="8" r="1.25" /></svg>
);
export default function Demo() {
const [pinned, setPinned] = useState(true);
const [last, setLast] = useState("nothing yet");
return (
<div className="flex flex-col items-center gap-3">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<IconButton aria-label="Row actions" variant="ghost" shape="square">{Dots}</IconButton>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>Invoice #1042</DropdownMenuLabel>
<DropdownMenuItem shortcut="⌘E" onSelect={() => setLast("Edit")}>Edit</DropdownMenuItem>
<DropdownMenuItem shortcut="⌘D" onSelect={() => setLast("Duplicate")}>Duplicate</DropdownMenuItem>
<DropdownMenuCheckboxItem checked={pinned} onCheckedChange={setPinned}>Pinned</DropdownMenuCheckboxItem>
<DropdownMenuSeparator />
<DropdownMenuItem tone="danger" onSelect={() => setLast("Delete")}>Delete</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<p className="font-mono text-xs text-fg-muted">last action: {last}</p>
</div>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | - | Open state (controlled). |
defaultOpen | boolean | false | Initial open state (uncontrolled). |
onOpenChange | (open: boolean) => void | - | Called when it opens or closes. |
Extends <div> attributes.
| Prop | Type | Default | Description |
|---|---|---|---|
side | "top" | "bottom" | "left" | "right" | "bottom" | Preferred side; flips when there isn't room. |
align | "start" | "center" | "end" | "start" | Alignment along the trigger. |
offset | number | 6 | Gap from the trigger, in px. |
| Prop | Type | Default | Description |
|---|---|---|---|
onSelect | (event: Event) => void | - | Called when chosen. Call event.preventDefault() to keep the menu open. |
icon | ReactNode | - | Icon on the left. |
shortcut | ReactNode | - | Shortcut hint on the right, e.g. ⌘D. |
tone | "default" | "danger" | "default" | Danger for destructive actions. |
disabled | boolean | false | Skip this item. |
asChild | boolean | false | Render the single child (e.g. a router Link) with this item's styles and behaviour. |
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | - | Required. Whether it's ticked. |
onCheckedChange | (checked: boolean) => void | - | Called when toggled. The menu stays open. |
Every component also accepts className and forwards its ref. Root CSS class: .kivu-menu