Off
A 40 × 24 track in text/muted, with “Off” in words.
Changes a setting immediately, like turning on email updates in account settings. The change is saved straight away, so there is no submit button.
Updated
Toggle
HTML
<div class="nds-toggle"> <div class="nds-toggle__row"> <span class="nds-toggle__label" id="email-updates"> Email updates </span> <div class="nds-toggle__control"> <button type="button" class="nds-toggle__switch" role="switch" aria-checked="false" aria-labelledby="email-updates" > <span class="nds-toggle__track" aria-hidden="true"> <span class="nds-toggle__knob"> </span> </span> </button> <span class="nds-toggle__status" aria-hidden="true"> Off </span> </div> </div></div> WordPress
<!-- wp:nds/toggle {} --><div class="nds-toggle"> <div class="nds-toggle__row"> <span class="nds-toggle__label" id="email-updates"> Email updates </span> <div class="nds-toggle__control"> <button type="button" class="nds-toggle__switch" role="switch" aria-checked="false" aria-labelledby="email-updates" > <span class="nds-toggle__track" aria-hidden="true"> <span class="nds-toggle__knob"> </span> </span> </button> <span class="nds-toggle__status" aria-hidden="true"> Off </span> </div> </div></div><!-- /wp:nds/toggle --> Usage
import { Toggle } from "@nigerian-design-standards/react";<Toggle label="Email updates" onChange={(next) => { // Save immediately, then announce e.g. "Email updates turned on" }}/> Usage
use NDS\Components\Toggle;echo Toggle::render([ 'label' => 'Email updates',]); Use a toggle when a setting should take effect as soon as someone flips it — account preferences, notifications, and similar controls.
The toggle’s states. On and Off are always shown in words next to the track. When a setting is disabled, say why next to it on the page—not only in the status word.
A 40 × 24 track in text/muted, with “Off” in words.
action/primary/default track, knob to the right, with “On”.
2px border/dark around the track. Not the keyboard focus ring.
Can’t be changed. Say why next to it.
The properties of the toggle. The same in HTML, WordPress and React.
| Property | Type | Possible values | Description |
|---|---|---|---|
| label | string | any text | The setting’s name. It is the switch’s accessible name. |
| on | boolean |
| Whether the setting is on. |
| disabled | boolean |
| Avoid where you can: explain why an option isn’t available instead. |
In code, use a <button> with role="switch" and aria-checked, named by the visible label with aria-labelledby. Save the
change straight away, then announce the result with a status message.
| Part | Token | Contrast on the page |
|---|---|---|
| Track | spacing/500 × spacing/300 (40 × 24px) · radius/200 | — |
| Off track | text/muted | 6.6:1 |
| On track | action/primary/default | 5.8:1 |
| Active | border/dark, 2px | 14.3:1 |
| Knob | size/icon/md (20px) · surface/canvas | — |
| Label | Body/medium · text/primary | 17.6:1 |
| Spacing | spacing/100 (8px) between track and On or Off text | — |
Use a toggle for a setting that saves straight away, and show On or Off in words.
Don’t use a toggle inside a form with a submit button. Use a checkbox.
How toggles are laid out.
How to name the setting and confirm the change.
A hint like “We’ll email you when your application changes”.
| Write | Don’t write | Why |
|---|---|---|
| Email updates | Do you want to receive email updates? | A short name for the setting. |
| Email updates turned on | Settings saved successfully! | Says what changed. |
| Show my phone number | Hide my phone number: Off | No double negatives. |
| On · Off | Yes · No | Matches a switch. |
| We’ll email you when your application changes | Toggle to receive notifications | Says what happens. |
A button with role=“switch”, labelled by the setting name, with On or Off shown in words.
| Key | What it does |
|---|---|
| Tab | Moves focus to the switch. |
| Shift+Tab | Moves focus back to the previous element. |
| Space or Enter | Switches the setting on or off straight away. |
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
Use Form/Toggle from 01 Library – Foundations. Set On, State and the Label. Don’t detach it.
Is this page useful?