DashboardSearchButton
A button that opens the search and shows its shortcut.
On this page
Examples
With the search
Inside a collapsed sidebar only the icon is shown.
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
KlyDashboardSearchButton
Button that opens the KlyDashboardSearch and shows its keyboard shortcut.
Parameters
| Name | Type | Description |
|---|---|---|
Class |
string |
Classes added to the root element, merged last so they win over the theme. |
Keys |
IReadOnlyList |
The keys of the shortcut to show, one KlyKbd each. Match the Shortcut of the search. Left out, the hint follows the platform in the browser (the command key and K on Apple devices, Ctrl and K elsewhere), matching the default mod+k shortcut, and the button announces aria-keyshortcuts . Keys you give are shown as given. |
Label |
string |
The text of the button. Defaults to the built-in text. |
Ui |
Dashboard |
Per-instance class overrides of the slots of the dashboard search button, see DashboardSearchButtonUi . They are merged after the theme and the Class parameter wins on the root slot. |
Ui slots
Ui takes a Dashboard with one class string per slot, merged after the theme.
| Slot | Styles |
|---|---|
Root |
Classes merged into the root slot of KlyDashboardSearchButton , after the theme and the app configuration. |
Icon |
Classes merged into the icon slot of KlyDashboardSearchButton , after the theme and the app configuration. |
Label |
Classes merged into the label slot of KlyDashboardSearchButton , after the theme and the app configuration. |
Kbds |
Classes merged into the kbds slot of KlyDashboardSearchButton , after the theme and the app configuration. |