Skip to content
kitn AI/UI

Command

kai-command

A grouped, filterable command palette — feed it a flat list of items and it buckets them under section headers, filters on every keystroke, and handles arrow-key navigation. The backbone of an @-mention picker or a slash-command menu.

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

Set items as a JS property — a flat array, not an attribute. Each item needs an id (echoed back in kai-select) and a label; add a group to bucket it under a section header, an icon, and a description for a muted second line. The element groups, filters, and navigates for you; listen for kai-select to learn which id was picked, and kai-query-change if you want to drive your own async filtering.

<kai-command placeholder="Search files, chats, people…"></kai-command>
<script type="module">
import '@kitn.ai/ui/elements';
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>

The classic @-mention surface — items grouped across Mac apps, Chats, and Files, each with an icon and a path or subtitle. Type to filter across every group at once.

A command menu of actions bucketed into Actions and Settings. Drop the description and each row is a single tidy line.

Omit group on every item and the palette renders one flat, unsectioned list — handy for a short quick-switcher like a model picker.

PropertyTypeDefaultNotes
itemsFlat list of items. Set as a JS property — not an HTML attribute.
placeholderPlaceholder text for the search input.
emptyLabelLabel shown when no items match the current query.
EventDetailNotes
Fired when the highlighted/active item changes — via Arrow keys or when filtering re-clamps the active row. `id` is the newly active item's id, or `undefined` when no item is active (e.g. the filtered list is empty). Lets a host preview the active item without committing a selection.
Fired on every keystroke in the search input.
Fired when the user selects an item (click or Enter).

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

CommandList