Skip to main content
Urbicon UI

Kbd

Render one or more keys as a compact keycap for shortcuts like ⌘K or Ctrl + S. Pure display, emitting a semantic <kbd> element.

Playground

+K
Size
<script lang="ts">
  import { Kbd } from '@urbicon-ui/blocks';

  const keys = ['', 'K'];
</script>

<Kbd
  {keys}
/>

01 Examples

Keycaps

Pass a string to keys for a single keycap. Symbols like ⌘, ⇧ and ⌥ render as-is, and spelled-out names cover the keys that have no glyph.
⌘K Esc Enter Tab
<Kbd keys="⌘K" />
<Kbd keys="Esc" />
<Kbd keys="Enter" />
<Kbd keys="Tab" />

Multi-key combos

An array shows several keys in one keycap, joined by the separator (default +). Reach for it when a shortcut uses more than one key.
Ctrl+K ++P
<Kbd keys={['Ctrl', 'K']} />
<Kbd keys={['', '', 'P']} />

Inline in a sentence

Kbd is inline and vertically centered on the text, so it reads naturally inside running copy or a tooltip.

Press / to search, or +K for the command palette.

<p>Press <Kbd keys="/" size="sm" /> to search, or <Kbd keys={['', 'K']} size="sm" /> for the command palette.</p>

02 Accessibility

Semantic element

Renders a semantic <kbd> element, the native HTML tag for keyboard input. It is presentational, so no explicit role is added.

Announced as shown

Every key is visible text, so screen readers read the shortcut exactly as it is shown.

A hint, not a control

Kbd never receives focus and has no interactive behaviour of its own. Wire the actual shortcut on the element it describes.

03 API Reference

10 props
10 props
Prop
Type
Default
Description

04 Types

Local type definitions used by this component.

3 types
Name
Kind
Category
Used by
Description

05 Installation

Import

import { Kbd } from '@urbicon-ui/blocks';