Kbd

Shows a keyboard key or shortcut.

Kbd is new in v0.4. It renders a <kbd> element styled as a key cap, for shortcut hints in menus, tooltips and help text.

Installation

bash
shellui add kbd

Usage

Inline

Use one Kbd per key.

Open the command palette with Ctrl K, or toggle the sidebar with Ctrl B.

<p class="text-sm text-muted-foreground">
    Open the command palette with <Kbd>Ctrl</Kbd> <Kbd>K</Kbd>, or toggle the sidebar with <Kbd>Ctrl</Kbd> <Kbd>B</Kbd>.
</p>

Shortcut list

Search CtrlK
Save CtrlS
Toggle sidebar CtrlB
Close Esc
<div class="w-full max-w-sm divide-y divide-border rounded-md border border-border text-sm">
    @foreach (var (label, keys) in shortcuts)
    {
        <div class="flex items-center justify-between px-3 py-2">
            <span>@label</span>
            <span class="flex items-center gap-1">
                @foreach (var key in keys)
                {
                    <Kbd>@key</Kbd>
                }
            </span>
        </div>
    }
</div>

@code {
    private readonly (string Label, string[] Keys)[] shortcuts =
    [
        ("Search", ["Ctrl", "K"]),
        ("Save", ["Ctrl", "S"]),
        ("Toggle sidebar", ["Ctrl", "B"]),
        ("Close", ["Esc"]),
    ];
}

API Reference

Parameter Type Default Description
ChildContent RenderFragment? null The key label
Class string? null Additional CSS classes

Accessibility

  • Uses the semantic <kbd> element
  • Kbd only displays a shortcut. Handle the key press yourself, or use Command Palette for a ready-made Ctrl+K menu

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.