Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Composition & Layout

Kbd

Keyboard keys and shortcuts — shadcn-style grouping, button hints, tooltips, and input addons. Build a clear hierarchy with reusable structure, consistent spacing and semantic surfaces. Keep layout decisions close to the content they organize. Import it from @/components/kamod-ui/kbd.

Source · Design reference · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import Kbd and optionally KbdGroup from @/components/kamod-ui/kbd.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Usage

Use Kbd for single keys. Wrap related keys in KbdGroup with gap-1. Use size="sm" for denser UI. On buttons, set data-icon="inline-end" on Kbd for slight nudge (matches Button inline-end icon pattern).

Import SetupTypeScript
import { Kbd } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Component Examples & Variants

Explore Kbd in Different Contexts, from the starting pattern to the compositions below. Begin with Demo, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Demo

Describe a Key Combination Accurately. Use Kbd for individual keys and KbdGroup when several keys form one command, such as Ctrl + B. The visual convention distinguishes a keyboard instruction from ordinary prose without making it an interactive button.

Match the displayed modifiers and ordering to the behavior your application implements, and provide an ordinary control for the same action so the shortcut remains an enhancement rather than the only way forward.

src/components/KbdExample.tsx17 lines
import { Kbd, KbdGroup } from "@kamod-ch/ui";

export const Example = () => (
  <div class="flex flex-col items-center gap-4">
    <KbdGroup>
      <Kbd>⌘</Kbd>
      <Kbd>⇧</Kbd>
      <Kbd>⌥</Kbd>
      <Kbd>⌃</Kbd>
    </KbdGroup>
    <KbdGroup>
      <Kbd>Ctrl</Kbd>
      <span>+</span>
      <Kbd>B</Kbd>
    </KbdGroup>
  </div>
);

Usage

Use a Keycap When You Mean a Keyboard Key. Wrap the name of one key in Kbd to give it a compact, recognizable keyboard treatment. Use the actual key label readers should press, keeping the surrounding text responsible for explaining when that input is relevant.

Keep the instruction explicit about whether users should press, hold or combine it with another key.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Group

Make a Sequence Readable as One Instruction. Place related Kbd elements inside KbdGroup when documenting a combination within a sentence. The group keeps the keys visually connected while the prose explains the command and any required modifier.

Distinguish simultaneous combinations from sequential steps, and keep platform-specific differences accurate rather than showing one modifier convention to every user.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Button

Keep the Action Label Primary. Place a shortcut hint inside a Button and use data-icon="inline-end" to align it with trailing content. The button's label still describes the action, while the key hint offers another way to invoke it.

Ensure the hinted combination performs the same operation, and do not let the extra keycaps crowd out the label at compact widths.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Tooltip

Reveal a Shortcut Where It Is Useful. Add Kbd inside TooltipContent when a control has a useful keyboard equivalent. The tooltip can pair the action name with the key combination, keeping the visible toolbar compact without hiding its purpose.

Keep the trigger's accessible name independent of the tooltip, and only advertise combinations that work in the current application context.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Input Group

Show How to Reach the Field Quickly. Use a keyboard hint in an inline-end InputGroupAddon to advertise a shortcut that focuses or opens search. Keep it secondary to the field's label and ensure the documented shortcut is actually handled by the application.

Register the handler separately, prevent conflicts thoughtfully, and avoid activating it while users are typing in another editable field unless that is intentional.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Sizes

Match the Keycap to Its Surrounding Text. Compare the sm and md keyboard treatments against the surrounding text or control height. Matching their scale keeps the hint legible without allowing a secondary shortcut to dominate the action it describes.

Preserve consistent baseline alignment and enough contrast; a secondary appearance should not make the actual key name difficult to distinguish.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Kbd using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props, slots and variants for this component.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/kbd1.5 KB min · 0.6 KB gzipSignals: none

Kbd

KbdProps

Kbd documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildKbdProps

Configure children for Kbd. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>KbdProps

Configure class for Kbd. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
size
"sm" | "md"KbdProps

Configure size for Kbd. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"md"

KbdGroup

KbdGroupProps

KbdGroup documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildKbdGroupProps

Configure children for KbdGroup. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>KbdGroupProps

Configure class for KbdGroup. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

Kbd Props

1 declared field
KbdProps
Exported Source Declaration from Kbd.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of KbdProps before adapting it.

KbdGroup Props

1 declared field
KbdGroupProps
Exported Source Declaration from KbdGroup.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of KbdGroupProps before adapting it.

Accessibility

Kbd displays keyboard notation; it does not register or execute a shortcut. Its visual key shape is instructional content, not an interactive button or proof that the documented command exists.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.