grasscnGitHub

Kbd

Passive keyboard labels using Minecraft button artwork.

Preview

Example source could not be loaded: kbd-example. Reload this page to retry.

Usage

Kbd renders a kbd element and KbdGroup a span. These passive labels have no activation or keyboard shortcut handler. Scale defaults to 2; intrinsic width follows measured text and Unicode glyph loading. Register the actual shortcut in your application and describe its scope separately.

Composition

Compose one Kbd per key inside KbdGroup and label a chord if its reading order is ambiguous. The button surface is visual reuse, not button semantics, click audio or native hotkey registration.

Installation

Loading registry address

Component source

This is the component implementation. Its supporting styles, helpers and resources are also required. See complete manual installation.

Component implementationcomponents/ui/kbd.tsx · tsx
"use client";

import * as React from "react";

import { minecraftGlyphs } from "./minecraft-font";
import {
  isMinecraftTextContent,
  minecraftClasses as cn,
  minecraftStyle,
} from "./minecraft-render";
import { MinecraftUnicodeLabel } from "./minecraft-unicode-label";

Interactive playground

JUMPSpace
SHORTCUTCtrlC
UNAVAILABLEUnbound
Keyboard labels display shortcuts