Skip to Content
Documentation
Getting startedComponentsChartsTheming
Overview
Concepts

Kbd

Used to show key combinations for an action

SourceStorybookRecipe
Shift + Tab

Anatomy

import { Kbd } from '@chakra-ui/react'
<Kbd>F12</Kbd>

Examples

Combinations

Render Kbd to showcase key combinations

ctrl+shift+del

Function Keys

Here's an example of using Kbd to showcase function keys

⌘⌥⇧⌃

Variants

Use the variant prop to change the appearance of the Kbd component

Shift + TabShift + TabShift + TabShift + Tab

Sizes

Use the size prop to change the size of the Kbd component

Shift + TabShift + TabShift + Tab

Within Text

Use Kbd within text to highlight key combinations

Press F12 to open DevTools

Kbd Group

KbdGroup displays a whole shortcut. Install it with npx @saas-ui/cli add kbd-group.

import { KbdGroup } from '#components/ui/kbd-group'
<KbdGroup>shift+X</KbdGroup>
info
KbdGroup was called Command before v3. Command from @chakra-ui/react is now the command palette. See the migration guide.

Shortcut string

Pass the shortcut as a string. Each key separated by + or a space renders as a Kbd, while then and or render as plain text. Set the modifiers prop to change which words stay as text.

⌘KshiftXGthenIaltoroption

Kbd children

Pass Kbd elements as children for full control over each key. size and variant are passed to every key in the group.

ctrlshiftdel

Sizes

Use the size prop to change the size of the keys.

⌘shiftP⌘shiftP⌘shiftP⌘shiftP

In a tooltip

Inside a tooltip, the group is separated from the label with a dot.

Props

PropDefaultType
colorPalette 'gray'
'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'presence' | 'status' | 'sidebar' | 'sidebar.accent' | 'accent' | 'slate'

The color palette of the component

variant 'subtle'
'raised' | 'outline' | 'subtle' | 'plain'

The variant of the component

size 'md'
'sm' | 'md' | 'lg'

The size of the component

KbdGroup

PropTypeDefaultDescription
size'xs' | 'sm' | 'md' | 'lg''sm'The size of the text and the keys
variantKbd variant-The variant passed to each Kbd
modifiersstring[]['then', 'or', '+']Words in a shortcut string that render as text, not as keys

Previous

Highlight

Next

Link