# Interfere Kbd

Displays a keyboard key or shortcut.

Build a Kbd in this project that looks and behaves like Interfere's. Measured from the running Interfere app (interfere.com). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or Base UI primitives if it has none.

Fidelity: Partly measured from the keyboard key CSS in Interfere's app frontend. No reference has been captured yet.

## Variants

- `variant`: `default`, `inverted`
- `size`: `sm`, `md`, `lg`

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--black-a3` | `#00000026` | `#00000026` |
| `--color-component` | `#0000000f` | `#ffffff12` |
| `--color-component-on-inverted` | `#ffffff1a` | `#0000001a` |
| `--color-secondary-foreground` | `#0000009b` | `#ffffffaf` |
| `--color-on-inverted-foreground` | `#fff` | `#000` |
| `--color-border-default` | `#0000000f` | `#ffffff12` |
| `--font-regular` | `"InterVariable", "Inter Variable", "InterVariable Fallback", sans-serif` | `"InterVariable", "Inter Variable", "InterVariable Fallback", sans-serif` |
| `--font-size-micro` | `11px` | `11px` |
| `--font-size-mini` | `12px` | `12px` |
| `--font-size-small` | `13px` | `13px` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-kbd` | `4px` | `4px` |

## CSS

Scoped under `[data-style="interfere"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.

```css
[data-style="interfere"] {
  .ui-kbd {
    box-sizing: border-box;
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0;
    border: 0.5px solid var(--color-border-default);
    border-radius: var(--radius-kbd);
    background-color: var(--color-component);
    color: var(--color-secondary-foreground);
    font-family: var(--font-regular);
    font-feature-settings: "ss02";
    font-size: var(--font-size-micro);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    text-transform: uppercase;
    pointer-events: none;
    user-select: none;
  }

  .ui-kbd[data-size="md"] {
    min-width: 20px;
    height: 20px;
    font-size: var(--font-size-mini);
  }

  .ui-kbd[data-size="lg"] {
    min-width: 24px;
    height: 24px;
    font-size: var(--font-size-small);
  }

  .ui-kbd[data-variant="inverted"] {
    background-color: var(--color-component-on-inverted);
    color: var(--color-on-inverted-foreground);
    opacity: 0.9;
  }

  &[data-theme="dark"] .ui-kbd[data-variant="inverted"] {
    background-color: var(--black-a3);
    opacity: 0.75;
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import type { ComponentProps } from "react";
import { join } from "./utils";

export function Kbd({ className, variant, size, ...props }: ComponentProps<"kbd"> & { variant?: string; size?: string }) {
  return <kbd className={join("ui-kbd", className)} data-variant={variant} data-size={size} {...props} />;
}
```

## Example

```tsx
import { Kbd } from "@replicas/ui";

export default function KbdDemo() {
  return (
    <>
      <Kbd>⌘</Kbd>
      <Kbd>K</Kbd>
      <Kbd>Shift</Kbd>
      <Kbd>Enter</Kbd>
    </>
  );
}
```

## Foundations

The rest of the Interfere style, as a skill: https://replicas.raphaelsalaja.com/skills/interfere/SKILL.md