31 lines
854 B
TypeScript
31 lines
854 B
TypeScript
import { type FC } from 'react'
|
|
import Radio from './Radio'
|
|
|
|
|
|
type Props = {
|
|
items: {
|
|
label: string
|
|
value: string | boolean
|
|
}[]
|
|
selected: string | boolean
|
|
onChange: (value: string | boolean) => void
|
|
}
|
|
|
|
const RadioGroup: FC<Props> = (props: Props) => {
|
|
return (
|
|
<div className='flex flex-wrap gap-5 items-center text-xs'>
|
|
{
|
|
props.items.map((item, index) => (
|
|
<div key={index} className='flex gap-2 items-center'>
|
|
<Radio value={item.value} onChange={props.onChange} isActive={item.value === props.selected} />
|
|
<div className='mt-0.5'>
|
|
{item.label}
|
|
</div>
|
|
</div>
|
|
))
|
|
}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default RadioGroup |