Skip to main content
On this page

Let users select one or more options from a group, or toggle a single option on or off.

When to use​

  • When users can select any number of options from a list, including none or all
  • When users need to opt in or confirm something before proceeding, such as agreeing to terms
  • When a single option needs to be explicitly turned on or off

When not to use​

  • When only one option can be selected at a time - use Radio instead. Checkboxes imply that multiple selections are valid.
  • When the list is very long - use Select Field or Combobox Field instead. A long checkbox list is difficult to scan.
  • When selection should take immediate effect - a checkbox is a form input; its value is submitted. If toggling should trigger an immediate action, use a different interaction pattern.
  • To show a pre-selected option the user cannot change - the disabled state is not supported. Display the value as plain text or use a read-only Summary List instead. Do not use the disabled prop.

Anatomy​

  1. Group label
  2. Group hint text
  3. Checkbox control
  4. Item label
  5. Item hint text
  6. Error text

Basic usage​

Use CheckboxField to group related checkboxes. The label prop becomes the group's legend, which screen readers announce before each individual checkbox.

Loading...
Edit live code
<CheckboxField label="How can I reduce my carbon footprint?" optional>
  <Checkbox label="Go plant based" id="plant-based" />
  <Checkbox label="Take fewer flights" id="flights" />
</CheckboxField>

Variants and features​

With hint text​

Hint text can be added at the group level (applies to the whole group) or at the item level (applies to one option). Use group hint text to clarify what the question is asking. Use item hint text when a specific option needs extra explanation.

Loading...
Edit live code
<CheckboxField
  label="How can I reduce my carbon footprint?"
  hint="Select all the changes you are willing to make"
>
  <Checkbox label="Go plant based" id="plant-based-hint" />
  <Checkbox
    label="Take fewer flights"
    id="flights-hint"
    hint="One long-haul return flight can outweigh a year of other savings"
  />
</CheckboxField>

Standalone checkbox​

A single Checkbox without a CheckboxField wrapper is appropriate when the intent is self-evident and no group label is needed, such as accepting terms and conditions.

Loading...
Edit live code
<Checkbox
  id="info"
  label="Tell me more about reducing my carbon footprint"
/>

A standalone checkbox can carry its own error, for example when it must be ticked to continue:

Loading...
Edit live code
<Checkbox
  id="info-error"
  error="You must agree in order to receive more information"
  label="Tell me more about reducing my carbon footprint"
/>

Optional groups​

Mark the group as optional with the optional prop on CheckboxField. This appends "(optional)" to the group label. Individual items can also be marked optional with the optional prop on Checkbox, though this is uncommon.

Loading...
Edit live code
<CheckboxField label="How can I reduce my carbon footprint?" optional>
  <Checkbox label="Go plant based" id="plant-based-optional" />
  <Checkbox label="Take fewer flights" id="flights-optional" />
</CheckboxField>

Rich labels​

A label accepts any React content, not just a string. Use this to include a Text Link in the label, for example when linking to terms the user is agreeing to.

Loading...
Edit live code
<Checkbox
  id="terms"
  label={
    <>
      Tell me more about reducing my{' '}
      <TextLink href="https://friendsoftheearth.uk" opensInNewWindow>
        carbon footprint
      </TextLink>
    </>
  }
/>

Common form features​

For validation, error messages, and integration with the Form component, see the Forms pattern guide.