Kbd

Keyboard shortcut token for command hints and menus.

VerifiedSince 1.0.0

Kbd

Basic Usage

Kbd

Loading demo...

Interaction Contract

  • The root element is <kbd>, so it carries native keyboard-token semantics.
  • size="sm" is the compact default for inline help and menu shortcuts.
  • tone="primary" highlights product shortcuts without changing the slot content.
  • The component has no events and no internal state.

API

Props

PropTypeDefaultDescription
size'sm' | 'md''sm'Token size: sm (default) for inline help and menu shortcuts; md is larger for shortcuts shown on their own.
tone'default' | 'primary''default'Visual tone: use primary only for the main shortcut on a page or command, at most one group per screen.

Events

TxKbd does not emit component events.

Slots

SlotPropsDescription
default-Key label, such as , Ctrl, or K.

Best Practices

  • Render key combinations as separate TxKbd tokens rather than one long string when spacing matters.
  • Keep labels platform-aware in host copy: for macOS, Ctrl for Windows/Linux.
  • Use tone="primary" sparingly for the main shortcut on a page or command.
  • Pair shortcut tokens with visible action text; shortcuts alone are not discoverable enough.

Review Notes

  • Source: packages/tuffex/packages/components/src/kbd/src/TxKbd.vue confirms the semantic <kbd> root, size / tone classes, and default slot-only content.
  • Verified coverage: Coverage: packages/tuffex/packages/components/src/kbd/__tests__/kbd.test.ts covers rendered shortcut content, root tag, and variant classes.
  • Export: packages/tuffex/packages/components/src/kbd/index.ts wraps the component with withInstall and exports TxKbdInstance.

Source

查看源码
packages/tuffex/packages/components/src/kbd/index.ts