Skip to content
shadcn.io is not affiliated with official shadcn/ui

Shadcn Keyboard Table for React and Tailwind

Key / Description rows with keycap shortcuts.

KeyDescription
Tab
Next focusable element.
ShiftTab
Previous focusable element.
ArrowDown
Next trigger.
ArrowUp
Previous trigger.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/keyboard-table.json

Anatomy

KeyboardTable
└── KeyboardTableItem

shadcn.io Keyboard Table is a framed Table. KeyboardTable renders the table and a Key / Description header (th). Each KeyboardTableItem is one tr. The Key column renders Kbd keycaps (outline by default) with a muted + between combo parts.

The outer card matches Type Table: rounded-xl border bg-card p-1. Hover on rows is off (isHoverable={false}). Rows are not expandable.

Usage

import {
  KeyboardTable,
  KeyboardTableItem,
} from "@/components/ui/keyboard-table";
<KeyboardTable>
  <KeyboardTableItem keys="Space">
    When focus is on a collapsed trigger, expand the row.
  </KeyboardTableItem>
  <KeyboardTableItem keys="Shift + Tab">
    Move focus to the previous focusable element.
  </KeyboardTableItem>
</KeyboardTable>

A string keys is split on +. Pass a string[] when you do not want splitting — glyphs like belong in an array.

Examples

Combo

Pass an array for modifier glyphs, or a string with + for named keys.

Muted keys

kbdVariant="default" uses the filled Kbd style instead of outline keycaps.

Compact

size="compact" reduces row padding. Keycaps stay the same size.

Guides

Keys

keys="Shift + Tab" becomes two keycaps. Extra spaces around + are ignored. Use keys={["⌘", "K"]} for symbols so a + inside a glyph is not a separator.

Each key is a <kbd>. The group has dir="ltr" so combos stay left-to-right in RTL layouts, and aria-label is the joined shortcut (Shift + Tab).

Keyboard Table vs Table vs Data List vs Type Table

Keyboard TableTableData ListType Table
ShapeTwo-column shortcut tableRows and columnsLabel / value pairsExpandable Prop / Type rows
Use whenKeyboard support, shortcut listsTabular comparisonMetadata, summariesComponent API docs

Keyboard Table is Table with a Key / Description header and keycaps. Use Table when you need extra columns, selection, or TanStack Table.

For a single shortcut on a Button or Tooltip, use Kbd directly.

API Reference

shadcn.io Keyboard Table wraps Table and Kbd. Defaults below are shadcn.io values. kbdVariant is "outline" here ("default" on Kbd). Row hover is off.

asChild merges props onto a single child element.

KeyboardTable

Root. Renders a div around a Table (table + Key / Description header).

PropType
AttributeDescription
data-slotkeyboard-table
data-size"default" or "compact"

Root styles: @container, rounded-xl border bg-card p-1 text-card-foreground. The header is data-slot="keyboard-table-header". The body is data-slot="keyboard-table-body". The inner table has aria-label="Keyboard shortcuts".

KeyboardTableItem

One shortcut row. Renders a Table row (tr) with Key and Description cells.

PropType
AttributeDescription
data-slotkeyboard-table-item

Accessibility

Uses native table semantics. Key and Description are column headers (th). Each shortcut is a row; the first cell is the keycaps, the second is the description. Keycaps are native kbd elements.

  • Decorative + separators are aria-hidden. The group aria-label is the readable combo.
  • Do not put a second interactive control in the Key column. Links and buttons belong in the description.
  • dir="ltr" on the key group keeps modifier order stable in RTL.

Keyboard support

The table is not a composite widget. Links and buttons inside descriptions participate in the normal tab order.