// Radio group. Rendered as a
/ so the group has a name, and as // one native radio per option so arrow-key navigation is the platform's job. import type { JSX } from 'solid-js'; import { useId } from '../a11y'; import { cx } from '../cx'; import styles from './Radio.module.scss'; export interface RadioOption { value: string; /** Already-translated. */ label: string; description?: string | undefined; disabled?: boolean | undefined; } export interface RadioProps { /** Already-translated group label, rendered as the . */ legend: string; name: string; options: readonly RadioOption[]; value?: string | undefined; disabled?: boolean | undefined; required?: boolean | undefined; direction?: 'row' | 'column' | undefined; class?: string | undefined; 'aria-describedby'?: string | undefined; onChange?: JSX.EventHandlerUnion | undefined; } export function Radio(props: RadioProps): JSX.Element { const group = useId('radio'); return (
{props.legend} {props.options.map((option, index) => ( ))}
); }