Skip to content
kitn AI/UI

Scope Picker

kai-scope-picker

A lightweight filter dropdown for narrowing a conversation or search to a specific author or tag — drop it in a chat header and listen for one event.

  • Shadow DOM
  • 1 event
  • Authors + tags sections
  • 2 array properties
  • Pairs with any header control

Set availableAuthors and availableTags in JavaScript (arrays can’t be HTML attributes) and listen for kai-scope-change:

<kai-scope-picker id="scope"></kai-scope-picker>
<script type="module">
import '@kitn.ai/ui/elements';
await customElements.whenDefined('kai-scope-picker');
const el = document.getElementById('scope');
el.availableAuthors = ['Alex Chen', 'Jordan Lee'];
el.availableTags = ['design', 'engineering'];
el.addEventListener('kai-scope-change', (e) => {
const { filters } = e.detail;
console.log(filters ?? 'all');
});
</script>
  • current-label — HTML attribute controlling the trigger button text (default 'All Content'). Update it after each kai-scope-change to reflect the active filter.
  • kai-scope-changedetail.filters is undefined when “All Content” is selected, or { authors?: string[], tags?: string[] } for a specific filter.
  • Passing an empty array for either property hides that section entirely.

Both sections populated — the dropdown shows an Authors group and a Tags group below “All Content”.

Non-empty availableAuthors, empty availableTags — renders only the Authors section.

Non-empty availableTags, empty availableAuthors — renders only the Tags section.

Both arrays empty — the dropdown shows only “All Content”. Useful while options are loading asynchronously.

Set current-label to reflect an already-active scope. Your app owns this state and updates the attribute on each kai-scope-change.

PropertyTypeDefaultNotes
theme'auto'Color mode (`auto` follows prefers-color-scheme).
availableAuthors[]Authors to offer as scope filters. Omit to drop the Authors section (for a tag-only picker). Set as a JS property.
availableTags[]Tags to offer as scope filters. Omit to drop the Tags section (for an author-only picker). Set as a JS property.
currentLabel'All Content'The label shown on the trigger for the active scope.
openDrive/observe the dropdown's open state (Shoelace-style: settable + reflected to the `open` attribute, the dropdown still self-manages on click/keyboard). Set `el.open = true`, or `<kai-scope-picker open>`; listen for `kai-open-change`.
defaultOpenInitial open state on mount (uncontrolled seed).
disabledDisable the trigger: click/keyboard and `show()` no longer open the dropdown.
EventDetailNotes
The scope dropdown opened or closed (by click, keyboard, Escape, outside-click, or a method).
A scope was chosen (`undefined` filters = "All Content").
MethodSignatureNotes
(): voidOpen it programmatically (no-op while disabled).
(): voidClose it programmatically.
(): voidFlip the open state (closes while disabled).

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

ChatScopePicker