Ready-made menus on top of Menu: account, row actions and pickers, with avatar, toggle, link and badge rows.
Used for
- Account menu
- Row actions
- Model picker
- Workspace switcher
- Share options
Examples
Installation
npx knowns-ui@latest add dropdownFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Dropdown from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/dropdown
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add dropdown
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/avatar.tsx
- components/ui/knowns/badge.tsx
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
- components/ui/knowns/menu.tsx
- components/ui/knowns/dropdown.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/dropdown, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "dropdown" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- trigger
ReactElement- Usually DropdownButton, DropdownIconButton or DropdownAvatarButton. Any element that takes a ref and onClick works.
- items
DropdownItem[]|DropdownSection[]- Menu rows plus the extra kinds below. Sections get an optional label and a hairline between them.
- onSelect
(item, event) => void- Gets the original row. For links, call event.preventDefault() to stop the navigation.
- header / footer
ReactNode- Fixed content around the rows. DropdownHeader is a ready-made user card.
- align / side / width
"start"|"end" / "top"|"bottom"|"auto" / number|"trigger"- Default
"start" / "auto" / content - Passed straight to Menu.
- open / onOpenChange
boolean / (open) => void- Optional control.
- kind: "link"
{ href, external? }- Navigates in the same tab, or opens a new tab with ↗ when external.
- kind: "toggle"
{ checked }- A switch on the right. The row is a menuitemcheckbox, so the menu stays open.
- avatar
{ label, src?, icon? }- Leading avatar instead of an icon.
- badge
ReactNode- Right-aligned extra. A string or number becomes a small Badge.
| Prop | Type | Default | Description |
|---|---|---|---|
| trigger | ReactElement | - | Usually DropdownButton, DropdownIconButton or DropdownAvatarButton. Any element that takes a ref and onClick works. |
| items | DropdownItem[] | DropdownSection[] | - | Menu rows plus the extra kinds below. Sections get an optional label and a hairline between them. |
| onSelect | (item, event) => void | - | Gets the original row. For links, call event.preventDefault() to stop the navigation. |
| header / footer | ReactNode | - | Fixed content around the rows. DropdownHeader is a ready-made user card. |
| align / side / width | "start" | "end" / "top" | "bottom" | "auto" / number | "trigger" | "start" / "auto" / content | Passed straight to Menu. |
| open / onOpenChange | boolean / (open) => void | - | Optional control. |
| kind: "link" | { href, external? } | - | Navigates in the same tab, or opens a new tab with ↗ when external. |
| kind: "toggle" | { checked } | - | A switch on the right. The row is a menuitemcheckbox, so the menu stays open. |
| avatar | { label, src?, icon? } | - | Leading avatar instead of an icon. |
| badge | ReactNode | - | Right-aligned extra. A string or number becomes a small Badge. |
What it handles
- 01Maps its own row kinds (item, radio, checkbox, link and toggle) onto Menu rows, so Menu keeps the keyboard, focus and typeahead.
- 02Renders a link row as a real anchor, adds an arrow glyph when external is set, and lets onSelect call preventDefault to cancel the navigation.
- 03Draws a toggle row as a switch inside a menuitemcheckbox and keeps the menu open while you flip it.
- 04Accepts a leading avatar and a trailing badge on any row, and turns a string or number badge into a small accent Badge.
- 05Ships four triggers: DropdownButton with a chevron that rotates while open, DropdownIconButton with a tooltip, DropdownAvatarButton for accounts, and a DropdownHeader card for the header slot.
- 06Opens a submenu from any row that has an items array, and hands onSelect the original row object instead of the mapped one.
States
- First render
- Nothing. The menu stays closed until the trigger is used
- none
- Open
- The panel fades in next to the trigger
- 120ms, opacity only
- Chevron
- The chevron on DropdownButton and DropdownAvatarButton turns 180 degrees while the menu is open
- 120ms, ease out
- Trigger hover
- The avatar trigger takes a soft muted background
- 120ms, ease out
- Toggle row
- The switch thumb slides and the track recolours while the menu stays open
- 120ms, ease out
- Reduced motion
- The panel and the chevron change at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. The menu stays closed until the trigger is used | none |
| Open | The panel fades in next to the trigger | 120ms, opacity only |
| Chevron | The chevron on DropdownButton and DropdownAvatarButton turns 180 degrees while the menu is open | 120ms, ease out |
| Trigger hover | The avatar trigger takes a soft muted background | 120ms, ease out |
| Toggle row | The switch thumb slides and the track recolours while the menu stays open | 120ms, ease out |
| Reduced motion | The panel and the chevron change at once | 0ms |
Works with
- MenuInstalled with it. Dropdown is a mapping layer over Menu and passes every other prop straight through.
- AvatarInstalled with it. Row avatars and the account trigger are Avatar at its xs, sm and md sizes.
- BadgeInstalled with it. Count and plan badges on rows and in the header are Badge.
- TooltipInstalled with it. DropdownIconButton wraps the more button in a Tooltip.
When to use
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Dropdown to my app and wire it to my own data.
- I need ready-made menus: account menu, row actions, pickers with avatars, toggles and badges. Set that up with the Knowns UI Dropdown.
- Which Dropdown props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "dropdown" }) and search_docs({ query: "dropdown" }).