Kbd

A component for displaying keyboard shortcuts and key combinations.

Anatomy

<script>
  import { Kbd } from "@saas-ui/svelte/components/kbd";
</script>

<Kbd>Ctrl</Kbd> + <Kbd>C</Kbd>

<!-- With modifier keys -->
<Kbd keys={["command"]}>K</Kbd>

<!-- With colour -->
<Kbd colour="indigo" keys={["command"]}>K</Kbd>

<!-- With variants and sizes -->
<Kbd variant="raised" size="lg">Enter</Kbd>

Examples

Basic Accessibility

Basic Kbd component displaying a keyboard shortcut.

Colours Accessibility

Use the colour prop to change the colour of the Kbd component. Supports all standard colour palettes.

Combinations Accessibility

Render Kbd to showcase key combinations.

Function Keys Accessibility

Example of using Kbd to showcase function keys.

Modifier Keys Accessibility

Use the keys prop to display modifier key symbols. Supports command (⌘), option (⌥), shift (⇧), control (⌃), and more.

Sizes Accessibility

Use the size prop to change the size of the Kbd component.

Variants Accessibility

Use the variant prop to change the appearance of the Kbd component.

Within Text Accessibility

Use Kbd within text to highlight key combinations.

Props

Prop Type Default Description
variant raised | outline | subtle | plain subtle The visual style of the component.
size sm | md | lg md The size of the component.
colour accent | gray | zinc | neutral | stone | slate | red | orange | amber | yellow | lime | green | emerald | teal | cyan | sky | blue | indigo | violet | purple | fuchsia | pink | rose gray The colour theme of the component.
keys object - Modifier keys to display (e.g., ['command', 'shift']). Supported: command, option, shift, control, enter, backspace, delete, escape, tab, arrow keys.
children any - The content to be rendered inside the component.
class text - Additional CSS classes to apply.