import type { HTMLAttributes } from "react"
const macOSSymbols: Record = {
cmd: "⌘",
command: "⌘",
opt: "⌥",
option: "⌥",
alt: "⌥",
ctrl: "⌃",
control: "⌃",
shift: "⇧",
enter: "↩",
return: "↩",
tab: "⇥",
esc: "⎋",
escape: "⎋",
delete: "⌫",
backspace: "⌫",
forwardDelete: "⌦",
up: "↑",
down: "↓",
left: "←",
right: "→",
space: "␣",
fn: "Fn",
globe: "🌐",
eject: "⏏",
power: "⏻",
capslock: "⇪",
home: "↖",
end: "↘",
pageup: "⇞",
pagedown: "⇟",
clear: "⌧",
}
export interface KbdProps extends HTMLAttributes {
mac?: keyof typeof macOSSymbols
}
export function Kbd({ children, mac, className = "", ...rest }: KbdProps) {
const label = children ?? (mac ? macOSSymbols[mac] : null)
if (!label) return null
return (
{label}
)
}