import {useEffect, useRef} from 'react'; type CheckboxProps = React.InputHTMLAttributes; interface Props extends Omit { /** * Is the checkbox active? Supports 'indeterminate' */ checked?: CheckboxProps['checked'] | 'indeterminate'; } const Checkbox = ({checked = false, ...props}: Props) => { const checkboxRef = useRef(null); // Support setting the indeterminate value, which is only possible through // setting this attribute useEffect(() => { if (checkboxRef.current) { checkboxRef.current.indeterminate = checked === 'indeterminate'; } }, [checked]); return ( ); }; export default Checkbox;