# Kbd

Keyboard keys as small bevelled pixel keycaps, alone or grouped.

Source: https://www.ui95.dev/ui/kbd

## Examples

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

import type { ShowcaseDemo } from "../types"

export const demo: ShowcaseDemo = {
  span: "single",
  variants: [
    { label: "key", render: () => <Kbd>Esc</Kbd> },
    {
      label: "group",
      render: () => (
        <KbdGroup>
          <Kbd>Ctrl</Kbd>
          <span className="text-lg">+</span>
          <Kbd>Alt</Kbd>
          <span className="text-lg">+</span>
          <Kbd>Del</Kbd>
        </KbdGroup>
      ),
    },
    {
      label: "in text",
      render: () => (
        <p className="text-lg">
          Press <Kbd>F1</Kbd> for help
        </p>
      ),
    },
  ],
}
```

## Installation

```bash
npx shadcn@latest add https://www.ui95.dev/r/kbd.json
```

Run it in a Radix shadcn project that already has the UI95 theme.

Dependencies:

```bash
npm install cn
```

`components/ui/kbd.tsx`

```tsx
import { cn } from "cn"

function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
  return (
    <kbd
      data-slot="kbd"
      className={cn(
        "pointer-events-none inline-flex h-6 w-fit min-w-6 items-center justify-center gap-1 pixel-border border-border bg-secondary px-1 font-pixel text-sm leading-none text-secondary-foreground uppercase bevel-raised offset-shadow-none select-none in-data-[slot=tooltip-content]:bg-background in-data-[slot=tooltip-content]:text-foreground [&_svg:not([class*='size-'])]:size-3",
        className
      )}
      {...props}
    />
  )
}

function KbdGroup({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <kbd
      data-slot="kbd-group"
      className={cn("inline-flex items-center gap-1", className)}
      {...props}
    />
  )
}

export { Kbd, KbdGroup }
```

## API reference

### Kbd

No props of its own. It forwards the props of the element or primitive it wraps.

### KbdGroup

No props of its own. It forwards the props of the element or primitive it wraps.
