Tone kbd
Five keyboard keys that carry meaning through color: info, success, warning, danger and muted. Each renders a real kbd element, exposes a data-tone attribute, and takes its fill and border from the matching semantic token, so the whole set recolors with your theme.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/kbd-toneDependencies, the @ai2/tokens theme and the component file are installed together.
Copy the source
components/ui/kbd-tone.tsx"use client"
import type * as React from "react"
import { cn } from "@/lib/utils"
/* Tone kbd family: 5 keys in semantic tones. Every root is a real <kbd>, carries data-tone and takes its colour ONLY from semantic tokens (a soft fill plus an alpha border, through color-mix or Tailwind opacity). Static - no motion required. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
const box: Record<StyledSize, string> = {
sm: "h-5 px-1.5 text-xs",
md: "h-6 px-2 text-xs",
lg: "h-7 px-2.5 text-sm",
xl: "h-8 px-3 text-sm",
}
const base =
"inline-flex w-fit shrink-0 select-none items-center justify-center gap-1 whitespace-nowrap rounded-md border font-mono font-medium leading-none [&_svg]:size-3 [&_svg]:shrink-0 [&_i]:text-xs [&_i]:leading-none"
type Props = React.ComponentProps<"kbd"> & { size?: StyledSize }
/* Info: bilgi tonu - info-soft govde, info kenar. */
export function InfoKbd({ className, size = "md", children, ...props }: Props) {
return (
<kbd
data-slot="styled-kbd"
data-tone="info"
className={cn(base, box[size], "border-info/30 bg-info-soft text-info-soft-foreground", className)}
{...props}
>
{children ?? "F1"}
</kbd>
)
}
/* Success: onay tonu - success-soft govde, success kenar. */
export function SuccessKbd({ className, size = "md", children, ...props }: Props) {
return (
<kbd
data-slot="styled-kbd"
data-tone="success"
className={cn(
base,
box[size],
"border-success/30 bg-success-soft text-success-soft-foreground",
className
)}
{...props}
>
{children ?? "Enter"}
</kbd>
)
}
/* Warning: uyari tonu - warning-soft govde, warning kenar. */
export function WarningKbd({ className, size = "md", children, ...props }: Props) {
return (
<kbd
data-slot="styled-kbd"
data-tone="warning"
className={cn(
base,
box[size],
"border-warning/30 bg-warning-soft text-warning-soft-foreground",
className
)}
{...props}
>
{children ?? "Alt"}
</kbd>
)
}
/* Danger: yikici eylem tonu - danger-soft govde, danger kenar. */
export function DangerKbd({ className, size = "md", children, ...props }: Props) {
return (
<kbd
data-slot="styled-kbd"
data-tone="danger"
className={cn(
base,
box[size],
"border-danger/30 bg-danger-soft text-danger-soft-foreground",
className
)}
{...props}
>
{children ?? "Esc"}
</kbd>
)
}
/* Muted: notr/ikincil ton - muted govde, standart kenar. */
export function MutedKbd({ className, size = "md", children, ...props }: Props) {
return (
<kbd
data-slot="styled-kbd"
data-tone="neutral"
className={cn(base, box[size], "border-border bg-muted text-muted-foreground", className)}
{...props}
>
{children ?? "Tab"}
</kbd>
)
}Manual installs skip the @ai2/tokens theme, so add the token CSS from the theming guide or the tone colors will be missing.
Variations
5 takes on the same idea. Each is its own export, and every one accepts a size prop (sm, md, lg, xl) aligned to the base Button scale.
Info
An info-toned key for help and hint shortcuts.
import { InfoKbd } from "@/components/ui/kbd-tone"
<InfoKbd />Success
A success-toned key for confirming actions.
import { SuccessKbd } from "@/components/ui/kbd-tone"
<SuccessKbd />Warning
A warning-toned key for shortcuts that need care.
import { WarningKbd } from "@/components/ui/kbd-tone"
<WarningKbd />Danger
A danger-toned key for destructive or escape shortcuts.
import { DangerKbd } from "@/components/ui/kbd-tone"
<DangerKbd />Muted
A neutral, low-emphasis key for secondary shortcuts.
import { MutedKbd } from "@/components/ui/kbd-tone"
<MutedKbd />ai2 Tone kbd: 5 styled variations on the token system
The ai2 Tone kbd are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around semantic tones applied to a keyboard key. They are free and MIT licensed, and every color comes from a semantic token, so they theme with the rest of ai2 in light and dark.
Motion runs on framer-motion: these are static, so no motion library work is required. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, there is no continuous motion to reduce.
What is in the ai2 Tone kbd?
5 exports in one file: Info, Success, Warning, Danger and Muted. Each renders a native button and takes a size prop (sm, md, lg, xl) aligned to the base Button. They are separate from the base Button on purpose: the base keeps its clean variant, tone and size axes, while the styled layer carries the effects.
You own the file. Copy the one category file and you have all 5 variations, with no runtime dependency on ai2 itself.
Why use it
- On-system by construction: Every color resolves to an ai2 semantic token, so the buttons follow your theme in light and dark with no extra work.
- Effect without the sprawl: The decorations live in a dedicated styled file, so the base Button keeps its clean, predictable API.
- Accessible and honest: Each renders a real button element, keeps a visible focus ring, and respects prefers-reduced-motion.
Features
- Token-driven color: No hardcoded hex or oklch; the look recolors with your theme tokens.
- framer-motion: these are static, so no motion library work is required.
- Reduced-motion aware: Under prefers-reduced-motion, there is no continuous motion to reduce.
- Size aligned to the base: Every variation takes sm, md, lg and xl matching the base Button height scale, so styled and base buttons line up in a row.
Production tips
- Use it for emphasis, not everywhere: Styled buttons draw the eye. Reserve them for the one action you want people to take on a screen, and use the base Button for the rest.
- Keep labels as verbs: The decoration adds weight, so a clear action label keeps the button scannable.
- Pick one variation per surface: The variations share a family; using two different ones in the same view competes for attention.
Works with the rest of ai2
The Tone kbd sit alongside the base Button and the rest of the @ai2 registry. They share the same token file, so a styled action next to a base button or a badge stays visually consistent in both modes.