Skip to content
Pebble Pro is here at $49 one timeSee what’s included ↗
Pebble
ComponentsDocsMCPPricing
⌕ Find a component↗Log in
All components 673

Categories

Core inputs & forms46Buttons & actions33Navigation36Overlays & feedback49Data display33Charts & data viz40Cards & layout43Marketing blocks38App shells & pages37AI interfaces40Text & typography effects33Backgrounds & visual effects38Motion & transitions32Numbers & counters32Media34E-commerce333D & interactive36Themed sets40
Start with the essentials.Installation guide ↗Connect your agent ↗
← All componentsData display

Kbd

Inline keyboard keys and key combinations for shortcut hints, legible inside tooltips.

Preview

Shortcuts

Press ? any time

  • Search notesCtrlK
  • New noteCtrlAltN
  • Share with PriyaCtrlShiftS
  • Toggle sidebarCtrl\
RecordingCtrlShiftP
Jump to inboxGthenI
Close panelEsc

Keys adapt inside a tooltip.

Install

Add the editable source with the shadcn CLI. Your project also needs the shared theme tokens this component uses. Setup and requirements. The Pebble installer is not published yet.

npx shadcn@latest add https://pebbleui.com/r/kbd.json

Props

PropTypeDefaultDescription
childrenReactNode-Kbd: key text or a small icon (auto-sized to size-3).
variant"raised" | "lit" | "flat""raised"Kbd: raised keycap, lit (ink) key, or flat for dense text.
size"sm" | "md""sm"Kbd: key height and text size.
classNamestring-Kbd/KbdGroup: merged last, so it wins.
Build notes
A styled `<kbd>`: `inline-flex`, `h-5`, `min-w-5`, centred, `px-1`, `rounded-sm`, `bg-muted` with `text-muted-foreground` and a `border-border` edge, `font-sans text-xs font-medium` so keys match UI text rather than monospace. `[&_svg:not([class*='size-'])]:size-3` sizes icon children unless they set a size. Tooltip adaptation uses an ancestor arbitrary variant, `[[data-slot=tooltip-content]_&]:…`, keyed on this library's tooltip `data-slot`, so no context is needed. Compared with the source: a border is added, the dark-mode-only tooltip tint is folded into one translucent tint that works on the tooltip's lit-key surface (`bg-linear-to-b from-key-top to-key-bottom`, `text-primary-foreground`) in both themes, and `KbdGroup` is typed as `<kbd>`.

**Pebble (2026-11-03).** The key is now a pebble cap rather than a bordered chip: `raised` is `bg-card` with `ring-1 ring-hairline`, an inset `0 -1px 0 var(--hairline)` bottom edge plus `--elevation-xs`, and `inset-shadow-highlight` on top (`dark:bg-muted` so the cap still separates from a dark card). `lit` reuses the lit-key recipe (`from-key-top to-key-bottom`, `ring-key-edge`, `--key-shine`) at `--elevation-xs`. `flat` keeps the old muted look with no edge. Corners are `rounded-[5px]`, type is 11 px `tabular-nums` so digits line up in shortcut columns, and a `variant`/`size` pair is exposed with `data-variant`. The tooltip override now also clears the gradient, ring tint, shadow and inset highlight (`bg-none`, `shadow-none`, `inset-shadow-none`) and keys take the tooltip's ink: `bg-primary-foreground/15`, `text-primary-foreground`, `ring-primary-foreground/25`, and repeats the tint under `dark:` so it beats the raised cap's dark background. Colour and shadow transitions are dropped under `motion-reduce`.

<!-- PEBBLE-LICENSE -->
View source

registry/text/kbd/kbd.tsx

/* PEBBLE-LICENSE
Built by Pebble. Component: kbd.

First-party license: MIT

The following first-party terms apply only to original Pebble material.

MIT License

Copyright (c) 2026 Praxys Solutions LLC (Pebble)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

THIRD-PARTY NOTICES
These notices apply to identified upstream portions; Pebble terms do not replace or narrow their rights.

Upstream: https://raw.githubusercontent.com/shadcn-ui/ui/main/LICENSE.md
MIT License

Copyright (c) 2023 shadcn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
END PEBBLE-LICENSE */

import * as React from "react";

import { cn } from "@/lib/utils";

// Pebble: a key is a tiny raised object. `raised` is a card-coloured cap with
// a hairline ring, a top highlight and a 1 px hairline bottom lip, so it reads
// as a physical key sitting on the line. `lit` is the dark lit key for the
// shortcut that is currently held or just used. `flat` is a quiet muted chip for
// dense tables and menus.
const variants = {
  raised:
    // In dark mode the cap steps up to `muted` so it still lifts off a card.
    "bg-(--kbd-cap) [--kbd-cap:var(--card)] dark:[--kbd-cap:var(--muted)] text-muted-foreground ring-1 ring-hairline shadow-[inset_0_-1px_0_var(--hairline),var(--elevation-xs)] inset-shadow-highlight",
  lit: "bg-linear-to-b from-key-top to-key-bottom text-primary-foreground ring-1 ring-key-edge shadow-[var(--key-shine),var(--elevation-xs)]",
  flat: "bg-muted text-muted-foreground",
} as const;

const sizes = {
  sm: "h-5 min-w-5 px-1 text-[11px] [&_svg:not([class*='size-'])]:size-3",
  md: "h-6 min-w-6 px-1.5 text-xs [&_svg:not([class*='size-'])]:size-3.5",
} as const;

export type KbdProps = React.ComponentProps<"kbd"> & {
  /** `raised` (default) is a small lit-from-above cap; `lit` is the dark key; `flat` a muted chip. */
  variant?: keyof typeof variants;
  size?: keyof typeof sizes;
};

export function Kbd({ variant = "raised", size = "sm", className, ...props }: KbdProps) {
  return (
    <kbd
      data-slot="kbd"
      data-variant={variant}
      className={cn(
        "pointer-events-none inline-flex w-fit items-center justify-center gap-0.5 rounded-[5px] font-sans leading-none font-medium tabular-nums select-none",
        "transition-[background-color,box-shadow,color] duration-(--motion-fast) ease-enter motion-reduce:transition-none",
        variants[variant],
        sizes[size],
        // Inside a tooltip (the lit key surface, inked in primary-foreground)
        // the key turns translucent in that ink.
        "[[data-slot=tooltip-content]_&]:bg-primary-foreground/15 [[data-slot=tooltip-content]_&]:bg-none [[data-slot=tooltip-content]_&]:text-primary-foreground [[data-slot=tooltip-content]_&]:shadow-none [[data-slot=tooltip-content]_&]:inset-shadow-none [[data-slot=tooltip-content]_&]:ring-primary-foreground/25 dark:[[data-slot=tooltip-content]_&]:bg-primary-foreground/15",
        className,
      )}
      {...props}
    />
  );
}

export function KbdGroup({ className, ...props }: React.ComponentProps<"kbd">) {
  // A nested <kbd> is HTML's own markup for a key combination.
  return (
    <kbd
      data-slot="kbd-group"
      className={cn("inline-flex items-center gap-1 font-sans text-xs", className)}
      {...props}
    />
  );
}
Pebble

Small details.
Better interfaces.

React components to explore, make your own, and build on.

Library

  • Components
  • Installation
  • Pricing

Resources

  • For agents
  • About
  • Support

Legal

  • License
  • Terms
  • Privacy
  • Final sale

Built by Pebble

A product of Praxys Solutions LLC ↗

Pebble Pro is live

$49 one time, lifetime updates ↗