Skip to content

Dropdown

Ready-made menus on top of Menu: account, row actions and pickers, with avatar, toggle, link and badge rows.

On this page
Used for
  • Account menu
  • Row actions
  • Model picker
  • Workspace switcher
  • Share options

Examples

Installation

npx knowns-ui@latest add dropdown
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

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.

What it handles

  1. 01Maps its own row kinds (item, radio, checkbox, link and toggle) onto Menu rows, so Menu keeps the keyboard, focus and typeahead.
  2. 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.
  3. 03Draws a toggle row as a switch inside a menuitemcheckbox and keeps the menu open while you flip it.
  4. 04Accepts a leading avatar and a trailing badge on any row, and turns a string or number badge into a small accent Badge.
  5. 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.
  6. 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

Works with

When to use

When to use

  • Ready-made menus: account menu, row actions, pickers with avatars, toggles and badges.

When not to use

  • Building your own menu from scratch: use Menu.
  • Choosing a value in a form: use Select.

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" }).

Need help?

Stuck on Dropdown, or found something off? We read every message.