Kbd
A keyboard key or shortcut, in four variants and five sizes.
On this page
Examples
Variants, sizes and shortcuts
KKKK
EscEscEscEscEsc
Open the search with Ctrl K
Razor
<div class="flex flex-col items-center gap-4">
<div class="flex flex-wrap items-center gap-2">
@foreach (var variant in Enum.GetValues<KlyVariant>())
{
<KlyKbd Variant="variant" Value="K" />
}
</div>
<div class="flex flex-wrap items-center gap-2">
@foreach (var size in Enum.GetValues<KlySize>())
{
<KlyKbd Size="size" Value="Esc" />
}
</div>
<p class="flex items-center gap-1 text-sm">
Open the search with <KlyKbd Value="Ctrl" /> <KlyKbd Value="K" />
</p>
</div>API
KlyKbd
Keyboard key cap, to show a shortcut.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Color |
KlyColor |
"neutral" |
Semantic color of the kbd: a built-in KlyColor or the name of a color you defined. Values: primary, secondary, success, info, warning, error, neutral. |
Size |
KlySize |
KlySize. |
Size of the kbd, from Xs to Xl . When not set, Size applies, else the default of the component. Values: Xs, Sm, Md, Lg, Xl. |
Ui |
KbdUi |
Per-instance class overrides of the slots of the kbd, see KbdUi . They are merged after the theme and the Class parameter wins on the root slot. | |
Value |
string |
The key to show, "Ctrl" or "K" for example. ChildContent wins when both are set. | |
Variant |
KlyVariant |
KlyVariant. |
Look of the key cap: Solid , Outline , Soft or Subtle . Values: Solid, Outline, Soft, Subtle. |
Slots
| Name | Type | Description |
|---|---|---|
ChildContent |
RenderFragment |
The key, when Value is not enough. |
Ui slots
Ui takes a KbdUi with one class string per slot, merged after the theme.
| Slot | Styles |
|---|---|
Base |
Classes merged into the base slot of KlyKbd , after the theme and the app configuration. |