STA-002b Never say a space is empty while its content is still loading
- Level
- Rule
- Verdict
- Unanimous (2 of 2)
- Area
- States
- Status
- proposed, version 1.0.0
Rule
While a list, table or panel is still fetching its content, show that it is loading, never that it is empty. Show the message that there is nothing only after the fetch has finished and returned no items.
Examples
Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.
Do: Wait first, then the answer
Overdue invoices
Example control
Sets the next reply. Press Reload invoices to send the request.
Don't: “Nothing” drawn before the reply
Overdue invoices
Nothing is overdue
Invoices that pass their due date will show here.
Example control
Sets the next reply. Press Reload invoices to send the request.
Don't: A failure shown as an empty list
Overdue invoices
Example control
Sets the next reply. Press Reload invoices to send the request.
Do: Old rows stay, dimmed, until the new ones arrive
Unpaid invoices
| Invoice | Customer | Due |
|---|---|---|
| INV-2041 | Harbour Café | 3 Dec |
| INV-2044 | Norberg Joinery | 5 Dec |
| INV-2047 | Studio Aalto | 12 Dec |
| INV-2050 | Dunmore Print | 19 Dec |
Don't: Rows cleared as soon as the filter changes
Unpaid invoices
| Invoice | Customer | Due |
|---|---|---|
| INV-2041 | Harbour Café | 3 Dec |
| INV-2044 | Norberg Joinery | 5 Dec |
| INV-2047 | Studio Aalto | 12 Dec |
| INV-2050 | Dunmore Print | 19 Dec |
Why
A message that says there is nothing is an answer, and people act on it. If it shows while the content is still on its way, some leave and never see their data, and those who wait and see it fill in learn not to trust what the app tells them. A blank space during the fetch does harm too, since it looks the same as an empty one. The space has to say "on its way" until the reply is there, and "nothing" only after. How and where the wait is drawn is STA-001. What the empty space then says is STA-002a, or the guideline STA-003 after a search or filter. No WCAG criterion says which of the two to show. When the line changes in place while focus stays elsewhere, both "Loading orders" and "No orders yet" are status messages under WCAG 2.2, 4.1.3 Status Messages, announced as FBK-004 says.
Do
- Give the component at least three states, not two: loading, empty and ready, and a fourth for a failure. A plain
useState([])cannot tell "not fetched yet" from "fetched, nothing there". - With TanStack Query, show the wait while
isPendingis true. Show the empty state only whenisSuccessis true and the data is an empty array. Never treatdatathat is stillundefinedas empty. A query withenabled: false, such as a search before anything is typed, stays pending without fetching: show neither the wait nor the empty state then, only the prompt to type. - A dashboard card Overdue invoices fetches on its own. Until the reply it shows a small indicator named "Loading overdue invoices", as STA-001 asks. Then it shows the invoices, or the empty state STA-002a describes.
- A table refetches after the person changes a filter. Keep the old rows, dimmed, with an indicator, as STA-001 says, until the new rows or the no-match message from STA-003 arrive. With TanStack Query, set
placeholderData: keepPreviousDataso the old rows stay while the new query key loads, and dim them whileisPlaceholderDatais true. - A command menu searches the server as the person types. While the request runs, the list says "Searching customers …". Only after the reply does it show the matches, or the no-match line.
- Give a Suspense boundary a
fallbackwith a skeleton or an indicator. - When the fetch fails, the space shows a failure, not an empty state. FBK-002 says where it goes and how long it stays, and TXT-001a what it says, with a way to try again. It may use the same place as the empty state, but it is a failure message.
- Whether to show a wait at all for a very quick reply is STA-001's own choice of about half a second. Applied here: for that half second the space shows neither the wait nor the empty state.
- The line that changes from "Loading invoices" to "No overdue invoices" or to "12 overdue invoices" is announced as FBK-004 says. The rows themselves are not a status message.
Don't
- Write
const [items, setItems] = useState([])and renderitems.length === 0 ? <Empty /> : <List />, so "No invoices yet" flashes on the first render before the effect has fetched anything. - Write
catch { setItems([]) }, or passdata ?? []to the shadcn data table, so a server error or a dropped connection shows the table's "No results." row. - Clear the rows as soon as a filter changes, so the empty row shows for as long as the request takes.
- Use
fallback={null}on a Suspense boundary, so the area is blank while it loads. - Show
CommandEmptywith "No results found." after the first keystroke while the request is still running.
Exceptions
- Content already on the page. A list that is rendered with the page, with nothing to fetch, has no loading state. Show the items or the empty state at once.
- What the wait looks like. A spinner, a skeleton or dimmed old rows all fit this rule. STA-001 decides which and where.
Verdict
Unanimous (2 of 2). Only the judges decide; the expert witnesses are shown but do not vote. 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 | Supports | Loading (all platforms; written for native apps and games, not the web) |
| Carbon Design System | Judge | Supports | Empty states Search Loading pattern |
| GOV.UK Design System | Expert witness | No position | |
| Nielsen Norman Group | Expert witness | Supports | 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.