Skip to content
kitn AI/UI

Command

kai-command

Filters as the user types while keyboard navigation keeps working, for picking from long lists.

  • Shadow DOM
  • Grouped + filterable
  • Full keyboard nav
  • role: listbox

Set items as a JS property: a flat array, never an attribute. Each item needs an id (echoed back in kai-select) and a label; add group to bucket it under a header, plus icon and description. Listen for kai-select for the picked id, and kai-query-change to drive your own async filtering.

<kai-command placeholder="Search files, chats, people…"></kai-command>
<script type="module">
import '@kitn.ai/ui/web-components';
const el = document.querySelector('kai-command');
// Array prop — set in JS, never as an HTML attribute.
el.items = [
{ id: 'screen9', label: 'screen9.py', icon: 'file-text', description: '/Users/rob/screen9.py', group: 'Files' },
{ id: 'rs', label: 'Record screen', icon: 'message-circle', group: 'Chats' },
];
el.addEventListener('kai-select', (e) => console.log('picked', e.detail.id));
el.addEventListener('kai-query-change', (e) => console.log('query', e.detail.value));
</script>

Grouped across Mac apps, Chats, and Files, each row with an icon and a path.

Actions bucketed into Actions and Settings; drop description and each row is one line.

Omit group on every item for one flat, unsectioned list.

PropertyTypeDefaultNotes
theme'auto'Color mode (`auto` follows prefers-color-scheme).
items—Flat list of items. Set as a JS property, not an HTML attribute.
placeholder—Placeholder text for the search input.
emptyLabel—Label shown when no items match the current query.
EventDetailNotes
The highlighted item changed. `detail.id` is `undefined` when nothing is active (e.g. the filtered list is empty).
Fired on every keystroke in the search input.
Fired when the user selects an item (click or Enter).
MethodSignatureNotes
(options?: FocusOptions): voidFocus the search combobox input inside the shadow root so the palette is type-ready on demand (Shadow-DOM autofocus is unreliable, so hosts call this after opening the palette).
(): voidBlur the focused search input.
(): voidReset the search query to empty, re-showing all items, and fire `kai-query-change` with `''`. Mirrors the Escape-key behavior.

This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.

CommandList