This page as markdown: /kbd.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Kbd

Status: stable

A keyboard key indicator. Renders a raised key cap sized from the surrounding text, so one Kbd fits body copy, menus and tooltips; KbdGroup sets one cap per key for a combo. mod renders the platform modifier (⌘ or Ctrl); variant="ghost" is the bare label for menu rows and tooltips.

Keywords: keyboard, shortcut, key, kbd

Usage

Use Kbd to display keyboard keys or shortcuts in help text, menus, and docs.

Best practices

Props

Name Type Default Description
mod boolean false Render the platform's shortcut modifier in place of children: ⌘ on macOS and iOS, Ctrl everywhere else. Server-rendered as Ctrl and corrected on hydration.
variant "key" | "ghost" "key" key: a raised cap on the surface it sits on, with a heavier bottom edge as the key's lip. ghost: the bare label, for menu rows, tooltips and other surfaces that are already a frame.
className string — Merge additional classes onto the key cap.
...props ComponentPropsWithRef<"kbd"> — All native attributes (children, ref, etc.).

Tokens used

border, border-strong, background, muted-foreground

Accessibility

Related

Examples

Single keys

import { Kbd } from "@sableui/react"

<Kbd>Esc</Kbd>

Combo

import { Kbd, KbdGroup } from "@sableui/react"

<KbdGroup><Kbd mod /><Kbd>K</Kbd></KbdGroup>

In a menu row

import { Kbd, MenuItem } from "@sableui/react"

<MenuItem>Search<KbdGroup className="ms-auto"><Kbd variant="ghost" mod /><Kbd variant="ghost">K</Kbd></KbdGroup></MenuItem>