Components
BaseCommandDialog
A command palette or search dialog: a search field, grouped results and keyboard navigation.
components/ui/BaseCommandDialog.vue
View in the demo
Example
The dialog only draws the results: filter them yourself with the query model and pass them as groups. Arrow keys move the active row, Enter emits select with the item and closes the dialog, and Escape closes it. Items with child are indented under the row above them, as the sections of a page in the documentation search. AppCommandPalette and the documentation search are built on it.
API
Props
Name | Type | Default | Description |
|---|---|---|---|
groupsrequired | BaseCommandGroup<T>[] | — | Each { key, title?, items }; an item is { key, title, subtitle?, icon, child? } plus any data you need back in select. |
label | string | — | The accessible name of the dialog and its field. |
placeholder | string | — | The placeholder of the search field. |
highlight | boolean | false | Marks the query in titles and subtitles with BaseTextMatch. |
max-width | number | 640 | The width of the dialog in pixels. |
results-height | number | 420 | The maximum height of the results before they scroll. |
v-model | boolean | false | — |
query | string | "" | — |
Slots
Name | Slot props | Description |
|---|---|---|
#empty | — | Shown when there are no groups, such as a BaseEmptyState. |
Events
Name | Payload | Description |
|---|---|---|
@select | [item: T] | An item was chosen with a click or Enter. |
@update:modelValue | [value: boolean] | — |
@update:query | [value: string] | — |