Overview
Individual selectable row within a command palette or dropdown command list.
keys shows a key sequence at the end of the row, read as "G then H" (each key in a Kbd); a single key shows alone. It is text in the row, so it joins the option's accessible name unless accessibleLabel is set. A sequence is not a chord, so it does not set aria-keyshortcuts; pass keyboardShortcut for a chord.
Usage
CommandItemProps is a discriminated union that the table above flattens to one row. With the default selectionMode: 'item', onSelect is required. With selectionMode: 'parent' — the mode CommandMenu uses — onSelect is optional and activation is owned by the parent list.
When to use
- Declaring an individual command, action, or result row inside a command-palette or command-menu.
- Composing a custom palette layout via children rather than the items prop.
- Used outside a command-palette or command-menu ancestor — the component throws at construction.
- Rendering a generic dropdown choice — use dropdown-item instead.
Props
Name | Type | Default | Description |
|---|---|---|---|
value required | text | Submitted value; surfaced through the registration record. | |
onSelect | () => void | Invoked when the item is activated inside CommandPalette. | |
selectionMode | 'item' | 'item' | selectionMode is a compile-time discriminant that only controls whether
onSelect is required; it has no runtime effect on activation dispatch.
'item' is the default CommandPalette mode, in which this component's
own onSelect is required. |
disabled | boolean | false | When true, the item is skipped by arrow keys and cannot be activated. |
description | text | Optional secondary text shown below the main label. | |
accessibleLabel | text | Accessible name for the option when the rendered row contains secondary text or rich content. | |
keyboardShortcut | text | Keyboard shortcut exposed through aria-keyshortcuts, e.g. Meta+N. | |
keys | string[] | A key sequence shown at the end of the row, read as "G then H": each key in a Kbd, with "then"
between them. One key shows alone ("C"). It is text in the row, so it joins the option's
accessible name unless accessibleLabel is set; it does not set aria-keyshortcuts, which
describes a chord, not a sequence. Pass keyboardShortcut as well for a chord. | |
leading | snippet | Leading content (icon, avatar). Rendered with aria-hidden. | |
leadingTone | 'neutral' | 'warning' | undefined | 'neutral' | How the leading content is drawn. neutral is a bare glyph in muted ink; warning is the
glyph on a small amber tile, for a row that is waiting on the person. |
meta | snippet | Muted secondary text, beside the label by default and below it in a docked command palette.
Rendered with aria-hidden, so name the row with accessibleLabel when the meta carries meaning. | |
trailing | snippet | Trailing content (kbd hint, badge). Rendered with aria-hidden. | |
children required | snippet | Main label content. |