Command
A searchable command list and palette — a combobox input, keyboard-highlighted options, groups and built-in filtering.
Angular: available Vue: available React: available React Native: not available yet
Usage
Selected: nothing yet
<div class="demo-stack" style="max-width: 26rem">
<sone-command style="box-shadow: 0 0 0 1px var(--border)">
<input soneCommandInput placeholder="Type a command or search…" aria-label="Search commands" />
<div soneCommandList aria-label="Commands">
<div soneCommandEmpty>No results found.</div>
<div soneCommandGroup heading="Notes">
@for (note of notes; track note) {
<div soneCommandItem (select)="picked.set($event)">{{ note }}</div>
}
</div>
<div soneCommandSeparator></div>
<div soneCommandGroup heading="Actions">
<div soneCommandItem value="New note" [keywords]="['create', 'add']" (select)="picked.set($event)">New note</div>
<div soneCommandItem value="Start recording" [keywords]="['record', 'meeting']" (select)="picked.set($event)">Start recording</div>
<div soneCommandItem value="Export" disabled>Export (locked)</div>
</div>
</div>
</sone-command>
<p style="margin: 0; color: var(--text-secondary)">Selected: {{ picked() ?? "nothing yet" }}</p>
<div class="demo-row">
<button soneBtn variant="outline" type="button" (click)="paletteOpen.set(true)">
Open the palette <sone-kbd>⌘K</sone-kbd>
</button>
</div>
</div>
@if (paletteOpen()) {
<sone-command-dialog label="Command palette" (dismiss)="paletteOpen.set(false)">
<sone-command>
<input soneCommandInput data-autofocus placeholder="Search notes…" aria-label="Search notes" />
<div soneCommandList aria-label="Notes">
<div soneCommandEmpty>No notes match.</div>
@for (note of notes; track note) {
<div soneCommandItem (select)="picked.set($event); paletteOpen.set(false)">{{ note }}</div>
}
</div>
</sone-command>
</sone-command-dialog>
}Import
import {
SoneCommandComponent,
SoneCommandDialogComponent,
SoneCommandEmptyDirective,
SoneCommandGroupComponent,
SoneCommandInputDirective,
SoneCommandItemDirective,
SoneCommandListDirective,
SoneCommandSeparatorDirective,
} from "@surface-one/angular/command";API reference
SoneCommandComponentComponent
`<sone-command>` — a filterable command list (shadcn/ui Command, spartan/ui brn-command): a combobox input over a listbox. The input keeps focus; the highlighted option is announced through `aria-activedescendant`. Arrow keys, Home / End and PageUp / PageDown move the highlight, Enter selects it. Filtering is built in (case- and accent-insensitive, item `value` + `keywords`); set `shouldFilter` to `false` when the list already comes filtered from a server.
| Name | Type | Default |
|---|---|---|
searchtwo-wayThe search text — `[(search)]`; the `soneCommandInput` writes it. | string | "" |
shouldFilterFilter the items by `search`. Turn off for server-side search. | boolean | true |
filterA custom match function (default `soneCommandFilter`). | SoneCommandFilter | soneCommandFilter |
loopArrow keys wrap from the last option to the first. | boolean | false |
activetwo-wayThe highlighted option's value — `[(active)]`. | string | null | null |
SoneCommandDialogComponentComponent
`<sone-command-dialog>` — a `sone-dialog` sized and padded for a command palette (shadcn/ui CommandDialog). Project a `<sone-command>` into it; render it with `@if` and close it on `(dismiss)`, like any dialog. Escape, the scrim and focus return come from `sone-dialog`.
| Name | Type | Default |
|---|---|---|
labelrequiredNames the dialog for assistive technology. | string | — |
size | DialogSize | "md" |
| Name | Type |
|---|---|
dismiss | void |
SoneCommandEmptyDirectiveDirective
`[soneCommandEmpty]` — shown only when no option matches.
SoneCommandGroupComponentComponent
`[soneCommandGroup]` — a labelled group of options; it hides when none of them match.
| Name | Type | Default |
|---|---|---|
heading | string | null | null |
SoneCommandInputDirectiveDirective
`input[soneCommandInput]` — the combobox that searches the command list and keeps focus.
SoneCommandItemDirectiveDirective
`[soneCommandItem]` — one option. `value` is what the search matches (default: the text content) and what `select` emits; `keywords` match too.
| Name | Type | Default |
|---|---|---|
value | string | null | null |
keywords | readonly string[] | [] |
disabled | boolean | false |
id | string | soneId("sone-command-item") |
| Name | Type |
|---|---|
selectChosen with a click or Enter; emits the item's value. | string |
SoneCommandListDirectiveDirective
`[soneCommandList]` — the listbox; it scrolls when the options overflow.
| Name | Type | Default |
|---|---|---|
id | string | soneId("sone-command-list") |
SoneCommandSeparatorDirectiveDirective
`[soneCommandSeparator]` — a divider between groups; hidden while searching.