QdsCheckbox

A binary and indeterminate choice control for the Quantum Design System.

Overview

The qds-checkbox component provides an accessible checkbox with support for checked, unchecked, and indeterminate states. It is form-associated and works standalone or inside qds-field.

When to use a checkbox vs a switch: A checkbox implies a pending change that the user must save. A switch implies an immediate change that is applied without a save step. Use qds-checkbox for form inputs, preferences dialogs, and row selection in data tables. Use qds-theme-switch (or a future switch component) for settings that take effect immediately.

Do not use qds-checkbox for mutually exclusive options — use qds-radio-group instead.

Usage

<qds-checkbox label="Accept terms and conditions" required></qds-checkbox>
<qds-checkbox checked label="Enable notifications"></qds-checkbox>
<qds-checkbox indeterminate label="Select all rows"></qds-checkbox>

Label can also be provided as slotted text content:

<qds-checkbox>Accept terms and conditions</qds-checkbox>

API Reference

Attributes

Properties

CSS Parts

CSS Custom Properties

Events

Example

<form id="prefs-form">
  <qds-checkbox name="newsletter" label="Subscribe to newsletter" checked></qds-checkbox>
  <qds-checkbox name="terms" label="Accept terms" required hint="You must accept to continue"></qds-checkbox>
  <qds-checkbox name="extras" label="Optional extras" value="extras-pkg"></qds-checkbox>
</form>
<script>
  document.querySelector('#prefs-form').addEventListener('change', (e) => {
    if (e.target.tagName === 'QDS-CHECKBOX') {
      console.log(e.detail.checked, e.detail.value);
    }
  });
</script>