Files
community-rule/app/components/RadioGroup/RadioGroup.view.tsx
T
2026-01-29 17:35:51 -07:00

46 lines
999 B
TypeScript

import RadioButton from "../RadioButton";
import type { RadioGroupViewProps } from "./RadioGroup.types";
export function RadioGroupView({
groupId,
value,
mode,
state,
disabled,
options,
className,
ariaLabel,
onOptionChange,
}: RadioGroupViewProps) {
return (
<div
className={`space-y-[8px] ${className}`}
role="radiogroup"
aria-label={ariaLabel}
>
{options.map((option) => {
const isSelected = value === option.value;
return (
<RadioButton
key={option.value}
checked={isSelected}
mode={mode}
state={state}
disabled={disabled}
label={option.label}
name={groupId}
value={option.value}
ariaLabel={option.ariaLabel}
onChange={({ checked }) => {
if (checked) {
onOptionChange(option.value);
}
}}
/>
);
})}
</div>
);
}