Skip to content

Kbd for Angular

AngularData display

Keyboard shortcut shown as keycaps, from the same hotkey syntax as matchesHotkey (‘Mod+Shift+K’). Mod is Command on Apple platforms and Ctrl elsewhere; Apple modifiers show as symbols with their names for assistive technology.

  • Platform awareMod becomes Command on Apple devices and Ctrl elsewhere.
  • Hotkey stringsPass a combination like Mod+Shift+K and get separate keycaps.
  • Readable namesSymbol keys carry a visually hidden name for screen readers.
  • Inline or standaloneSits inside text or on its own in two sizes.

Behavior, design tokens, and limitations are described on the Kbd page; this page covers the Angular API.

import { Component } from '@angular/core';
import { AuiKbd } from '@absoluteui/angular/kbd';
@Component({
selector: 'app-save-hint',
imports: [AuiKbd],
template: `<p>Save with <aui-kbd hotkey="Mod+S"></aui-kbd></p>`,
})
export class SaveHintComponent {}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiKbd } from '@absoluteui/angular/kbd';

Defaults for every instance: provideAbsoluteUIConfig({ components: { kbd: { ... } } }) (see Configuration).

Class AuiKbd; template reference #ref="auiKbd".

Server rendering: Renders on the server; the browser re-creates it after hydration.

Input Type Default Description
hotkey string Required. Shortcut in matchesHotkey syntax, such as ‘Mod+Shift+K’; ‘Plus’ is the + key.
platform KbdPlatform 'auto' Apple shows Command for Mod and modifier symbols; other shows Ctrl and ‘+’ separators; auto detects.
size KbdSize 'md' Keycap size.
locale string 'en-US' Locale of key names.

Pattern: Keyboard input markup: a kbd element for the combination with one nested kbd per key (HTML kbd semantics).

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Kbd: Accessibility and performance.