Talisman LogoTalisman Logo Design System
Browse documentation
Components

Kbd

Shows a keyboard key or a shortcut as a small key cap, for help text, tooltips and command menus.

Stableimport { Kbd } from "@repo/ui/kbd";Source
Esc
size
variant
<Kbd size="md" variant="default">Esc</Kbd>

When to use

  • To teach a shortcut next to the action it triggers: “Buscar processo” with Ctrl K.
  • Inside tooltips, menu items and the footer of a command menu.
  • In help text that tells the operator which key to press.

When not to use

  • Buttons the user clicks. Use Button. A key cap looks pressable but does nothing.
  • Status or category labels. Use Tag or Badge.
  • Code or identifiers. Use Typography with the inlineCode variant.

Variants

defaultoutline
Variant Use for
default Filled key cap. The usual choice on plain backgrounds.
outline Border only. Use it on filled or colored surfaces.

Sizes

md · 28pxsm · 24pxxs · 20px
Size Height Use for
md 28px Default. Help text and empty states.
sm 24px Tooltips and menu items.
xs 20px Dense toolbars and table footers.

Examples

Shortcut combinations

Put each key in its own Kbd. Use an icon with an aria-label for keys that have a symbol.

CtrlKBuscar processo pelo número
Navegar entre as tarefas
Abrir a tarefa selecionada

Content

  • Write key names as they appear on the keyboard: Esc, Enter, Ctrl, Tab.
  • One Kbd per key. Never put “Ctrl + K” in a single key cap.
  • Describe the action in words next to the keys. The key cap alone does not say what happens.

Accessibility

  • Renders the native kbd element, which marks the text as keyboard input for assistive technology.
  • It is not focusable and has no role. Do not use it as a control.
  • An icon inside Kbd is not read. Add aria-label to the Kbd (“Seta para cima”) and aria-hidden to the icon.
  • Keep the text description of the action beside the shortcut. Not everyone sees or uses the key.

Code

import { Kbd } from "@repo/ui/kbd";

<span className="flex items-center gap-1">
  <Kbd>Ctrl</Kbd>
  <Kbd>K</Kbd>
</span>;

Props

Kbd
PropTypeDefaultDescription
size"md" | "sm" | "xs"mdHeight, padding and type size
variant"default" | "outline"defaultFilled key cap or border only

Kbd also accepts every attribute of the native kbd element.

Known issues

Issue Effect
xs uses text-[0.6875rem] (11px) and sm uses text-[0.75rem] with a line height of 12px. Small text for operators who work 8 hours a day. Prefer md for help text.
Edit this page on GitHub