Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dip/cmdk/llms.txt
Use this file to discover all available pages before exploring further.
Command is the root wrapper for the entire command menu. Render it inline in your UI, or use Command.Dialog to render it in an overlay. It manages all internal state including the current search query, selected item, and filtered results.
[cmdk-root]
All item values are trimmed with
String.trim() before being used for filtering or comparison.Props
Accessible label for the command menu. Rendered as a visually hidden
<label> element associated with the input. Use this to describe the purpose of the menu to screen reader users.Set to
false to disable automatic filtering and sorting. When disabled, you are responsible for conditionally rendering items based on the current search query. Useful for server-side filtering or virtualized lists.Custom filter function used to rank each item against the search query. Return a number between
0 and 1, where 1 is the best match and 0 hides the item entirely. Defaults to the built-in command-score algorithm.The value of the item that is selected when the menu first renders. Has no effect if
value is provided (controlled mode).The controlled value of the currently selected item. Use together with
onValueChange to manage selection state externally.Callback fired when the selected item changes. Receives the
value string of the newly selected item.When
true, keyboard navigation wraps around: pressing ArrowDown on the last item moves focus to the first item, and vice versa.When
true, moving the pointer over an item does not select it. Selection only changes through keyboard navigation or clicks.When
true, enables Ctrl+N / Ctrl+J to move down and Ctrl+P / Ctrl+K to move up, mirroring common Vim-style navigation bindings.Keyboard navigation
| Key | Action |
|---|---|
ArrowDown | Select next item |
ArrowUp | Select previous item |
Alt+ArrowDown | Select first item in the next group |
Alt+ArrowUp | Select first item in the previous group |
Meta+ArrowDown | Select last item |
Meta+ArrowUp | Select first item |
Home | Select first item |
End | Select last item |
Enter | Trigger onSelect on the selected item |
Ctrl+N / Ctrl+J | Select next item (vim bindings, when enabled) |
Ctrl+P / Ctrl+K | Select previous item (vim bindings, when enabled) |
Examples
Controlled selection
Passvalue and onValueChange to control which item is selected:
Custom filter function
Replace the default scoring algorithm with your own logic. The function receives the item’s value, the current search query, and returns a score between0 (hidden) and 1 (best match):
Custom filter with keywords
The filter function also receives a thirdkeywords argument — the array passed to each Command.Item. Use it to match against aliases:
Disable automatic filtering
SetshouldFilter={false} to take full control of which items are rendered. Useful for server-side search or when you have too many items to filter in the browser:
Looping navigation
Enable wrap-around keyboard navigation so pressingArrowDown on the last item returns to the first:
