Light

Kbd

Displays a keyboard key or shortcut in a styled inline element.

Spec · from metadata

When to use

  • Displaying keyboard shortcuts in menus, tooltips, or documentation
  • Command palette shortcut indicators
  • Inline keyboard key references in help text

When not to use

  • General badges or tags — use Badge component instead
  • Action buttons — use Button instead
  • Status indicators — use Badge with appropriate variant

Anti-patterns

Avoid<span className="bg-gray-100 rounded px-1 text-xs">Ctrl+K</span>
Prefer<KbdGroup><Kbd>⌃</Kbd><Kbd>K</Kbd></KbdGroup>

Use Kbd for consistent styling that adapts to theme and context (e.g., inside tooltips).

Accessibility

  • Screen readerKbd renders as a semantic <kbd> element. Screen readers announce keyboard keys. Use readable key names for non-visual users.

Token bindings

TokenCategoryUsage
mutedcolorBackground color
muted-foregroundcolorText color
rounded-smradiusBorder radius

Import

import { Kbd, KbdGroup } from "@timelycare/helix-ui"

Props

interface KbdProps extends React.HTMLAttributes<HTMLElement> {
  className?: string
  children: React.ReactNode
}

interface KbdGroupProps extends React.HTMLAttributes<HTMLDivElement> {
  className?: string
  children: React.ReactNode
}

Styling

PropertyValueTailwind
FontAdelle Sans Mediumfont-medium
Font size12pxtext-xs
Padding2px 6pxpx-1.5 py-0.5
Border radius6pxrounded-sm
Backgroundbg-mutedMuted surface color
Border1px solidborder border-border
Text colortext-muted-foregroundSubdued text
ShadowSubtle insetshadow-xs
Min width20pxmin-w-5
Text alignCentertext-center

Variants

Kbd is a single-variant component. Visual consistency across all usages.


Common Patterns

Single Key

<Kbd>⌘</Kbd>

Key Combination

<KbdGroup>
  <Kbd>⌘</Kbd>
  <Kbd>K</Kbd>
</KbdGroup>

Modifier Keys

<KbdGroup>
  <Kbd>⌘</Kbd>
  <Kbd>⇧</Kbd>
  <Kbd>⌥</Kbd>
  <Kbd>⌃</Kbd>
</KbdGroup>

With Text Separator

<KbdGroup>
  <Kbd>Ctrl</Kbd>
  <span>+</span>
  <Kbd>B</Kbd>
</KbdGroup>

In Tooltips

<TooltipContent>
  Save <Kbd>⌘S</Kbd>
</TooltipContent>

In Command Palette

<CommandShortcut>
  <KbdGroup>
    <Kbd>⌘</Kbd>
    <Kbd>K</Kbd>
  </KbdGroup>
</CommandShortcut>

Accessibility

  • Uses semantic <kbd> HTML element for keyboard input
  • Screen readers announce content as keyboard input
  • No interactive behavior; purely presentational
  • Ensure sufficient color contrast between text-muted-foreground and bg-muted

Gotchas

ProblemSolution
Keys run together without spacingUse KbdGroup to add consistent gaps between keys
Symbol keys too smallSingle-character keys use min-w-5 for consistent sizing
Kbd inside dark backgrounds hard to readbg-muted and border-border adapt to dark mode automatically
Platform-specific symbolsUse for Mac Command, Ctrl for Windows/Linux; consider detecting OS

See Also

  • Related Components: Tooltip (keyboard hints), Command (shortcut display)

Last updated: February 19, 2026