Sub topic 4
Why a screen is empty
This chapter assumes you know basic UI vocabulary (layout, components, copy), how web or mobile apps fetch data asynchronously, and enough HTML and TypeScript to read short snippets. It builds on the screen state model from the first chapter, where "empty" appeared as a distinct case of successful data with no items.
Empty is a result, not a single state
A list with zero items looks the same in every case: a blank area. The cause behind it varies a lot, and the cause decides what the user needs to see.
Compare three people who all see an empty project list:
- A new user who signed up a minute ago. Nothing is wrong. They need to know what the screen is for and how to start.
- A user who typed "invoice" into a filter and got nothing. They need to know the filter caused it and how to change it.
- A user whose manager removed them from the workspace. They need to know they lost access and who can restore it.
If you show all three the same message ("Nothing here"), at least two of them get the wrong guidance. Designing empty states starts with finding the cause, and the wording and layout follow from it. The next chapter covers writing and layout. This chapter covers the classification.
An empty state is also not a loading state and not an error state. In the discriminated union from the state model, success with data.length === 0 is its own branch, and it must never be confused with loading or error.
The main types of empty state
Most empty screens fall into a small set of causes. The names below are working labels for design discussions. Use whatever names your team agrees on, but keep one name per cause.
| Type | Cause | Example | What the user needs |
|---|---|---|---|
| First use | The user has never created or received anything here | A new account's project list | An explanation of the screen and a clear first action |
| Cleared | The user finished or removed everything | An inbox after the last message is archived | Confirmation that this is a good or neutral result |
| No results | A search or filter excludes everything | Searching "invoice" in a file list | The active query, and a way to loosen or clear it |
| No access | Content exists, but this user may not see it | A project the user was removed from | An honest statement of the limit and who can grant access |
| Not set up | A prerequisite is missing, so nothing can appear yet | A dashboard before any data source is connected | The missing setup step, as a direct action |
| Pending | Data is expected but has not arrived yet | A report that generates overnight | What is coming and roughly when |
The sections below take each type in turn and then the one that causes the most damage: an error that looks like an empty state.
First use
First use is the user's first look at a feature. The screen has no content yet because the user has never produced any. This is an opportunity as well as a gap. The user is deciding whether the product is worth learning, and an empty box tells them nothing.
Signals that identify it: the user has never created an item, and no filter is active. Note that "never created an item" is a fact you must be able to determine. If the data only tells you the list is empty, you cannot tell first use from cleared.
Cleared
A cleared state appears after the user did something that emptied the screen: archived the last email, completed the last task, deleted the last file. The emotional register differs from first use. Finishing a task queue is a success, and deleting all files might be neutral or a mistake the user wants to undo.
Because the user caused it, the screen should acknowledge that action. Offering to undo a deletion belongs here. Telling someone to "get started" after they finished everything feels wrong.
No results
No results appear when the dataset has items but the current query, filter, or date range matches none. The key distinction from first use is that the user can fix this without creating anything. The screen should show what is currently applied, because users often forget they left a filter on.
A frequent bug is showing a first-use prompt ("Create your first project") when a filter is hiding existing projects. The user has projects, so the prompt is false and confusing.
No access
No access is the case where items exist but the user cannot see them. Be careful here, because the right message depends on your security model. In some systems, revealing that a resource exists is itself a leak, so a "no access" message should be replaced by a plain "not found." Decide this with whoever owns authorization, not on your own.
When it is safe to reveal, say what is limiting the user (a role, a removed membership) and who can change it.
Not set up
Some screens are empty because a prerequisite has not happened: no payment method, no connected account, no data source. Here the empty area is a dead end until the user does something else, often on a different screen. The action to fix it should be one click away, and the screen should name the specific missing piece.
Pending
Pending content is expected but not ready: an import that is still processing, a report scheduled for tomorrow. This differs from loading. A loading state means a request is in flight and will resolve within seconds. A pending state is a successful response that says "not yet," and it may stay that way for hours. Treat it as an empty state with a time expectation, not as a spinner that never ends.
The false empty state
The most harmful case is an error displayed as an empty state. It happens when code catches a failed request, falls back to an empty array, and renders the "no items" branch.
// Anti-pattern: a failure becomes an empty list.
async function loadProjectsUnsafe(fetchProjects: () => Promise<string[]>): Promise<string[]> {
try {
return await fetchProjects();
} catch {
return []; // The UI will now say "No projects yet."
}
}The user sees "No projects yet. Create your first project," concludes their work is gone, and may create duplicates or contact support in a panic. The data is still there. The request failed.
The fix is structural: the failure must travel to the UI as an error state, never as an empty success. If you modeled the screen with the AsyncState union, this bug cannot compile in the same form, because error and success are separate branches.
Finding the cause in code
The UI can only show the right empty state if the code knows the cause. A bare array is not enough. You need a few facts alongside it: whether filters are active, whether the user has ever had items, whether access is limited, and whether setup is complete.
The function below takes those facts and returns a reason. It is a plain function so it is easy to test, which matters in the final chapter of this tutorial.
type EmptyReason =
| "first-use"
| "cleared"
| "no-results"
| "no-access"
| "not-set-up"
| "pending";
interface EmptyContext {
canView: boolean; // false if the user lacks permission
isSetUp: boolean; // prerequisites such as a connected source
isProcessing: boolean; // an import or report is still being prepared
activeFilterCount: number; // search text, filters, date range
everHadItems: boolean; // true if the user created or received items before
}
function classifyEmpty(ctx: EmptyContext): EmptyReason {
if (!ctx.canView) return "no-access";
if (!ctx.isSetUp) return "not-set-up";
if (ctx.isProcessing) return "pending";
if (ctx.activeFilterCount > 0) return "no-results";
return ctx.everHadItems ? "cleared" : "first-use";
}
const reason = classifyEmpty({
canView: true,
isSetUp: true,
isProcessing: false,
activeFilterCount: 1,
everHadItems: true,
});
console.log(reason); // "no-results"The order of the checks is a design decision. Permission comes first because a user who cannot view the content should not be told about filters. Setup and processing come before filters because they explain why nothing can exist yet. Filters come before first-use and cleared, which prevents the false first-use prompt described earlier.
Notice everHadItems. Your API may not return it by default. If it cannot, you have to choose: ask the backend for a flag, or treat first use and cleared as one state with neutral wording. Both are acceptable. Guessing wrong is the only bad option.
A decision path
The diagram shows the same logic as a flow. Start from "the request succeeded and returned zero items" and ask the questions in order.
If the request did not succeed, you never enter this diagram. That is the point: the error branch is decided before any empty state is considered.
Edge cases
Real screens produce combinations that a clean taxonomy hides. These are the ones that come up most.
- Partial emptiness. A dashboard with four panels where one panel has no data. Each panel needs its own classification. A single page-wide empty message would hide the three panels that do have content.
- Filter plus first use. A user with no items who also has a stale filter saved from a previous session. The filter check wins, and the screen should offer to clear it. After clearing, the user then lands in first use.
- Empty after a delete. The user deletes the last item and the screen changes under them. This is the cleared state, and an undo option is more useful than a call to create something new.
- Stale cache. If you show cached data while refetching, an empty cache is not an empty result. Wait for the real response before declaring emptiness, or users will see a brief "No projects yet" before the list appears. The timing chapter in this tutorial covers this flicker in detail.
- Empty but not final. Paginated or lazily loaded lists can be empty on the first page of a filter yet have matches later, for example when the server filters after paging. Make sure "no results" reflects the entire query, not one page.
- Different roles, same screen. An admin and a viewer may both see an empty team page. The admin can invite people, so a call to action fits. The viewer cannot, so the same call to action would be a dead end.
Common mistakes
- Using one generic "No data" message for every cause.
- Showing a first-use prompt while a filter is active.
- Rendering a failed request as an empty list.
- Telling a user who lacks permission to "create" something they cannot create.
- Treating a long-running pending state as an endless loading spinner.
- Letting an empty region collapse to nothing, so the user cannot tell whether the screen is broken.
Each of these comes from the same root cause: the code or the design did not ask why the list was empty.
Summary
An empty screen is a successful result with a cause. The common causes are first use, cleared, no results, no access, not set up, and pending. Each calls for a different explanation and next step. Your code must carry enough context to tell them apart, and a failed request must never be shown as an empty list. The next chapter takes these causes and covers how to write the message and lay out the screen for each one.
Exercise
A user opens their task list and sees "You have no tasks. Create your first task!" They have 40 tasks, but a "Due this week" filter is active and nothing matches. Which empty state type should the screen show, what is wrong with the current message, and what should the screen offer instead?
Show answer
It should show the no results type. The current message is a first-use prompt, which is false because the user has tasks and it hides the real cause, the active filter. The screen should say that no tasks match "Due this week", display the active filter, and offer a way to clear or change it. Creating a task is a secondary option at most.
Exercise
A request to load invoices times out. The code catches the error and returns an empty array, and the UI shows "No invoices yet." Name the problem and describe how to change the state model so the problem cannot recur.
Show answer
The problem is a false empty state: a failure is presented as a successful result with no items, so the user may think their invoices are gone. Model the screen with separate loading, error, and success states, for example a discriminated union. Let the catch block produce an error state (with a message and whether retrying is possible) instead of an empty success, and render the empty message only in the success branch when the data length is zero.