On this page
3 checkboxes with following states: unchecked, indeterminate, checked

Definitive guide to indeterminate state of a checkbox

Learn more about the indeterminate state of form element like checkbox, radio button, and progress bar and how your users can benefit from it.

In HTML, the indeterminate state is a special visual state for form elements like checkboxes, radio buttons, and progress bars. For checkboxes, this state represents a condition where the checkbox is neither checked nor unchecked – it’s a third visual state typically displayed as a horizontal line (dash) inside the checkbox instead of a checkmark.

Important: the indeterminate state cannot be triggered by user interaction (such as clicking, hovering, or partial clicks). It is only set programmatically via JavaScript and is purely visual – it doesn’t affect the checkbox’s submitted value.

Common use case

The indeterminate state is most commonly used in hierarchical checkbox lists (parent/child relationships) to indicate that some, but not all, child checkboxes are selected. For example:

  • Parent checkbox: indeterminate state (dash) when some children are checked
  • Parent checkbox: checked state when all children are checked
  • Parent checkbox: unchecked state when no children are checked

See screenshot examples of visual representation of input type checkbox and indeterminate state:

Input type checkbox and indeterminate state on Safari browser on macOS
Safari, version 15.4 (17613.1.17.1.13), macOS
Indeterminate state on Ubuntu Linux, Firefox 118.0.2, Ubuntu 22.01
Ubuntu Linux, Firefox 118.0.2, Ubuntu Linux 22.10

You can also see a code example of a checkbox with a mixed-state.

Understanding the indeterminate property

The indeterminate property is a JavaScript property of the HTMLInputElement object. It has a boolean value (true or false) and is used to set or check the indeterminate state of a checkbox.

Key characteristics

  • Visual only: the indeterminate state does not affect the checkbox’s checked property or its value when submitted.
  • Independent: modifying indeterminate has no effect on checked, and vice versa.
  • No HTML attribute: there is no indeterminate HTML attribute – this state can only be set via JavaScript.

CSS pseudo-class

The :indeterminate CSS pseudo-class targets:

  • <input type="checkbox"> elements whose indeterminate property is true.
  • <input type="radio"> elements when all radio buttons with the same name are unchecked.
  • <progress> elements in an indeterminate state.

Practical use case: parent-child checkbox pattern

The indeterminate state is most useful when managing a group of checkboxes where you want to indicate the selection status of sub-options.

See visual example:

Indeterminate vs. mixed state: clarifying the terminology

Throughout this article, indeterminate and mixed state are often used interchangeably, but they have specific meanings:

The indeterminate and mixed state details
TermContextDescription
IndeterminateNative HTML elementVisual state of a native <input type="checkbox"> set via the indeterminate JavaScript property
MixedARIA attributeARIA state value (aria-checked="mixed") used on elements with role="checkbox" or role="menuitemcheckbox"

Both represent the same concept – a third state that is neither checked nor unchecked – but they have different implementation requirements and accessibility implications.

Detecting the indeterminate state

There is no HTML attribute for indeterminate and the only way to detect this state is using JavaScript:

An example of how to check if a checkbox has an indeterminate state
const checkbox = document.querySelector('#myCheckbox');

if (checkbox.indeterminate) {
  // The indeterminate state is true
  console.log('Checkbox is in indeterminate state');
} else {
  console.log('Checkbox is not in indeterminate state');
}

How to change the indeterminate state

Use the indeterminate property on the HTMLInputElement object:

Setting indeterminate state

An example of how to set an indeterminate state to true on the input type checkbox
const checkbox = document.querySelector('#myCheckbox');

// Set indeterminate state
checkbox.indeterminate = true;

// Clear indeterminate state
checkbox.indeterminate = false;

Important notes

  • The indeterminate property has no effect on the checked property.
  • Setting indeterminate to true doesn’t change the checkbox’s value when submitted.
  • Always set indeterminateafter setting checked if both properties need to be configured.

Example with parent-child logic

Complete example showing parent-child checkbox management
// Parent checkbox that controls child checkboxes
const parentCheckbox = document.querySelector('#parent');
const childCheckboxes = document.querySelectorAll('.child');

function updateParentState() {
  const checkedCount = document.querySelectorAll('.child:checked').length;
  const totalChildren = childCheckboxes.length;
  
  if (checkedCount === 0) {
    parentCheckbox.checked = false;
    parentCheckbox.indeterminate = false;
  } else if (checkedCount === totalChildren) {
    parentCheckbox.checked = true;
    parentCheckbox.indeterminate = false;
  } else {
    parentCheckbox.indeterminate = true;
    parentCheckbox.checked = false; // Visual state is indeterminate
  }
}

