import * as React from 'react' import { cn } from '../../internal/utils' type KbdSize = 'sm' | 'md' | 'lg' const SIZE_CLASSES: Record = { sm: 'h-5 min-w-5 text-xs px-1.25 rounded-2xs', md: 'h-6 min-w-6 text-sm px-1.5 rounded-[calc(var(--radius-xs)-0.0625rem)]', lg: 'h-7 min-w-7 text-base px-1.75 rounded-xs', } interface KbdProps extends React.ComponentProps<'kbd'> { /** * Height, padding, and text scale. Inherited from a `KbdGroup`. * @default 'md' */ size?: KbdSize } function Kbd({ className, size = 'md', ...props }: KbdProps) { return ( ) } interface KbdGroupProps extends React.ComponentProps<'span'> { /** * Default size applied to each child `Kbd` that doesn't set its own. * @default 'md' */ size?: KbdSize } function KbdGroup({ className, size = 'md', children, ...props }: KbdGroupProps) { return ( {React.Children.map(children, (child) => { if (!React.isValidElement(child) || child.type !== Kbd) return child if (child.props.size !== undefined) return child return React.cloneElement(child, { size }) })} ) } export { Kbd, KbdGroup } export type { KbdProps, KbdGroupProps, KbdSize }