import * as React from 'react'; import { Checkbox, Stack } from '@fluentui/react'; // Used to add spacing between example checkboxes const stackTokens = { childrenGap: 10 }; export const CheckboxIndeterminateExample: React.FunctionComponent = () => { // Only used for the controlled checkbox (the last one) const [isIndeterminate, setIsIndeterminate] = React.useState(true); const [isChecked, setIsChecked] = React.useState(false); const onChange = React.useCallback( (ev?: React.FormEvent, newChecked?: boolean) => { if (isIndeterminate) { // If the checkbox was indeterminate, the first click should remove the indeterminate state // without affecting the checked state setIsIndeterminate(false); } else { setIsChecked(!!newChecked); } }, [isIndeterminate], ); return ( ); };