STA-003 When a search or filter matches nothing, say so and offer a way to change it
- Level
- Guideline, our choice
- Verdict
- Insufficient evidence (1 of 3 judges spoke)
- Area
- States
- Status
- proposed, version 1.0.0
Rule
When a search or filter matches nothing, say in the results space that nothing matched, and offer a way to change or clear the search or the filters. Our own choice: name what was searched for or filtered by, and keep the query and the filters in place, ready to edit.
Examples
Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.
Do: The message names the search and offers a way back
Stock
0 parts
1 filter onNo in-stock parts match “alloy seatpost”.
Don't: “No results.” for every empty case
Stock
0 parts
1 filter on| Part | Brand | Stock |
|---|---|---|
| No results. | ||
Don't: A count line that is not a live region
Stock
No in-stock parts match “alloy seatpost”.
Don't: No match dressed as an error
Stock
0 parts
1 filter onNo in-stock parts match “alloy seatpost”.
Why
An empty result after a search is a different thing from an empty list. The items may well exist; the person's words or choices kept them out. If the space only goes blank, or says "No results." with nothing else, they cannot tell a search that found nothing from one that is slow or broken, and they do not know which of their choices to undo. A message that names the query and offers the way back lets them correct it in one step. No WCAG criterion asks for the content of this message. When the line appears while focus stays in the search field, it is a status message under WCAG 2.2, 4.1.3 Status Messages, announced as FBK-004 says.
Our reasons
Only one judge has spoken, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. So does NN/g, an expert witness who does not vote. Naming the query or the filters in the message is our own choice, backed by NN/g. Keeping the query in the field is backed only by NN/g, so that is our own choice too. We follow it for three reasons.
- A dead end costs the person the search. Without a way out, the only next step is to start over, and many people give up instead.
- The cause is the person's own input. Naming the query or the filters shows them what to change, and a clear control lets them change it without hunting.
- Rebuilding a search is work. A query or a set of filters that is cleared after an empty result must be typed and chosen again. Leaving it in place costs nothing.
Do
- A bike parts shop's stock table has a search field and the filters Brand and In stock. The person types "alloy seatpost" with In stock on. Where the rows were, the table area says "No in-stock parts match “alloy seatpost”.", with Clear search and Clear filters. "alloy seatpost" stays in the field, and In stock stays on.
- The count line above the table, "0 parts", sits in a polite live region that was in the page before the search, as FBK-004 says. The rows themselves are not a status message.
- The filters live in a popover. Outside it, the toolbar shows "2 filters on" and Clear filters, so an empty table never looks like missing stock.
- Our own advice: when one filter is likely to blame and the product can tell cheaply, offer to remove just that one, such as Show parts not in stock (4).
- Our own advice: suggest a spelling or wider words when the search can, such as a link Search for “seat post”.
- In a shadcn command menu, replace the default text of
CommandEmptywith a line that repeats the typed words and a hint, such as "No customers match “Hendrix”. Check the spelling or try fewer letters."CommandEmptyonly mounts when the count reaches zero, so it is created together with its text, and focus stays in the input. Write the same line into a polite live region that is in the menu from the start, as FBK-004 says. - A tag combobox, where creating the typed tag is what the person likely wants, may offer Create tag “gravel” in the empty line. Elsewhere, changing or clearing the query is the main way out, not creating an item.
- Write in a plain tone and neutral colours. No match is a normal outcome, not an error, so it does not use the danger colour or the wording TXT-001a asks of a problem.
- A search that found near matches may show them under a line that says nothing matched exactly.
- Buttons follow ACT-001a: Clear filters, not Reset or OK.
Don't
- Keep the data table's "No results." row for every empty case, so a filter with no match, a list with no items and a failed fetch all look alike.
- Leave
CommandEmptyat "No results found." with no hint and nothing to do. - Clear the search field or the filters when the result is empty, or reset them when the person comes back with the browser's Back button.
- Put the count line in a
divthat is created at the same moment as its text, so screen readers miss it. - Show "No matches" in red with a warning icon.
- Offer Add part as the main button under "No in-stock parts match “alloy seatpost”".
Exceptions
- Nothing there at all. When the list is empty with no search or filter applied, STA-002a applies.
- Still searching or failed. While the request runs, show the wait (STA-002b). A search that failed is a failure, shown as FBK-002 and TXT-001a say, not a no-match.
- A product that chooses otherwise. This is a guideline. A product that words its no-match message differently still announces the count line, as FBK-004, a requirement, asks.
Verdict
Insufficient evidence (1 of 3 judges spoke). Only the judges decide; the expert witnesses are shown but do not vote. The judges do not settle this one, so it is a guideline: our own choice, with our reasons above. How verdicts work
| Source | Role | Stance | Page |
|---|---|---|---|
| WCAG 2.2 | Law | Supports | 4.1.3 Status Messages |
| Material Design | Judge | No position | |
| Apple Human Interface Guidelines | Judge | No position | |
| Carbon Design System | Judge | Supports | Empty states Search Filtering |
| GOV.UK Design System | Expert witness | No position | |
| Nielsen Norman Group | Expert witness | Supports | 3 Guidelines for Search Engine "No Results" Pages, by Kathryn Whitenton Designing Empty States in Complex Applications: 3 Guidelines, by Kate Kaplan |
Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.
History
- Version 1.0.0, : First version.
Last checked against the other rules for conflicts on .
More in States: 5 rules and 2 guidelines · All rules
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.