Skip to main content
cmdk is written in TypeScript and ships a .d.ts declaration file. All component prop types are available for inference via React.ComponentProps utilities.
The prop type interfaces (CommandProps, ItemProps, etc.) are not exported as named exports from the package. To type component props in your own code, use React.ComponentProps<typeof Command>, React.ComponentProps<typeof Command.Item>, etc.

Import styles

cmdk supports two import styles. Both are fully typed.
The namespace import (Command) and the individual named exports (CommandRoot, CommandList, etc.) refer to the same underlying components. Use whichever style fits your project.

Component prop types

CommandProps

Props for the Command root component (also exported as CommandRoot).

CommandFilter

The type of the custom filter function accepted by Command.
Return a number between 0 and 1. A score of 0 hides the item entirely; 1 is the highest possible rank. The built-in defaultFilter export uses the command-score algorithm and can be used as a reference implementation or fallback.

DialogProps

Props for Command.Dialog, which renders the command menu inside a Radix UI Dialog. Extends all CommandProps plus the Radix DialogProps.

InputProps

Props for Command.Input. Extends the native <input> element, with value, onChange, and type omitted in favour of the controlled API below.

ListProps

Props for Command.List, the container that holds items and groups.

ItemProps

Props for Command.Item.

GroupProps

Props for Command.Group, which groups items under an optional heading.

SeparatorProps

Props for Command.Separator. The separator is automatically hidden when a search query is active.

LoadingProps

Props for Command.Loading, a progressbar rendered while async items are being fetched.

EmptyProps

Props for Command.Empty, which renders automatically when no items match the current query.

State type

The State type represents the internal state object exposed by useCommandState.

Real-world example

A fully typed command palette component using the namespace import style: