Skip to content
nexubDesign System
v11.9.0

Components · Navigation

Command List

AlphaAdded v11.2.0

A search box over a filtered, grouped list you move through with the keyboard. Inline: put it in a Dialog, Sheet, Drawer or page.

import { CommandList } from '@nexub/react';
View as Markdown

Usage

Use it for
  • Picking one item from a long list inside a dialog or sheet: move to folder, assign to, jump to.

  • A search the server answers (`onSearch` with `loading`).

Use something else for
  • An app-wide launcher opened with Cmd+K: use CommandPalette.

  • A form field that shows the picked value: use ComboboxField.

  • Ten choices or fewer: use a RadioGroup or Select.

Playground

Props

Picked: —

TSX
<CommandList items={items} onSelect={setPicked} autoFocus={false} />

Examples

Default

Picked: —

In a dialog

States

  • Picked: —

    default
  • Loading…

    Picked: —

    loading

Props

Props
PropTypeDefaultDescription
itemsrequiredCommandListItem[]—{ value, label, description?, keywords?, icon?, group?, disabled?, shortcut? }. description and keywords are searched too; group lists the item under a heading; shortcut shows keys at the end of the row.
onSelect((value: string, item: CommandListItem) => void)—Called when an item is picked with Enter or a click.
labelstringmessages.searchAccessible name of the search box and list.
placeholderstringmessages.searchPlaceholderThe search box placeholder.
emptyTextReact.ReactNodemessages.noResultsShown when the search finds nothing.
onSearch((text: string) => void)—Server search: while onSearch is set the list is not filtered here. loading shows a busy row.
loadingboolean—Server search: while onSearch is set the list is not filtered here. loading shows a busy row.
autoFocusbooleantrueFocus the search box on mount.
maxHeightstring20remThe list scrolls past this height (any CSS length).
classNamestring—

Accessibility

Keyboard

  • Arrow Up / Arrow Down

    Moves the highlight; wraps at the ends.

  • Home / End

    Moves to the first or last item.

  • Enter

    Picks the highlighted item.

Notes

  • Focus stays in the search box, a `combobox` that points at the highlighted `option` with `aria-activedescendant`.

  • Group headings name their groups; disabled items are skipped and marked `aria-disabled`.

  • While loading, the list has `aria-busy`.

On iOS & Android