# Kbd

Use `ui-kbd` to present keyboard keys inside help copy, shortcut lists, command hints, and documentation. It is not an interactive control by itself. Its job is to make keyboard tokens readable, scannable, and visually consistent.

## Import
```ts
import { KbdComponent } from 'ui';
```

## Basic keys
```ts
import { Component } from '@angular/core';
import { KbdComponent } from 'ui';

@Component({
  selector: 'app-kbd-basic-demo',
  standalone: true,
  imports: [KbdComponent],
  template: `
    <div style="display:flex;flex-wrap:wrap;gap:0.75rem;align-items:center">
      <ui-kbd text="Enter" />
      <ui-kbd text="Esc" />
      <ui-kbd text="Tab" />
      <ui-kbd text="Shift" />
      <ui-kbd text="Space" />
    </div>
  `,
})
export class KbdBasicDemoComponent {}
```

## Size and appearance
```ts
import { Component } from '@angular/core';
import { KbdComponent } from 'ui';

@Component({
  selector: 'app-kbd-size-appearance-demo',
  standalone: true,
  imports: [KbdComponent],
  template: `
    <div
      style="display:grid;grid-template-columns:repeat(auto-fit,minmax(15rem,1fr));gap:1rem;align-items:start"
    >
      <div
        style="display:flex;flex-direction:column;gap:0.75rem;padding:1rem;border:1px solid var(--color-neutral-stroke-rest);border-radius:1rem;background:var(--color-neutral-background-rest)"
      >
        <div style="font-size:0.875rem;font-weight:600">Default appearance</div>
        <div style="display:flex;flex-wrap:wrap;gap:0.75rem;align-items:center">
          <ui-kbd text="Ctrl" size="small" appearance="default" />
          <ui-kbd text="Ctrl" size="medium" appearance="default" />
          <ui-kbd text="Ctrl" size="large" appearance="default" />
        </div>
      </div>

      <div
        style="display:flex;flex-direction:column;gap:0.75rem;padding:1rem;border:1px solid var(--color-neutral-stroke-rest);border-radius:1rem;background:var(--color-neutral-background-rest)"
      >
        <div style="font-size:0.875rem;font-weight:600">Filled appearance</div>
        <div style="display:flex;flex-wrap:wrap;gap:0.75rem;align-items:center">
          <ui-kbd text="Ctrl" size="small" appearance="filled" />
          <ui-kbd text="Ctrl" size="medium" appearance="filled" />
          <ui-kbd text="Ctrl" size="large" appearance="filled" />
        </div>
      </div>
    </div>
  `,
})
export class KbdSizeAppearanceDemoComponent {}
```

## Common shortcut rows
```ts
import { Component } from '@angular/core';
import { KbdComponent } from 'ui';

@Component({
  selector: 'app-kbd-common-shortcuts-demo',
  standalone: true,
  imports: [KbdComponent],
  template: `
    <div style="display:flex;flex-direction:column;gap:0.75rem;max-width:28rem">
      @for (shortcut of shortcuts; track shortcut.label) {
        <div
          style="display:flex;justify-content:space-between;gap:1rem;align-items:center;padding:0.75rem 0.875rem;border:1px solid var(--color-neutral-stroke-rest);border-radius:0.875rem;background:var(--color-neutral-background-rest)"
        >
          <span style="font-size:0.875rem">{{ shortcut.label }}</span>
          <div style="display:flex;gap:0.375rem;align-items:center;flex-wrap:wrap">
            @for (key of shortcut.keys; track key) {
              <ui-kbd [text]="key" appearance="filled" />
            }
          </div>
        </div>
      }
    </div>
  `,
})
export class KbdCommonShortcutsDemoComponent {
  protected readonly shortcuts = [
    { label: 'Copy selection', keys: ['Ctrl', 'C'] },
    { label: 'Paste clipboard', keys: ['Ctrl', 'V'] },
    { label: 'Undo last action', keys: ['Ctrl', 'Z'] },
    { label: 'Search in page', keys: ['Ctrl', 'F'] },
  ];
}
```

