# Keyboard key

Readable key labels and accessible shortcut chords for menus, search and help.

Access: free. Category: Essentials. Kind: primitive.

## When to use

- Use it when a product interface needs readable key labels and accessible shortcut chords for menus, search and help.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose tidal-button instead when press, loading, success and disabled states is the actual interface need, rather than keyboard key.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Keyboard key

```sh
npx shadcn@latest add https://tidalui.com/r/keyboard-key.json
```

Stylesheets: `components/ui/tidal.css`, `components/ui/keyboard-key.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/keyboard-key.css";
import{TidalKeyboardKey}from"./components/ui/keyboard-key";
export default()=><div className="tidal-scope"><TidalKeyboardKey children={"value"}/></div>;
```

## Structured props

- `TidalKeyboardKey.children: string | number`: Required children value accepted by this exported component.
- `TidalKeyboardKey.size?: "sm" | "md" | undefined` (default "md"): Optional size value accepted by this exported component.
- `TidalKeyboardShortcut.keys: ReadonlyArray<TidalShortcutKey>`: Required keys value accepted by this exported component.
- `TidalKeyboardShortcut.separator?: string | number | undefined` (default "+"): Optional separator value accepted by this exported component.
- `TidalKeyboardShortcut.size?: "sm" | "md" | undefined` (default "md"): Optional size value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/keyboard-key.tsx) | [Manifest](https://tidalui.com/examples/keyboard-key.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { TidalKeyboardShortcut } from "./components/ui/keyboard-key";

import "./components/ui/keyboard-key.css";



const tidalExampleStyles = ".tidal-scope .keyboard-key-demo {\n  width: 100%;\n  max-width: 380px;\n  min-width: 0;\n}\n.tidal-scope .keyboard-key-demo dl {\n  margin: 0;\n}\n.tidal-scope .keyboard-key-demo dl > div {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 16px;\n  padding: 15px 0;\n  border-bottom: 1px solid var(--t-border);\n}\n.tidal-scope .keyboard-key-demo dt {\n  color: var(--t-ink);\n  font-size: 13px;\n  min-width: 0;\n  overflow-wrap: anywhere;\n}\n.tidal-scope .keyboard-key-demo dd {\n  margin: 0;\n  max-width: 65%;\n}\n.tidal-scope .keyboard-key-demo p {\n  margin: 16px 0 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n}";

const shortcuts = [
  {
    label: "Search",
    keys: [
      { id: "cmd", label: "⌘", accessibleLabel: "Command" },
      { id: "k", label: "K", accessibleLabel: "K" },
    ],
  },
  {
    label: "Switch project",
    keys: [
      { id: "cmd", label: "⌘", accessibleLabel: "Command" },
      { id: "shift", label: "⇧", accessibleLabel: "Shift" },
      { id: "p", label: "P", accessibleLabel: "P" },
    ],
  },
  {
    label: "Open help",
    keys: [
      { id: "shift", label: "⇧", accessibleLabel: "Shift" },
      { id: "slash", label: "/", accessibleLabel: "Slash" },
    ],
  },
];

export function KeyboardKeyDemo() {
  return (
    <div className="keyboard-key-demo" aria-label="Example shortcut labels">
      <dl>
        {shortcuts.map((shortcut) => (
          <div key={shortcut.label}>
            <dt>{shortcut.label}</dt>
            <dd>
              <TidalKeyboardShortcut keys={shortcut.keys} />
            </dd>
          </div>
        ))}
      </dl>
      <p>
        Display labels only. These shortcuts are not active in this preview.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <KeyboardKeyDemo />
    </div>
  );
}

```

## Gotchas

- Install the declared registry dependencies and render inside a tidal-scope with the foundation stylesheet loaded.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

TidalKeyboardKey forwards native kbd data/title/style/class attributes/ref; content is string or number with sm/md sizes; role, tabIndex and contentEditable are owned. TidalKeyboardShortcut forwards native span attributes/ref, accepts stable unique-id key entries with visual label and required accessibleLabel, optional textual separator and size. The chord is exposed as one image-like labelled object; visual key labels and separators are hidden from assistive technology to avoid repeated glyph readings. Override aria-label for a localized full phrase. Keys wrap within narrow containers and remain noninteractive. Consumers own keyboard handling, shortcut availability, platform mapping and localization; this component never registers shortcuts.
