Loading and empty state patterns for shadcn
Rules / States: 5 rules and 2 guidelines
Between pressing a button and seeing the result there is often a wait. A table loads its data, a form is saved, a payment goes through. What the app shows during that wait, and what it still lets people do, decides whether they trust it. When the wait ends with nothing to show, the space has to say whether it is empty, still on its way, or empty only because of a search. Some apps also run a clock of their own: a session that ends, a reserved seat that is released. shadcn gives you a Spinner and a Skeleton. It does not say where they go, what the button that started the wait should do, or what happens when time runs out.
Where states go wrong
- A full-page overlay with a spinner while one table reloads, so nothing else on the screen can be used. STA-001
- A Save button that shows nothing after it is pressed, so people press it again. STA-005a
- Two orders placed, because the second press went through as well. STA-005b
- A session that ends after a quarter of an hour of reading and throws away a long form, with no warning and no way to ask for more time. STA-004
- A loading message that a screen reader never hears about. FBK-004
- The data table’s “No results.” row on a list nobody has searched, with no way to add the first item. STA-002a
- “No invoices yet” that flashes before the data has arrived, or that shows after a failed fetch. STA-002b
- A search that empties the table, clears the query and offers no way back. STA-003, a guideline (our choice)
How the rules fit together
STA-001 says where a wait is shown: in the part that is loading, at the control that started it or where the content will appear, while the rest of the view stays usable. A skeleton in place of the table that is loading fits this rule; a layer over the whole page does not.
STA-005a covers an action that has been sent. While a button’s request is under way, the button shows it until the reply comes. STA-005b, a guideline (our choice), goes with it: while the action is being sent, another click, tap, Enter or Space does not send it again. Together they mean that a button that is saving looks busy and cannot fire twice, while the rest of the screen stays alive. The obvious way, the disabled attribute, has a catch: a button that becomes disabled while it has focus drops out of the tab order, and focus can land at the top of the page. STA-005b explains the way we prefer.
STA-004 is about time limits that the product itself sets. When a limit could end someone’s chance to act or throw away their work, people can turn it off, lengthen it, or extend it after a warning. The rule lists the conditions each option has to meet and prefers them in that order.
Three texts cover a space that holds nothing. STA-002b comes first: while a list, table or panel is still fetching, it shows that it is loading, and it says it is empty only once the fetch has finished with no items. A fetch that failed shows a failure, not an empty state. STA-002a covers a space that is truly empty: a short message in that space says what will appear there, with one button or link for the first step when the person can take it. STA-003, a guideline (our choice), covers a search or filter that matched nothing: it says so in the results space and offers a way to change or clear the search. Naming what was searched for, and keeping the query and filters in place, are our own choices within it. The table patterns cover the table around these messages.
When the wait is over, the feedback patterns take over: a success shows in the view (FBK-003), a failure stays where it started (FBK-002), and a status message is announced without moving focus (FBK-004). Inside a dialog, what Escape and Cancel do while the action is under way is decided by STA-005a, as DLG-001 points out.
What WCAG requires and what the judges decide
STA-004 is a requirement of WCAG 2.2, under 2.2.1 Timing Adjustable. Its order of preference is our own advice and marked as such. No judge has spoken on it, but for a requirement the law decides.
STA-001 and STA-005a are decided by the judges, with all three in support. The two empty-state rules, STA-002a and STA-002b, are decided by the judges too, with both who spoke in support; no WCAG criterion says what an empty space should show. STA-005b and STA-003 are guidelines: only one judge has spoken on each, so they are our choice, with our reasons on each page.
Rules and guidelines
Each one has its own page with the full rule, Do and Don't cases, exceptions and the verdict. A rule is decided by WCAG 2.2 or by the judges. A guideline is our own choice. How the method works
Required by WCAG 2.2
A WCAG 2.2 Level AA criterion requires the behaviour. Where a rule adds advice of its own, it says so.
STA-004Let people turn off, lengthen or extend a time limit the product setsWhen the product sets a time limit that can end a person's chance to act or throw away their work, let them turn it off, lengthen it, or extend it after a warning, unless an exception applies. Each option meets 2.2.1 only with the conditions listed for it first under Do. Our advice is to prefer them in that order.
Decided by the judges
No WCAG criterion requires these. The judges who spoke support them, all or most of them.
STA-001Show a wait in the part that is loading, not over the whole pageWhen content in one part of a view loads, show the wait in that part, at the control that started it or as a small indicator where the content will appear, never as a layer over the whole page, and keep the rest of the view usable.STA-002aSay what will appear in a space that holds nothing yet, and offer the first stepWhen a list, table, panel or page has finished loading and holds nothing yet, show a short message in that space that says what will appear there. When the person can add the first item, offer that action as one button or link with the message.STA-002bNever say a space is empty while its content is still loadingWhile 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.STA-005aShow that a sent action is under way until the reply comesWhen a button sends, saves or deletes something and the reply does not come at once, show that the action is under way until the reply comes.
Guidelines, our choice
The judges are split or too few have spoken, so we choose and give our reasons. A product that chooses otherwise is not wrong.
STA-003When a search or filter matches nothing, say so and offer a way to change itWhen 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.STA-005bWhile an action is being sent, a second press does not send it againWhile an action is being sent, another press on the same button does not send it again, whether it comes as a click, a tap, Enter or Space.
All rules · Is shadcn accessible? · Give the rules to an AI agent
Justified by Blackwood & Blake helps you work toward WCAG 2.2 AA. It is not a certification. Read more
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.