DashboardSearch
A command palette in a modal, opened by a shortcut (Ctrl or Cmd plus K by default).
On this page
Examples
Links and actions
Links navigate, other commands raise OnSelect. Everything else, including the shortcut, runs in the browser.
Last command: none
Razor
@* Press Ctrl+K (Cmd+K on a Mac), or use the button. The shortcut and the button are handled in the browser, so they work
in static rendering too. *@
<div class="flex flex-col items-start gap-3" data-testid="dashboard-search-example">
<div class="w-64">
<KlyDashboardSearchButton data-testid="dashboard-search-example-button" />
</div>
<p class="text-sm text-(--klyroo-text-muted)" data-testid="dashboard-search-example-last">Last command: @(_last ?? "none")</p>
<KlyDashboardSearch Groups="_groups" OnSelect="item => _last = item.Label" />
</div>
@code {
private string? _last;
private static readonly KlyCommandGroup[] _groups =
[
new("Go to",
[
new() { Label = "Inbox", Href = "?view=inbox", Keywords = "mail messages" },
new() { Label = "Settings", Href = "?view=settings", Keywords = "preferences account" },
]),
new("Actions",
[
new() { Label = "Compose message", Keywords = "new write" },
new() { Label = "Sign out", Keywords = "logout" },
]),
];
}API
KlyDashboardSearch
Command palette in a modal for a dashboard, opened by a keyboard shortcut.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Groups (required) |
IReadOnlyList |
The commands, in groups: links navigate, other commands go to OnSelect . | |
Label |
string |
Accessible name of the dialog and the search field. Defaults to the built-in text. | |
Open (@bind-Open) |
bool |
false |
Open state. Use @bind-Open ; the browser opens and closes the search on its own. |
Placeholder |
string |
Hint of the search field. Defaults to the built-in text. | |
Shortcut |
string |
"mod+k" |
The keyboard shortcut that opens the search: "mod+k" by default, where mod is Cmd on Apple platforms and Ctrl elsewhere. Ctrl, meta, alt and shift are accepted too. |
Ui |
CommandPaletteUi |
Slot overrides of the command palette. |
Events
| Name | Type | Description |
|---|---|---|
OnSelect |
EventCallback |
Called with the activated command. Link commands navigate as well. The search closes in either case. |
Ui slots
Ui takes a CommandPaletteUi with one class string per slot, merged after the theme.
| Slot | Styles |
|---|---|
Root |
Classes merged into the root slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
InputWrapper |
Classes merged into the inputWrapper slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
InputIcon |
Classes merged into the inputIcon slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
Input |
Classes merged into the input slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
Listbox |
Classes merged into the listbox slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
Group |
Classes merged into the group slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
GroupLabel |
Classes merged into the groupLabel slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
Item |
Classes merged into the item slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
ItemIcon |
Classes merged into the itemIcon slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
ItemWrapper |
Classes merged into the itemWrapper slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
ItemLabel |
Classes merged into the itemLabel slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
ItemDescription |
Classes merged into the itemDescription slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
ItemShortcut |
Classes merged into the itemShortcut slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
ItemCount |
Classes merged into the itemCount slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
Empty |
Classes merged into the empty slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |
Status |
Classes merged into the status slot of KlyCommandPalette , KlyContentSearch and KlyDashboardSearch , after the theme and the app configuration. |