cmdk
Command menu component library for React applications.
3. Used by agents' projects
Dependency in 393 public GitHub projects set up for AI coding agents that we scanned (6.3%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What cmdk does
cmdk is an unstyled React command menu where you write the items as plain composable JSX and the component filters and sorts them for you.
cmdk popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How cmdk is used
- cmdk is a dependency in 393 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (8.1% of the 4,867 JavaScript/TypeScript ones), #5 of 230 in ui components and icons.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,628; those are left out of every share on this page.
- Projects that use it most often also use Class Variance Authority (98.7%), Lucide React (98.5%), clsx (97.2%).
- It is more common in projects set up for Roo Code (12.6%) than for Gemini CLI (4.2%).
By coding agent
Often used with
cmdk in practice
Strengths
The README says the API is fully composable. Items can be wrapped in other components or written as static JSX. You do not have to pass them in as a data array.
Every part forwards props, including <code>ref</code>, to a real element. Every part also gets a <code>cmdk-</code> data attribute such as <code>[cmdk-item]</code> or <code>[cmdk-list]</code> for CSS. The README also links drop-in stylesheets as a starting point.
You can pass a custom <code>filter(value, search, keywords)</code> function that scores each item. Item-level <code>keywords</code> act as aliases that can affect rank. You can also turn built-in filtering off with <code>shouldFilter={false}</code>.
The FAQ says labeling, aria attributes and DOM ordering were tested with VoiceOver and Chrome DevTools. It also says the Dialog composes an accessible Dialog implementation.
Watch out for
The FAQ says cmdk does not virtualize. It reports good performance up to 2,000-3,000 items. For more, pass <code>shouldFilter={false}</code> and bring your own virtualization.
The component does not listen for the keyboard shortcut. The README's dialog example adds its own <code>keydown</code> listener to toggle <code>open</code>.
cmdk depends on React 18 hooks. The FAQ also says it is a client component, not a React server component.
A basic inline command menu
import { Command } from 'cmdk'
const CommandMenu = () => {
return (
<Command label="Command Menu">
<Command.Input />
<Command.List>
<Command.Empty>No results found.</Command.Empty>
<Command.Group heading="Letters">
<Command.Item>a</Command.Item>
<Command.Item>b</Command.Item>
<Command.Separator />
<Command.Item>c</Command.Item>
</Command.Group>
<Command.Item>Apple</Command.Item>
</Command.List>
</Command>
)
}More about cmdk
Funding
- GitHub Sponsors: https://github.com/pacocoursey
- 2 GitHub sponsors
Packages around it
- class-variance-authority: Component variant classes
- lucide-react: Icon set
- clsx: Class name joining
- tailwind-merge: Tailwind class merging
- @radix-ui: Headless UI primitives
- sonner: Toast notifications
More in UI components and icons
Alternatives
cmdk This page
Get started
Install it.
npm install cmdkRules for your agent
## cmdk
- Give every `Command.Item` a `key` and a unique `value`. If `value` is omitted it is inferred from `.textContent`, and values are always trimmed.
- Treat cmdk as a client component that requires React 18. Do not use it in a React server component.
- Add your own `keydown` listener for ⌘K/Ctrl+K and toggle `open` on `Command.Dialog`. cmdk does not listen for the shortcut.
- Keep `open` on `Command.Dialog` `false` during server rendering to avoid hydration mismatches.
- For lists beyond 2,000-3,000 items, pass `shouldFilter={false}`, filter yourself and add your own virtualization.
- Style through the `[cmdk-*]` data attributes. Groups are hidden with the `hidden` attribute, not unmounted.
- Use `useCommandState` only for advanced cases such as a detailed empty state. Conditionally render `Command.Loading` while async items load.