Skip to content
Hazine

Kbd

Key cap for a single key or a combination, built from nested kbd elements. Modifier glyphs such as the command sign carry a spoken name and every cap keeps a 24px box.

How it differs. The primitive key cap that other shortcut displays compose: one kbd per key, nested in an outer kbd for a combination, with named modifiers mapped to glyphs.

Install

pnpm dlx shadcn@latest add @hazine/kbd

Adds 1 file.

First time? Add the registry to components.json
{
  "registries": {
    "@hazine": "https://api.hazine.dev/r/{name}.json"
  }
}

Needed once per project. Items resolve each other through the @hazine namespace.

Props1

keys
string[]
Key names for a combination, for example ["command", "K"]. Renders one nested kbd per key. The names command, shift, option and control become glyphs.

Also accepts every prop of React.ComponentProps<"kbd">.

Accessibility

Pattern
Landmarks and headings
Keyboard
Nothing to operate. The item has no focusable parts.
Screen reader

Native kbd elements. A glyph key is wrapped in abbr with the key name as its title, so the name is read in place of the symbol.

Reduced motion
No motion.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies0

None. The item is one self-contained file.

Tokens shipped0

None. The item is styled by the tokens your theme already has.

More in Data Display