Skip to content
Brok UI

Loading…

No results

Kbd

Open source

Displays a keyboard key or key combination.

Version
v1.0.4
Stability
stable
License
MIT
Related
Badge
Tooltip
Button

Preview

Press ⌘ K to open the command menu.

previews.components.kbd.default.blade.php Blade
<p class="text-sm text-muted-foreground">
    {{ __('Press') }}
    <x-ui.kbd.group>
        <x-ui.kbd>⌘</x-ui.kbd>
        <x-ui.kbd>K</x-ui.kbd>
    </x-ui.kbd.group>
    {{ __('to open the command menu.') }}
</p>

Installation

terminal
php artisan ui:add kbd

Registry contract

php artisan ui:add kbd writes only the files below. The CLI validates each file hash before writing and asks before it replaces a local change, unless you pass --force.

  • blade resources/views/components/ui/kbd.blade.php
  • blade resources/views/components/ui/kbd/group.blade.php
Registry dependencies
None — installs on its own.
Packages
composer: jml/brok:^0.2

Use with AI

A brief for your coding agent: install command, usage, props, guidance and the rules. Copy it, or open a prompt about this component in an assistant.

kbd.md
# Brok UI: Kbd (`kbd`)

Displays a keyboard key or key combination.

Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.

## Install

```bash
php artisan ui:add kbd
```

## Usage

```blade
<p class="text-sm text-muted-foreground">
    {{ __('Press') }}
    <x-ui.kbd.group>
        <x-ui.kbd>⌘</x-ui.kbd>
        <x-ui.kbd>K</x-ui.kbd>
    </x-ui.kbd.group>
    {{ __('to open the command menu.') }}
</p>
```

## Use when

- Use to summarize, sequence, or present data so users can scan it quickly.
- Representing a keyboard key or a shortcut combination inline in text, such as documentation or a tooltip.

## Avoid when

- Do not add display-only ornament when the user needs actionable structure or exact comparison instead.
- Labeling a clickable control; use button instead, since kbd carries no interactive semantics.

## Anti-patterns

- Adding display ornament without informational value

## Rules

- Use the `<brok:kbd>` tag (or `<x-ui.kbd>`) in Blade; do not rewrite the component.
- Prefer the documented props and variants over utility-class overrides; when a utility must win, use the `!` important modifier.
- Use semantic design tokens (`bg-primary`, `text-muted-foreground`), never raw colour utilities.
- Keep the `data-slot` attributes; they are the styling and test hooks.

## Links

- Docs: https://brokui.dev/docs/components/kbd
- Registry JSON (files, props, contract): https://brokui.dev/r/open/kbd.json

Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.

API

manifest knowledge + registry-derived coverage

Props

No documented props. Pass normal Blade attributes through the component root.

Slots

  • default —
  • x-ui.kbd.group — Installed subcomponent from the registry item.

Data slots

Stable hooks for CSS overrides and browser tests.

kbd kbd-group

Behavior

  • Renders as a single inline kbd element styled as a small key cap; combine several inside a shortcut with a literal separator such as "+".
  • Declares registry capability flags: a11y, responsive, rtl, darkMode, localized.

Guidance

Scannable data display

Present data for rapid scanning.

Use when

  • Use to summarize, sequence, or present data so users can scan it quickly.
  • Representing a keyboard key or a shortcut combination inline in text, such as documentation or a tooltip.

Avoid when

  • Do not add display-only ornament when the user needs actionable structure or exact comparison instead.
  • Labeling a clickable control; use button instead, since kbd carries no interactive semantics.

Use instead

  • Table for exact comparison
  • Plain text for a single value

Anti-patterns

  • Adding display ornament without informational value
Anatomy
root kbd-group
Theming hooks
kbd kbd-group

Accessibility

WCAG 2.2 AA Keyboard focus-visible RTL-ready Localized labels Dark mode
Keyboard
No component-owned keyboard interaction; native element behavior applies.
Focus
none
  • The native kbd element is read as normal text by screen readers, so keep the slot content literal, such as "Ctrl" or "Esc".
  • Semantic HTML and a stable data-slot attribute for styling and scripting hooks.
  • Focus-visible rings use the ring token, so keyboard focus is always visible.
  • Disabled and invalid states are conveyed to assistive tech, not by color alone.
  • Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces in the preview.
  • Labels go through __() and layout uses logical properties (ms-*, text-start), so it mirrors under dir="rtl" — flip the preview to RTL to confirm.
  • Dark mode uses the same semantic tokens under the dark class; high contrast follows forced-color system tokens.

Livewire

Safe

Livewire can update this component through forwarded wire:* attributes.

Source

The exact, editable files ui:add writes into your app. Previews render this same code; there are no preview-only components.

resources/views/components/ui/kbd.blade.php Blade
<kbd data-slot="kbd" {{ $attributes->merge(['class' => 'inline-flex h-5 min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-2 font-body text-xs font-medium text-muted-foreground select-none']) }}>{{ $slot }}</kbd>
resources/views/components/ui/kbd/group.blade.php Blade
<kbd data-slot="kbd-group" {{ $attributes->merge(['class' => 'inline-flex items-center gap-1']) }}>{{ $slot }}</kbd>

Ownership & lifecycle

Owner, release state, review evidence and adoption for this item.
Owner
Platform UI (@JoshJML)
Current version
1.0.4
Status
Stable
License
open
Accessibility reviewed
No review date recorded
Last breaking change
No date recorded
Deprecation
Not deprecated
Contract
v6
Foundation
≥ 1.0.0