React playground

Nova v3.37.0

Preview

React

Checkbox

nv-fieldcheckbox

Selects one or more options from a group, with a label and an optional description.

Live demo

Label Placement

Use checkboxes to let people select any number of options from a group, such as the notifications they want to receive. For a single setting that applies immediately, use a toggle; for exactly one choice from a group, use radio buttons.

Anatomy

A checkbox with three callouts: 1 marks the empty checkbox, 2 the label Label to its right, and 3 the description below the label.

The parts of a checkbox.
  1. Checkbox shows whether the option is selected. Clicking it or its label, or pressing Space, toggles it.
  2. Label names the option; set it with label. hideLabel hides it visually but keeps it for screen readers.
  3. Description (optional) adds context below the label.

States

A checkbox is unchecked, checked or indeterminate. Indeterminate shows that only some options in a group are selected, usually on a "select all" checkbox; your application sets it, and selecting the checkbox clears it. Hover and focus styles are built in. disabled prevents interaction; readonly keeps the checkbox focusable but prevents changes.

unchecked
checked
indeterminate
disabled

For an invalid choice, set error with an errorDescription that says how to fix it: the checkbox turns red and the message appears below it.

Label placement

The label sits after the checkbox by default. labelPlacement="before" places it first; keep the description beside the same label and use one placement consistently within a group.

error
labelPlacement="before"

Themes

The design includes Spark and Ocean appearances. Use the page's theme and mode controls to compare the live examples; retain the same labels, states and validation messages in each theme.

Guidelines

  • Group related checkboxes under a clear heading, such as a fieldset with a legend.
  • Offer a "select all" checkbox when people often want every option.
  • Do not preselect options without a clear reason, such as a default preference.
  • Do not mix checkboxes and radio buttons in one group.
DoOffer “select all” when people often want every option.
Don'tAvoid mixing checkboxes and radio buttons in one group.

Sources