Kbd
Keyboard key indicator rendered as an inline kbd element with terminal styling.
size="sm" renders 10px type — a dense desktop-legend size. On mobile/touch
surfaces keep the default size="md".
Installation
dgadd ships in @diffgazer/add on npm: pnpm add -D @diffgazer/add puts it on pnpm exec, and npx @diffgazer/add runs it without the install.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS from the installed package.
Usage
Examples
Sizes
Inline
Group
API Reference
Kbd
KbdGroup
Accessibility
Notes
Size Variants
Available in sm and md sizes (defaults to md). Renders inline, designed for use inside text.
Terminal Styling
Rendered with a hairline border and a translucent --foreground fill so the key cap carries the same inline weight in light and dark palettes.
Inverse surfaces
Use `variant="inverse"` for caps on a bar painted in --foreground (shortcut legends, app footers). It mirrors the same border/fill recipe against --background, so the cap keeps its weight instead of disappearing into the inverted bar.
Chord Grammar
Two grammars are supported and should not be mixed on one surface: platform chords place modifier glyphs adjacent with no separator (Command K), spelled-out chords use a dimmed + between caps (Ctrl + Shift + P). Wrap either in KbdGroup and give the group an aria-label so assistive tech announces the whole shortcut.
Source
Install via CLI: pnpm exec dgadd add ui/kbd.
Highlighted source loads after this disclosure opens. Browse the source repository.