astro-reactive-form/packages/form/components/controls/RadioGroup.astro
2022-10-25 09:56:06 +02:00

31 lines
529 B
Text

---
/**
* RADIO GROUP COMPONENT
*/
import type { Radio } from 'common/types';
export interface Props {
control: Radio;
}
const { control } = Astro.props;
const options = control.options.map((option) => {
if (typeof option === 'string') {
return {
label: option,
value: option,
};
}
return option;
});
---
{
options.map((option) => (
<div class="radio-option">
<input type="radio" name={control.name} value={option.value} checked={option.value === control.value} />{' '}
{option.label}
</div>
))
}