overleaf/services/web/frontend/js/shared/components/radio-chip.tsx
Rebeka Dekany a2946f8601 Merge pull request #15249 from overleaf/rd-odc-radio
Radio buttons for Onboarding Data Collection

GitOrigin-RevId: 8c4d1e965f3263b4c8a41c129c5c3d6e3ef10986
2023-11-02 08:52:52 +00:00

42 lines
782 B
TypeScript

import React from 'react'
type RadioChipProps<ValueType> = {
checked?: boolean
disabled?: boolean
name: string
onChange: (value: ValueType) => void
required?: boolean
label: React.ReactElement | string
value: ValueType
}
const RadioChip = <T extends string>({
checked,
disabled,
name,
onChange,
label,
required,
value,
}: RadioChipProps<T>) => {
const handleChange = () => {
onChange(value)
}
return (
<label className="radio-chip" data-disabled={disabled ? 'true' : undefined}>
<input
checked={checked}
disabled={disabled}
name={name}
onChange={handleChange}
type="radio"
required={required}
value={value}
/>
{label}
</label>
)
}
export default RadioChip