Dropdown
A dropdown menu component with trigger, items, labels, separators, and keyboard support.
PREVIEW
Click the buttons below to trigger a dropdown.
INSTALLATION
bash
# Required
npm install @kennbalino/kui
# Optional — only if you want to use CVA, cn(), or lucide icons directly
npm install class-variance-authority clsx tailwind-merge lucide-reactUSAGE
tsx
"use client";
import {
Dropdown,
DropdownTrigger,
DropdownMenu,
DropdownItem,
DropdownSeparator,
DropdownLabel,
} from "@kennbalino/kui";
import { Button } from "@kennbalino/kui";
import { User, Settings, LogOut } from "lucide-react";
export default function MyComponent() {
return (
<Dropdown>
<DropdownTrigger>
<Button variant="ghost">Open Menu ▾</Button>
</DropdownTrigger>
<DropdownMenu>
<DropdownLabel>Account</DropdownLabel>
<DropdownItem icon={<User size={14} />}>Profile</DropdownItem>
<DropdownItem icon={<Settings size={14} />}>Settings</DropdownItem>
<DropdownSeparator />
<DropdownItem icon={<LogOut size={14} />} variant="danger">
Logout
</DropdownItem>
</DropdownMenu>
</Dropdown>
);
}
// Align options
<DropdownMenu align="start">Item 1</DropdownMenu> // default
<DropdownMenu align="center">Item 2</DropdownMenu>
<DropdownMenu align="end">Item 3</DropdownMenu>
// Side options
<DropdownMenu side="bottom">Item 4</DropdownMenu> // default
<DropdownMenu side="top">Item 5</DropdownMenu>
// Item variants
<DropdownItem variant="default">Default</DropdownItem>
<DropdownItem variant="danger">Danger</DropdownItem>
<DropdownItem variant="disabled">Disabled</DropdownItem>PROPS
| Prop | Type | Default | Description |
|---|---|---|---|
| align | start | center | end | start | Controls the horizontal alignment of the dropdown menu. |
| side | top | bottom | bottom | Controls which side the dropdown opens from. |
| variant (item) | default | danger | disabled | default | Controls the visual style of a dropdown item. |
| icon | ReactNode | — | Icon displayed on the left of a dropdown item. |
| onClick | () => void | — | Callback fired when a dropdown item is clicked. |