Skip to content

Kbd

A keyboard key, for shortcuts in menus, tooltips and help text.

On this page
Used for
  • Shortcut hints
  • Palette triggers
  • Menu item keys
  • Send-prompt key

Examples

Installation

npx knowns-ui@latest add kbd
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

size
"sm" | "md"
Default"md"
md for help text and menus; sm fits inside a 28px button.
tone
"default" | "inverse"
Default"default"
inverse is a translucent key in the ink of a primary (solid) button.
...props
kbd attributes
Everything a native kbd takes.

What it handles

  1. 01Renders a real kbd element for one key, so a shortcut is a row of them such as the command key and K.
  2. 02Comes in `md` for a standalone key and `sm` to fit inside a 28px button.
  3. 03Draws the key with a border and a thicker bottom edge so it reads as a key cap.
  4. 04Offers an `inverse` tone for a primary button, a translucent key in the button's own ink colour.
  5. 05Takes any kbd attribute and `className`, so a key can carry a title or a width.
  6. 06Sizes the key with a minimum width, so single characters and wider keys line up.

States

Any change
It updates at once
none
Hover or focus
Nothing moves; the key is not interactive
none
Theme change
The border and fill follow the theme tokens
none

Works with

When to use

When to use

  • Showing a key or shortcut in text or a hint.

When not to use

  • Labels for buttons: use Badge.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Kbd to my app and wire it to my own data.
  • I need showing a key or shortcut in text or a hint. Set that up with the Knowns UI Kbd.
  • Which Kbd props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "kbd" }) and search_docs({ query: "kbd" }).

Need help?

Stuck on Kbd, or found something off? We read every message.