States in React Checkbox

13 Nov 20262 minutes to read

The React Checkbox component supports three visual states:

  • Checked
  • Unchecked
  • Indeterminate

Checked and unchecked

Use the React Checkbox checked property to manage the checked and unchecked states. When checked, a checkmark appears in the React Checkbox frame.

Indeterminate

Set the React Checkbox to an indeterminate state using the indeterminate property. The indeterminate state visually represents a partially selected condition and is commonly used for parent React Checkboxes in hierarchical lists. This state cannot be set through user interaction and is only achievable through the property.

import { enableRipple } from '@syncfusion/ej2-base';
import { CheckBoxComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
function App() {
    return (<ul>
          {/* checked state. */}
          <li><CheckBoxComponent label="Checked State" checked={true}/></li>

          {/* unchecked state. */}
          <li><CheckBoxComponent label="Unchecked State"/></li>

          {/* indeterminate state. */}
          <li><CheckBoxComponent label="Indeterminate State" indeterminate={true}/></li>
      </ul>);
}
export default App;
ReactDom.render(<App />, document.getElementById('check-box'));
import { enableRipple } from '@syncfusion/ej2-base';
import { CheckBoxComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';

enableRipple(true);

function App() {
  return (
      <ul>
          {/* checked state. */}
          <li><CheckBoxComponent label="Checked State" checked={true} /></li>

          {/* unchecked state. */}
          <li><CheckBoxComponent label="Unchecked State" /></li>

          {/* indeterminate state. */}
          <li><CheckBoxComponent label="Indeterminate State" indeterminate={true} /></li>
      </ul>
  );
}
export default App;
ReactDom.render(<App />, document.getElementById('check-box'));