ContentSearchButton
A button that opens the search and shows its shortcut.
On this page
Examples
Full and icon only
These buttons open the search of this site, the one in the header.
Razor
@* The button opens the search it names (the unnamed one by default, which is the search of this site). *@
<div class="flex flex-wrap items-center gap-3" data-testid="content-search-button-example">
<KlyContentSearchButton Collapsed="false" data-testid="content-search-button-full" />
<KlyContentSearchButton data-testid="content-search-button-icon" />
<KlyContentSearchButton Collapsed="false" Variant="ButtonVariant.Soft" Label="Find a page" />
</div>API
KlyContentSearchButton
Button that opens the KlyContentSearch of the page and shows its keyboard shortcut.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Collapsed |
bool |
true |
Shows only the icon, as a square button. Without it the button shows its label and its shortcut. |
Color |
KlyColor |
"neutral" |
Semantic color of the content search button: a built-in KlyColor or the name of a color you defined. Values: primary, secondary, success, info, warning, error, neutral. |
For |
string |
"" |
The Name of the search to open. Without it the button opens the unnamed one. |
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; with Collapsed it is the accessible name. | |
Size |
KlySize |
KlySize. |
Size of the content search button, from Xs to Xl . When not set, Size applies, else the default of the component. Values: Xs, Sm, Md, Lg, Xl. |
Ui |
Content |
Per-instance class overrides of the slots of the content search button, see ContentSearchButtonUi . They are merged after the theme and the Class parameter wins on the root slot. | |
Variant |
ButtonVariant |
ButtonVariant. |
Look of the button: Solid , Outline , Soft , Subtle , Ghost or Link . Values: Solid, Outline, Soft, Subtle, Ghost, Link. |
Ui slots
Ui takes a Content with one class string per slot, merged after the theme.
| Slot | Styles |
|---|---|
Root |
Classes merged into the root slot of KlyContentSearchButton , after the theme and the app configuration. |
Label |
Classes merged into the label slot of KlyContentSearchButton , after the theme and the app configuration. |
Kbds |
Classes merged into the kbds slot of KlyContentSearchButton , after the theme and the app configuration. |