import React, { FC, ReactNode } from 'react'; import classNames from 'classnames'; import css from './index.module.css'; export interface RadioItem { name: string; value: string; label: ReactNode; isChecked?: boolean; } export interface RadioButtonsProps { items: RadioItem[]; desc?: string; onChange?: (e) => void; onBlur?: (e) => void; error?: string; required?: boolean; // style props horizontal?: boolean; invert?: boolean; } const RadioButtons: FC = ({ desc, onChange, onBlur, items, error, required, horizontal, invert, }) => { const radioButtonsClassNames = classNames(css.radioButtons, { [`${css.radioButtonsError}`]: error, [`${css.radioButtonsHorizontal}`]: horizontal, [`${css.radioButtonsInvert}`]: invert, }); return (
{desc &&
{desc}
} {items && items.map(item => ( ))} {error &&
{error}
}
); }; export default RadioButtons;