GooseUI

Components

Kbd


Kbd displays a keyboard key or shortcut. It uses the native kbd element for semantic markup. Combine keys in a group to show shortcuts. It works without JavaScript.

Preview

⌘K

Installation

npx shadcn@latest add @gooseui/kbd
pnpm dlx shadcn@latest add @gooseui/kbd
yarn dlx shadcn@latest add @gooseui/kbd
bunx --bun shadcn@latest add @gooseui/kbd

Usage

import { Kbd, KbdGroup } from "@/components/ui/kbd"

<KbdGroup><Kbd>⌘</Kbd><Kbd>K</Kbd></KbdGroup>

Examples

Single key

Esc
<Kbd>Esc</Kbd>

Combination

⌘K
<KbdGroup><Kbd>⌘</Kbd><Kbd>K</Kbd></KbdGroup>

Keys with icons

<Kbd><KbdEnterIcon /></Kbd>
<Kbd><KbdArrowUpIcon /></Kbd>
<Kbd><KbdArrowDownIcon /></Kbd>

Inside a button

<button>
  Search
  <KbdGroup><Kbd>⌘</Kbd><Kbd>K</Kbd></KbdGroup>
</button>

Inline in text

Press Esc to close the dialog.

<p>Press <Kbd>Esc</Kbd> to close the dialog.</p>

Props

PropTypeDefaultDescription
classNamestring-Additional CSS classes.