Skip to content
Glint UI

Kbd

A key cap, and the row of them a chord is written as.

Usage

import { Kbd, KbdGroup } from "@glint/components/kbd.slint";
import { Tokens } from "@glint/theme/tokens.slint";
export component AppWindow inherits Window {
width: 560px;
height: 200px;
background: Tokens.color-background;
VerticalLayout {
alignment: center;
padding: 24px;
HorizontalLayout {
alignment: center;
KbdGroup {
Kbd { text: "Esc"; }
}
}
}
}

Kbd renders a keyboard key cap. KbdGroup lays out shortcut chords with consistent spacing between keys.

Examples

Tones

tone accommodates different surface backgrounds (on-glass, on-glow, muted) and semantic highlights (affirm-on-glass, deny-on-glass, affirm-on-glow, deny-on-glow).

Sizes

Use size: KbdSize.sm for dense menus and inline rows, or size: KbdSize.md for standard key caps.

API Reference

Properties

PropertyTypeDefaultDescription
textin stringno defaultLabel inside the key cap (e.g. , K).
sizein KbdSizeKbdSize.mdHeight + padding — sm, md.
tonein KbdToneKbdTone.on-glassSurface × semantics — on-glow, on-glass, muted, affirm/deny-on-glow, affirm/deny-on-glass.

Enums

EnumValues
KbdSizesm, md
KbdToneon-glow, on-glass, muted, affirm-on-glow, deny-on-glow, affirm-on-glass, deny-on-glass

KbdGroup

The chord: a row of caps with the theme’s gap between them. Layout only — each cap goes on announcing its own key, and a host embedding a chord as an ornament silences the caps the way it silences a lone one.

KbdGroup publishes no properties, callbacks or functions of its own. What a call site can set on it is the Slint HorizontalLayout it inherits.

Accessibility

  • Accessible text role. Key caps publish an accessible-role: text announcing the key name.
  • Embedded ornament silence. When a key hint is embedded inside an already-accessible component (such as a menu row describing its shortcut), silence the key cap with accessible-role: none to avoid duplicate announcements.