Mac kbd
Five platform glyph treatments: unicode mac symbols, a Command shortcut, its Windows text equivalent, lucide icon caps and a mixed set. A glyph alone is not readable, so every root carries a visually hidden label spelling out the full shortcut, such as Command plus K.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/kbd-macDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install lucide-reactCopy the source
components/ui/kbd-mac.tsx"use client"
import type * as React from "react"
import { ArrowBigUp, Command, Option } from "lucide-react"
import { cn } from "@/lib/utils"
/* Mac kbd family: platform glyph styles. The visual caps carry a unicode glyph or a lucide icon; because no glyph gives a readable name on its own, the root <kbd> always carries the sr-only full text ("Command plus K") and the visual stack is aria-hidden. Colour comes ONLY from tokens. Static - no motion required. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
const box: Record<StyledSize, string> = {
sm: "h-5 min-w-5 px-1.5 text-xs",
md: "h-6 min-w-6 px-2 text-xs",
lg: "h-7 min-w-7 px-2.5 text-sm",
xl: "h-8 min-w-8 px-3 text-sm",
}
const gap: Record<StyledSize, string> = {
sm: "gap-1",
md: "gap-1",
lg: "gap-1.5",
xl: "gap-1.5",
}
const rootBase =
"inline-flex w-fit shrink-0 select-none items-center whitespace-nowrap font-mono font-medium leading-none text-foreground"
const capBase =
"inline-flex shrink-0 select-none items-center justify-center gap-1 whitespace-nowrap rounded-md border border-border bg-surface-2 font-mono font-medium leading-none text-foreground [&_svg]:size-3 [&_svg]:shrink-0 [&_i]:text-xs [&_i]:leading-none"
/* Bir kapak: gorsel glif + ekran okuyucuya giden ad. */
interface Key {
glyph: React.ReactNode
name: string
}
type Props = React.ComponentProps<"kbd"> & { size?: StyledSize }
/* Shared shell: the sr-only full combination text plus aria-hidden visual caps. */
function Combo({
keys,
size,
className,
children,
...props
}: Props & { keys: Key[] }) {
return (
<kbd data-slot="styled-kbd" className={cn(rootBase, gap[size ?? "md"], className)} {...props}>
{children ?? (
<>
<span className="sr-only">{keys.map((k) => k.name).join(" plus ")}</span>
<span aria-hidden="true" className={cn("inline-flex items-center", gap[size ?? "md"])}>
{keys.map((k, i) => (
<kbd key={`${k.name}-${i}`} className={cn(capBase, box[size ?? "md"])}>
{k.glyph}
</kbd>
))}
</span>
</>
)}
</kbd>
)
}
/* Symbol: saf unicode mac glifleri (Command, Option, Shift). */
export function SymbolKbd({ size = "md", ...props }: Props) {
return (
<Combo
size={size}
keys={[
{ glyph: "⌘", name: "Command" },
{ glyph: "⌥", name: "Option" },
{ glyph: "⇧", name: "Shift" },
]}
{...props}
/>
)
}
/* Mac: mac kisayolu - Command glifi + harf. */
export function MacKbd({ size = "md", ...props }: Props) {
return (
<Combo
size={size}
keys={[
{ glyph: "⌘", name: "Command" },
{ glyph: "K", name: "K" },
]}
{...props}
/>
)
}
/* Win: windows/linux karsiligi - duz metin tus adlari. */
export function WinKbd({ size = "md", ...props }: Props) {
return (
<Combo
size={size}
keys={[
{ glyph: "Ctrl", name: "Control" },
{ glyph: "K", name: "K" },
]}
{...props}
/>
)
}
/* Icon: caps carrying lucide icons instead of glyphs. */
export function IconKbd({ size = "md", ...props }: Props) {
return (
<Combo
size={size}
keys={[
{ glyph: <Command />, name: "Command" },
{ glyph: <ArrowBigUp />, name: "Shift" },
{ glyph: "P", name: "P" },
]}
{...props}
/>
)
}
/* Mixed: glif, ikon ve metin kapaklarin karisimi. */
export function MixedKbd({ size = "md", ...props }: Props) {
return (
<Combo
size={size}
keys={[
{ glyph: "⌘", name: "Command" },
{ glyph: <Option />, name: "Option" },
{ glyph: "Del", name: "Delete" },
]}
{...props}
/>
)
}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.
Symbol
Pure unicode mac glyphs for Command, Option and Shift.
import { SymbolKbd } from "@/components/ui/kbd-mac"
<SymbolKbd />Mac
A mac shortcut: the Command glyph plus a letter.
import { MacKbd } from "@/components/ui/kbd-mac"
<MacKbd />Win
The Windows and Linux equivalent, spelled out in plain text.
import { WinKbd } from "@/components/ui/kbd-mac"
<WinKbd />Icon
Keycaps that carry lucide icons instead of glyphs.
import { IconKbd } from "@/components/ui/kbd-mac"
<IconKbd />Mixed
A mix of glyph, icon and text keycaps in one shortcut.
import { MixedKbd } from "@/components/ui/kbd-mac"
<MixedKbd />ai2 Mac kbd: 5 styled variations on the token system
The ai2 Mac kbd are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around platform glyph styles for keyboard shortcuts. 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 Mac kbd?
5 exports in one file: Symbol, Mac, Win, Icon and Mixed. 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 Mac 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.