## Navigation keys
```ts
import { Component } from '@angular/core';
import { KbdComponent } from 'ui';

@Component({
  selector: 'app-kbd-navigation-demo',
  standalone: true,
  imports: [KbdComponent],
  template: `
    <div
      style="display:grid;grid-template-columns:repeat(auto-fit,minmax(17rem,1fr));gap:1rem;align-items:start"
    >
      <div
        style="display:flex;flex-direction:column;gap:0.75rem;padding:1rem;border:1px solid var(--color-neutral-stroke-rest);border-radius:1rem;background:var(--color-neutral-background-rest)"
      >
        <div style="font-size:0.875rem;font-weight:600">Navigation cluster</div>
        <div style="display:flex;gap:0.5rem;flex-wrap:wrap">
          <ui-kbd text="↑" />
          <ui-kbd text="↓" />
          <ui-kbd text="←" />
          <ui-kbd text="→" />
          <ui-kbd text="Home" />
          <ui-kbd text="End" />
        </div>
      </div>

      <div
        style="display:flex;flex-direction:column;gap:0.75rem;padding:1rem;border:1px solid var(--color-neutral-stroke-rest);border-radius:1rem;background:var(--color-neutral-background-rest)"
      >
        <div style="font-size:0.875rem;font-weight:600">Paged movement</div>
        <div style="display:flex;gap:0.5rem;flex-wrap:wrap">
          <ui-kbd text="Page Up" appearance="filled" />
          <ui-kbd text="Page Down" appearance="filled" />
          <ui-kbd text="Shift" />
          <ui-kbd text="Tab" />
        </div>
      </div>
    </div>
  `,
})
export class KbdNavigationDemoComponent {}
```

## Command help composition
```ts
import { Component } from '@angular/core';
import { KbdComponent, MessageBarComponent, TagComponent } from 'ui';

@Component({
  selector: 'app-kbd-command-help-demo',
  standalone: true,
  imports: [KbdComponent, MessageBarComponent, TagComponent],
  template: `
    <div
      style="display:grid;grid-template-columns:repeat(auto-fit,minmax(18rem,1fr));gap:1rem;align-items:start;max-width:48rem"
    >
      <div
        style="display:flex;flex-direction:column;gap:1rem;padding:1rem;border:1px solid var(--color-neutral-stroke-rest);border-radius:1rem;background:var(--color-neutral-background-rest)"
      >
        <div style="display:flex;flex-direction:column;gap:0.25rem">
          <div style="font-size:0.9375rem;font-weight:600">Editor shortcuts</div>
          <div style="font-size:0.8125rem;color:var(--color-neutral-foreground2-rest)">
            The kbd component is most useful when it appears inside real shortcut help, command
            hints, or training surfaces.
          </div>
        </div>

        <ui-message-bar
          title="Quick tip"
          message="Use keyboard hints only for actions that are actually supported by the current surface."
          variant="info"
          appearance="subtle"
          [dismissible]="false"
        />

        <div style="display:flex;flex-direction:column;gap:0.75rem">
          @for (item of shortcuts; track item.label) {
            <div style="display:flex;justify-content:space-between;gap:1rem;align-items:center">
              <span style="font-size:0.875rem">{{ item.label }}</span>
              <div style="display:flex;gap:0.375rem;align-items:center;flex-wrap:wrap">
                @for (key of item.keys; track key) {
                  <ui-kbd [text]="key" appearance="filled" />
                }
              </div>
            </div>
          }
        </div>
      </div>

      <div
        style="display:flex;flex-direction:column;gap:0.875rem;padding:1rem;border:1px solid var(--color-neutral-stroke-rest);border-radius:1rem;background:var(--color-neutral-background-rest)"
      >
        <div style="display:flex;flex-wrap:wrap;gap:0.5rem">
          <ui-tag text="Documentation" appearance="filled" variant="secondary" />
          <ui-tag text="Shortcut hints" appearance="subtle" variant="info" />
          <ui-tag text="Ready to copy" appearance="subtle" variant="success" />
        </div>

        <div
          style="display:flex;flex-wrap:wrap;gap:0.75rem;align-items:center;padding:0.75rem 0.875rem;border:1px dashed var(--color-neutral-stroke-rest);border-radius:0.875rem;background:var(--color-neutral-background-rest)"
        >
          <span style="font-size:0.8125rem;color:var(--color-neutral-foreground2-rest)">
            Open command palette with
          </span>
          <ui-kbd text="Ctrl" appearance="filled" />
          <ui-kbd text="K" appearance="filled" />
        </div>
      </div>
    </div>
  `,
})
export class KbdCommandHelpDemoComponent {
  protected readonly shortcuts = [
    { label: 'Save draft', keys: ['Ctrl', 'S'] },
    { label: 'Open search', keys: ['Ctrl', 'F'] },
    { label: 'Duplicate line', keys: ['Shift', 'Alt', '↓'] },
  ];
}
```

## Accessibility

### Semantics
`ui-kbd` renders a native `kbd` element with an `aria-label` that expands to a readable key description.

| Element | Behavior |
| --- | --- |
| root | native `kbd` semantics |
| aria label | localized `Keyboard key: {text}` pattern |
| interactive behavior | none, it is purely presentational content |

### Usage guidance
Because the component is not interactive, use it only as supporting content next to the action or instruction it describes. Shortcut hints should reflect real product behavior instead of speculative or decorative keyboard tokens.
