Empty state
What stands in for a list, a set of results or a report when there is nothing to show. It says what is empty, why, and what to do next.
Nothing matches
Try fewer filters, or clear them to see everything.
The library is empty
Add some pictures and they will appear here.
Nothing matches
Try fewer filters, or clear them to see everything.
The library is empty
Add some pictures and they will appear here.
Show code
<div class="sn-empty">
<p class="sn-empty-title">Nothing matches</p>
<p>Try fewer filters, or clear them to see everything.</p>
<button type="button" class="btn-secondary">Clear filters</button>
</div> Three kinds of nothing
| Why it's empty | Say | The way out |
|---|---|---|
| Nothing has been added yet | What will appear here, and how: "The library is empty. Add some pictures and they will appear here." | The button that adds one, if it isn't already beside the list |
| Nothing matches the filters or the search | "Nothing matches", and that there are things to find | Clear filters |
| It couldn't be fetched | That it didn't arrive, and why if known. Never "nothing here": that would be untrue. | Try again, or who to tell |
Anatomy
- A dashed frame the width of what it stands in for, so the page keeps its shape and the gap reads as a place, not a fault.
- A title (
.sn-empty-title): a plain statement in a few words, in the text colour. - One sentence in the softer text colour, if it adds something.
- One action at most, a secondary button, under the words.
A single line needs no frame of its own: <p class="sn-empty"> works for a short "No changes yet".
Do and don't
Do
- Say what is empty in the page's own words: "No days kept yet"
- Offer the one thing that fixes it
Don't
- Leave a blank space, or a heading with nothing under it
- Blame the reader ("You haven't…") or make a joke of it
Accessibility
What it does for you
- Ordinary text in reading order: the title, a sentence, then the one action.
- A frame the width of what it stands in for, so the page keeps its shape.
- The action is a real button.
What you need to do
- When it appears in answer to typing or filtering, put it in a polite live region (
role="status") so it is read out. - Leave the focus where it was: on the filter or search box.
- Tell the truth about why it’s empty. "Nothing here" for something that failed to load is wrong.
Keyboard
| Key | What it does |
|---|---|
| Tab | Moves to its action, if it has one. |
| Enter or Space | Does the action (Clear filters). |
What a screen reader is told
- Its words, as text. Read out by itself only if the area it appears in is a live region.
This is what the browser reports to assistive technology. What each screen reader then says varies, and has not been listened to yet.
WCAG 2.2
| Criterion | Level | How this meets it |
|---|---|---|
| 1.3.1 Info and Relationships | A | Title, sentence and action are in the order they are read. |
| 4.1.3 Status Messages | AA | Met only when the area it appears in is a live region: that part is yours. |
The criteria this component has a part in. A page that uses it still has to meet the rest.
Checked
| Check | How | Result |
|---|---|---|
| Automated (axe-core) | WCAG 2.0, 2.1 and 2.2 rules at A and AA, the page in light and in dark | Passed Nothing found, light or dark |
| Narrow screen | No sideways scrolling at 320px wide (WCAG 1.4.10) | Passed No sideways scrolling |
| Keyboard and what the browser reports | Real key presses on the live example, and the role, name and state given to assistive technology | Passed 2 of 2 checks pass |
| On paper | Somnia’s print check: no overlaps, stranded headings or controls on the page | Passed No faults on 4 sheets |
| Screen reader | Listened to by a person, in VoiceOver and NVDA | Not yet Not yet checked by a person |
The 2 checks made with the keyboard, on the example at the top of this page:
- Passed Its one action is a button, reached by Tab and named by its words
- Passed Its words are ordinary text, in reading order: the title, then the sentence, then the action
Run by script on against Somnia DS 1.89.0, in Chromium with axe-core 4.14.0. How these checks work, and every component's results.
Not yet checked
- How it sounds in a screen reader (VoiceOver, NVDA, TalkBack) has not been checked by a person. The roles, names and states the browser reports are checked by script; what is actually spoken is not.
- Whether each place in Somnia CMS that shows one also announces it (a live region) has not been checked one by one.
Evidence
Where it's used
| Where | For |
|---|---|
| Somnia CMS | The media library ("The library is empty", "Nothing matches"), filtered lists, Visitors ("No days kept yet"), Version history and the audit log. |
What we saw, and what changed
| When | What we saw | What changed |
|---|---|---|
| Lists and filters in Somnia CMS needed one way to say there is nothing to show. | A framed empty state, with Clear filters under it where filters are the reason (1.60.0). | |
| The Visitors page’s longer periods start with no days kept. "Nothing to show" would have been true and useless. | It says what will appear and when: "Somnia CMS keeps each finished day’s figures from now on". |
From building and using it on real sites, each entry taken from the changelog or the build's own notes. This is observation by the studio and its clients, not research sessions with users.
What it rests on
- Nielsen Norman Group: Designing Empty States in Complex Applications: Say what the state of things is, help people learn the system, and give a direct way to the next task.
What we don't know yet
- See the live-region gap under Accessibility.