Unchecked
A 20px box with a 1px border/strong outline.
Lets people pick one or more answers from a list, or tick a single box to confirm something, like agreeing to the terms.
Updated
Checkbox
HTML
<div class="nds-checkbox"> <input class="nds-checkbox__input" type="checkbox" id="email" name="contact" value="email" /> <label class="nds-checkbox__label" for="email"> <span class="nds-checkbox__control" aria-hidden="true"> </span> <span class="nds-checkbox__text"> Email </span> </label></div> WordPress
<!-- wp:nds/checkbox {} --><div class="nds-checkbox"> <input class="nds-checkbox__input" type="checkbox" id="email" name="contact" value="email" /> <label class="nds-checkbox__label" for="email"> <span class="nds-checkbox__control" aria-hidden="true"> </span> <span class="nds-checkbox__text"> Email </span> </label></div><!-- /wp:nds/checkbox --> Usage
import { Checkbox } from "@nigerian-design-standards/react";<Checkbox label="Email" name="contact" value="email"/> Usage
use NDS\Components\Checkbox;echo Checkbox::render([ 'label' => 'Email', 'name' => 'contact', 'value' => 'email',]); Checkboxes sit in a group, under a legend that asks the question, and people can tick any number of them. One checkbox on its own confirms something, like “I agree to the terms”.
The box’s states. Disabled is also available, but explain why an option isn’t available instead where you can.
A 20px box with a 1px border/strong outline.
action/primary/default fill with a white tick.
2px border/dark around the control. Not the keyboard focus ring.
A red border, always with the group’s error message.
The properties of the checkbox. The same in HTML, WordPress and React.
| Property | Type | Possible values | Description |
|---|---|---|---|
| label | string | any text | The option, in a few words. The whole label is clickable. |
| checked | boolean |
| Whether the box is ticked. |
| name · value | string | any text | Sent with the form. Options in one group share a name. |
| disabled | boolean |
| Avoid where you can: explain why an option isn’t available instead. |
In code, each option is an <input type="checkbox"> with a <label for>, so the whole label is clickable. Put the group in a <fieldset> with a <legend>; the hint and error ids go on the
fieldset’s aria-describedby. Stack options one per line.
| Part | Token | Contrast on the page |
|---|---|---|
| Box | 20px (size/icon/md) · radius/050 · surface/canvas | — |
| Border | border/strong, 1px | 4.2:1 |
| Checked fill and tick | action/primary/default · text/white (2px stroke tick) | 5.8:1 |
| Active | border/dark, 2px | 14.3:1 |
| Error | status/error/surface border, with the group’s error message | 4.9:1 |
| Label | Body/medium · text/primary | 17.6:1 |
| Spacing | spacing/100 8px box to label · spacing/150 12px between options · spacing/300 24px in a fieldset | — |
Ask the question in the legend and stack the options, one per line.
Don’t put an error on one option. The group gets one error message under the legend.
How checkboxes are laid out.
How to write the question, the options and the error.
“How would you like us to contact you?”
In the hint, so people know they can pick more than one.
A few words each, starting with a capital.
“Send me updates”, not “Don’t send me updates”.
“Select how you want to be contacted”.
“I agree to the terms and conditions”, not “I accept”.
| Write | Don’t write | Why |
|---|---|---|
| Select all that apply | Choose any | Clear instruction. |
| Send me email updates | Don’t send me emails | Positive wording. |
| Select how you want to be contacted | Please select an option | Says what to do. |
| I agree to the terms and conditions | I accept | Says what they agree to. |
| Text message | SMS | Plain words, no jargon. |
Real checkbox inputs with labels, grouped in a fieldset with a legend.
| Key | What it does |
|---|---|
| Tab | Moves to each checkbox in turn. Labels and legends aren’t Tab stops. |
| Shift + Tab | Moves back. |
| Space | Ticks or unticks the checkbox. |
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
Use Form/Checkbox from 01 Library – Foundations, inside Form/Checkbox group for a question. Set Checked, State and the Label. Don’t detach it.
Is this page useful?