import { FormControlLabel as MUIFormControlLabel, styled, Switch as MUISwitch, } from '@mui/material'; import { FC, ReactElement, useMemo } from 'react'; import { GREY } from '../lib/consts/DEFAULT_THEME'; import { BodyText } from './Text'; const SwitchFormControlLabel = styled(MUIFormControlLabel)({ height: '3.5em', marginLeft: 0, width: '100%', }); const SwitchWithLabel: FC = ({ baseInputProps, checked: isChecked, formControlLabelProps, id: switchId, label, name: switchName, onChange, switchProps, }) => { const labelElement = useMemo( () => typeof label === 'string' ? ( {label} ) : ( <>{label} ), [label], ); return ( <> } label={labelElement} labelPlacement="start" {...formControlLabelProps} /> ); }; export default SwitchWithLabel;