Info
A neutral update people may want to know about.
A short, temporary message that confirms an action or reports a change, without taking people away from what they’re doing.
Updated
Changes saved
Toast
Add the Toast block, or paste this markup into the Code editor
<div class="nds-toast nds-toast--success" role="status"> <div class="nds-toast__inner"> <div class="nds-toast__leading"> <svg class="nds-toast__status-icon" width="20" height="20" focusable="false" aria-hidden="true"> <use href="#nds-icon-success"> </use> </svg> </div> <div class="nds-toast__content"> <p class="nds-toast__title"> Changes saved </p> <p class="nds-toast__message"> Your profile details have been updated. </p> </div> <button type="button" class="nds-toast__close" aria-label="Close notification"> <svg class="nds-toast__icon" width="20" height="20" focusable="false" aria-hidden="true"> <use href="#nds-icon-close"> </use> </svg> </button> </div></div> Usage
<!-- wp:nds/toast {} --><div class="nds-toast nds-toast--success" role="status"> <div class="nds-toast__inner"> <div class="nds-toast__leading"> <svg class="nds-toast__status-icon" width="20" height="20" focusable="false" aria-hidden="true"> <use href="#nds-icon-success"> </use> </svg> </div> <div class="nds-toast__content"> <p class="nds-toast__title"> Changes saved </p> <p class="nds-toast__message"> Your profile details have been updated. </p> </div> <button type="button" class="nds-toast__close" aria-label="Close notification"> <svg class="nds-toast__icon" width="20" height="20" focusable="false" aria-hidden="true"> <use href="#nds-icon-close"> </use> </svg> </button> </div></div><!-- /wp:nds/toast --> Usage
import { Toast } from "@nigerian-design-standards/react";<Toast state="success" title="Changes saved" message="Your profile details have been updated."/> Usage
use NDS\Components\Toast;echo Toast::render([ 'state' => 'success', 'title' => 'Changes saved', 'message' => 'Your profile details have been updated.',]); A toast is a short message about something that just happened. It appears above the page at the top right and people can carry on without acting on it. Four states tell people what kind of message it is.
Pick the state from what the message means, and use the same state for the same meaning across a service.
A neutral update people may want to know about.
Something people just did worked.
Something to watch that doesn’t block people.
Something failed. Say what to do next.
The properties of the nds-toast component. The same in HTML, WordPress and React.
| Property | Type | Possible values | Description |
|---|---|---|---|
| state | string |
| What the message means. Sets the icon and its colour. |
| title | string |
| Optional. A few words. Leave it out for a one-line message. |
| message | string |
| One or two sentences. For problems, say what to do next. |
In code, add the toast to a live region that is already on the page: role="status" for
success and info, role="alert" for warning and error. Start the text with a visually
hidden “Success:”, “Information:”, “Warning:” or “Error:”. The close button is a <button> with aria-label="Close notification".
| Part | Token | Contrast on the page |
|---|---|---|
| Container | surface/canvas · border/subtle · 1px · radius/050 | Border is decorative |
| Status icon | info · success · warning: 20px Fill /surface · error: 16px status/error/surface disc + 12px icon/exclamation (text/white) | Info 5.6:1 · Success 5.8:1 · Warning 4.9:1 · Error disc 4.9:1 · Exclamation 4.5:1 |
| Title | Label/medium · text/primary | 17.6:1 |
| Message | Body/small · text/secondary | 6.6:1 |
| Close icon (20px) | icon/close · text/primary | 17.6:1 |
| Padding · gaps | spacing/300 24px (top, bottom) · spacing/150 12px (sides, column gap) · spacing/050 4px (title to message) | — |
| Shadow | Not a style yet: y 2, blur 4, spread -1 at 2% · y 5, blur 13, spread -5 at 5% | — |
Confirm something people just did, in a few words.
There were 2 problems
Don’t put form errors in a toast. It disappears before people fix them. Use an alert above the form.
Where a toast appears and how much room it takes.
How to write toast text. Say what happened and, for problems, what to do, in plain words.
A hidden state word or the title says it. Never rely on the icon or colour.
For errors: “We couldn’t upload your file. Check your connection and try again.”
Anything people must read or act on goes in an alert or on the page.
A title and one or two sentences. People see it for a few seconds.
A saved record is Success everywhere in the service.
| Write | Don’t write | Why |
|---|---|---|
| Changes saved | Success! | Says what worked. |
| Your reference number has been copied | Copied to clipboard successfully | Shorter, and says what was copied. |
| We couldn’t upload your file. Check your connection and try again | Error 500 | Says what failed and what to do. |
| Connection is slow. Some changes may take longer to save | Network issue detected | Plain words, and what it means for people. |
| Online renewals will be unavailable on Saturday | Scheduled maintenance | Says what and when. |
A toast appears without people asking for it, so it is announced and never takes focus.
| Key | What it does |
|---|---|
| Tab | Reaches the close button in reading order. The toast itself isn’t a Tab stop. |
| Shift + Tab | Moves back. |
| Enter or Space | Closes the toast. |
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
Use the nds-toast component from 01 Library – Foundations. Don’t detach it.
Is this page useful?