120k

Kbd

Used to display textual user input from keyboard.

Installation

pnpm dlx shadcn@latest add @force-ui-svelte/kbd

Usage

<script lang="ts">
  import * as Kbd from "$lib/components/ui/kbd/index.js";
</script>
<Kbd.Root>B</Kbd.Root>

Composition

Use the following composition to build Kbd.Root and Kbd.Group:

Kbd.Root
Kbd.Group
├── Kbd.Root
└── Kbd.Root

Examples

Group

Use the Kbd.Group component to group keyboard keys together.

Button

Use the Kbd.Root component inside a Button component to display a keyboard key inside a button.

Tooltip

You can use the Kbd.Root component inside a Tooltip component to display a tooltip with a keyboard key.

Input Group

You can use the Kbd.Root component inside a InputGroup.Addon component to display a keyboard key inside an input group.

Primary

Use variant="primary" when placing a Kbd on a solid or brand-coloured surface so the key label remains legible against the background.

RTL

To enable RTL support in Force UI, see the RTL configuration guide.

API Reference

Kbd.Root

Use the Kbd.Root component to display a keyboard key.

PropTypeDefault
classstring``
variant"default" | "primary""default"
<Kbd.Root>Ctrl</Kbd.Root>

Kbd.Group

Use the Kbd.Group component to group Kbd.Root components together.

PropTypeDefault
classstring``
<Kbd.Group>
  <Kbd.Root>Ctrl</Kbd.Root>
  <Kbd.Root>B</Kbd.Root>
</Kbd.Group>