ProComponents, templates & AI tooling
HeroUI
27.7k

Kbd

Display keyboard shortcuts and key combinations

Usage

import { Kbd } from "@heroui/react";

Anatomy

import { Kbd } from "@heroui/react";

export default () => (
  <Kbd>
    <Kbd.Abbr title="Command">⌘</Kbd.Abbr>
    <Kbd.Content>K</Kbd.Content>
  </Kbd>
);

Examples

Variants

Inline Usage

Instructional Text

Special Keys

Customization

Tailwind CSS

Global CSS

To customize the Kbd component classes, you can use the @layer components directive. Learn more.

@layer components {
  .kbd {
    @apply bg-gray-100 dark:bg-gray-800 border-gray-300;
  }

  .kbd__abbr {
    @apply font-bold;
  }

  .kbd__content {
    @apply text-sm;
  }
}

Styling Reference

HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.

CSS Classes

The Kbd component uses these CSS classes (View source styles):

Base Classes

  • .kbd - Base keyboard key styles with background, border, and spacing
  • .kbd__abbr - Abbreviation element for modifier keys
  • .kbd__content - Content wrapper for key text

API Reference

Kbd

PropTypeDefaultDescription
childrenReact.ReactNode-Content of the key
variant`"default""light"`default
classNamestring-Custom CSS classes

Kbd.Abbr

PropTypeDefaultDescription
titlestring-Title attribute for accessibility (e.g., "Command" for ⌘)
childrenReact.ReactNode-The symbol or text to display (e.g., ⌘, ⌥, ⇧)
classNamestring-Custom CSS classes

Kbd.Key

PropTypeDefaultDescription
childrenReact.ReactNode-Text content of the key
classNamestring-Custom CSS classes

Kbd.Content Type

Available key values for the keyValue prop:

Modifier KeysSpecial KeysNavigation KeysFunction Keys
commandenterupfn
shiftdeletedown
ctrlescapeleft
optiontabright
altspacepageup
wincapslockpagedown
helphome
end

On this page