Command menu in cmdk
cmdk gives you a command menu component for React: you render the items and it filters and sorts them as the user types.
How it works
- Compose the menu from parts. The menu is built from
Command,Command.Input,Command.ListandCommand.Item. Typing in the input narrows the list without any filtering code of our own. [1] - Groups, separator and empty state.
Command.Groupadds a heading above related items, andCommand.Separatordraws a divider.Command.Emptyshows its text when the search matches nothing. [1] - Style it with data attributes. cmdk ships no styles, so the
<style>block targets selectors such as[cmdk-input],[cmdk-item]and[data-selected="true"]to build a dark theme. [1]
Run and edit it
It runs in your browser, in a sandboxed frame that cannot see this site; the packages load from esm.sh only after you press Run.
Checked Oct 12, 2026: it starts without errors in Chromium with cmdk 1.1.1, react 19.3.0, react-dom 19.3.0. Needs WebGL.
More cmdk examples
Cmd+K command dialog in cmdk Custom filter and keywords in cmdk Nested pages in cmdk useCommandState in cmdk
Sources
Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.