Command

Navigation

A searchable list of commands: <Command.Root> holds a Command.Input that filters the Command.Items (value, keywords, onSelect) and Command.LinkItems (href) in a Command.List, grouped with Command.Group (heading) and divided with Command.Separator. Command.Empty shows when nothing matches, Command.Loading while results load, Command.Shortcut a key hint. Arrow keys move, Enter runs. Command.Dialog puts it all in a dialog as a command palette.

import { Command } from '@limerdev/zest';
Command for AI tools (llms.txt)
Use for
A command palette (⌘K), or picking from a long list by typing: jump to a project, run an action.
Don't
Choosing a value for a form field: use Combobox. A short list that fits on screen: use DropdownMenu.

Examples

Basic

Typing filters by value and keywords; arrow keys move, Enter runs.

Ran: nothing yet

A palette

Command.Dialog as a palette, opened with ⌘K or Ctrl+K.

Props

Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that renders your own element, with props to spread on it).

Command.Root

Prop Type Default Description
columns number | null null The number of columns in a grid layout.
disableInitialScroll boolean false Whether to disable scrolling the selected item into view on initial mount. When true, prevents automatic scrolling when the command menu first renders and selects its first item, but still allows scrolling on subsequent selections.
disablePointerSelection boolean – Optionally set to true to disable selection via pointer events.
filter ((value: string, search: string, keywords?: string[] | undefined) => number) – A custom filter function for whether each command item should match the query. It should return a number between 0 and 1, with 1 being a perfect match, and 0 being no match, resulting in the item being hidden entirely. By default, it will use the computeCommandScore function exported by this package to compute the score.
label string – An accessible label for the command menu. Not visible & only used for screen readers.
loop boolean – Optionally set to true to enable looping through the items when the user reaches the end of the list using the keyboard.
onStateChange ((state: Readonly<CommandState>) => void) – A function that is called when the command state changes.
onValueChange ((value: string) => void) – A function that is called when the selected command menu item changes. It receives the new value as an argument.
shouldFilter boolean – Optionally set to false to turn off the automatic filtering and sorting. If false, you must conditionally render valid items yourself.
value bindable string '' Optionally provide or bind to the selected command menu item.
vimBindings boolean true Set this prop to false to disable the option to use ctrl+n/j/p/k (vim style) navigation.

Command.Dialog

Prop Type Default Description
columns number | null null The number of columns in a grid layout.
description string the Config's `strings.commandPaletteDescription`, else 'Search for a command to run.' The palette's description for screen readers.
disableInitialScroll boolean false Whether to disable scrolling the selected item into view on initial mount. When true, prevents automatic scrolling when the command menu first renders and selects its first item, but still allows scrolling on subsequent selections.
disablePointerSelection boolean – Optionally set to true to disable selection via pointer events.
filter ((value: string, search: string, keywords?: string[] | undefined) => number) – A custom filter function for whether each command item should match the query. It should return a number between 0 and 1, with 1 being a perfect match, and 0 being no match, resulting in the item being hidden entirely. By default, it will use the computeCommandScore function exported by this package to compute the score.
label string – An accessible label for the command menu. Not visible & only used for screen readers.
loop boolean – Optionally set to true to enable looping through the items when the user reaches the end of the list using the keyboard.
onOpenChange OnChangeFn<boolean> – A callback that is called when the popover's open state changes.
onOpenChangeComplete OnChangeFn<boolean> – A callback called when the dialog finishes opening/closing animations.
onStateChange ((state: Readonly<CommandState>) => void) – A function that is called when the command state changes.
onValueChange ((value: string) => void) – A function that is called when the selected command menu item changes. It receives the new value as an argument.
open bindable boolean false The open state of the dialog.
portalProps PortalProps – Props for the portal the content renders in: to (the element to render in, the body by default) and disabled (render in place).
shouldFilter boolean – Optionally set to false to turn off the automatic filtering and sorting. If false, you must conditionally render valid items yourself.
showCloseButton boolean false Show a close button in the corner.
title string the Config's `strings.commandPalette`, else 'Command palette' The palette's name for screen readers.
value bindable string '' Optionally provide or bind to the selected command menu item.
vimBindings boolean true Set this prop to false to disable the option to use ctrl+n/j/p/k (vim style) navigation.

Command.Empty

Prop Type Default Description
forceMount boolean – Whether to force mount the group container regardless of filtering logic.

Command.Group

Prop Type Default Description
forceMount boolean – Whether to force mount the group container regardless of filtering logic.
heading string – The group's heading, which names the group.
value string – A unique value for the group.

Command.Item

Prop Type Default Description
disabled boolean false Whether the item is disabled.
forceMount boolean – Whether to always mount the item regardless of filtering logic.
keywords string[] – A list of keywords that will be used to filter the item.
onSelect (() => void) – A callback that is fired when the item is selected, either via click or keyboard selection.
value string – A unique value for this item that will be used when filtering and ranking the items. If not provided, an attempt will be made to use the textContent of the item. If the textContent is dynamic, you will need to provide a stable unique value for the item.

Command.LinkItem

Prop Type Default Description
disabled boolean false Whether the item is disabled.
forceMount boolean – Whether to always mount the item regardless of filtering logic.
keywords string[] – A list of keywords that will be used to filter the item.
onSelect (() => void) – A callback that is fired when the item is selected, either via click or keyboard selection.
value string – A unique value for this item that will be used when filtering and ranking the items. If not provided, an attempt will be made to use the textContent of the item. If the textContent is dynamic, you will need to provide a stable unique value for the item.

Command.Input

Prop Type Default Description
value bindable string '' The value of the input element, used to search/filter items.

Command.List

No props of its own beyond the common ones.

Command.Separator

Prop Type Default Description
forceMount boolean – Whether to force mount the separator container regardless of filtering logic.

Command.Shortcut

No props of its own beyond the common ones.

Command.Loading

Prop Type Default Description
progress number – The current progress of the loading state. This is a number between 0 and 100.