// Listen for changes on child checkboxes
childCheckboxes.forEach(checkbox => {
  checkbox.addEventListener('change', updateParentState);
});

Key takeaways

  • The indeterminate state is visual only and doesn’t affect the checkbox’s checked property or submitted value.
  • It cannot be set via HTML – JavaScript is required.
  • The indeterminate and checked properties are independent of each other.
  • Most useful for parent-child checkbox relationships where some (but not all) child items are selected.
  • Accessibility support varies by browser and screen reader – test thoroughly.
  • Always reset indeterminate state manually when resetting forms.

Browser support

The :indeterminate CSS pseudo-class is widely supported across modern browsers. Check caniuse.com for detailed compatibility information.

However, visual representation of the indeterminate state can vary significantly across browsers:

Visual representation of the indeterminate state
BrowserVisual Appearance
Chrome 118+Horizontal dash (—)
Firefox 118+Horizontal dash or filled square
Safari 15.4+Horizontal dash (—)
Edge 118+Horizontal dash (—)

Note: always test your implementation across target browsers to ensure consistent visual appearance.

Complete working example

Below is a complete example demonstrating the indeterminate state with parent-child checkbox relationships:

Resetting a checkbox to its initial state

When resetting a form, the indeterminate state is not automatically reset. You need to store the original state and restore it manually:

Example: manual reset

How to properly reset indeterminate state
// Store initial state
const checkbox = document.querySelector('#myCheckbox');
const initialIndeterminate = checkbox.indeterminate;

// On form reset
function resetForm() {
  // Reset other form fields...
  
  // Restore indeterminate state
  checkbox.indeterminate = initialIndeterminate;
}

Accessibility support for indeterminate state

Live code examples

Testing aria-checked="mixed" on a native checkbox:

Testing aria-checked="mixed" on a faux checkbox:–

Testing indeterminate property on a native checkbox:

Screen reader compatibility

The table below shows how different screen reader/browser combinations expose the indeterminate/mixed state to assistive technologies. Pass means the state is correctly announced to users, while Not exposed means users may not receive this information – this is an important consideration for accessibility.

Safari (macOS) / VOChrome / JAWS (2020)Chrome / NVDAIE 11 / JAWS (2020)Firefox / NVDASafari (iOS) / VOChrome / Talkback
Native checkbox with aria-checked="mixed"Not exposed to APIExposed, announced ✓Exposed, announced ✓Not exposed to APINot exposed to APINot exposed to APINot exposed to API
Faux checkbox with aria-checked="mixed"Exposed, announced ✓Exposed, announced ✓Exposed, announced ✓Exposed, announced ✓Exposed, announced ✓Not exposed to API
Native checkbox with indeterminate stateNot exposed to APIExposed, announced ✓Exposed, announced ✓Not exposed to APIExposed, announced ✓Not exposed to APINot exposed to API

Accessibility best practices

  1. Always provide visual indicators for sighted users (the dash/horizontal line).
  2. Use ARIA labels (aria-label or aria-labelledby) for additional context.
  3. Test with screen readers in your target browsers.
  4. Consider using aria-checked="mixed" on faux checkboxes for better screen reader support (as shown in the table above).
  5. Ensure keyboard accessibility (tabindex, Space/Enter key handling).

Common pitfalls and best practices

Pitfalls to avoid

  1. Assuming indeterminate affects form submission. The indeterminate property is visual only and it doesn’t affect the checkbox’s checked state or submitted value.
  2. Relying on user interaction to set indeterminate. Users cannot set indeterminate state through clicks or keyboard interaction. It must be set via JavaScript.
  3. Forgetting to handle indeterminate in form resets. The indeterminate state persists through form resets and must be managed manually.
  4. Using only visual indicators for accessibility. Sighted users see the dash, but screen reader users may not hear the mixed state depending on browser/AT combination.

Best practices and recommendations

  1. Always pair visual state with proper ARIA attributes when creating custom checkbox components.
  2. Test the indeterminate state with screen readers (NVDA, JAWS, VoiceOver (macOS).
  3. Provide keyboard support for custom checkbox implementations.
  4. Document the indeterminate state behavior for other developers working on the codebase.
  5. Use parent-child checkbox patterns where the indeterminate state adds clear value.

Further reading and resources

Related posts

Comments

Leave a Reply

Search in sitelint.com

Is your site slow?

Discover performance bottlenecks to provide a better customer experience and meet your company’s revenue targets.