Sub topic 5
Writing and Laying Out an Empty State
Assume you understand basic layout, components, asynchronous data fetching, HTML, and TypeScript. An empty state appears when a screen has no items to show. It should explain why the screen is empty and give the user a useful next action.
Start with the cause
Do not use one generic message for every empty screen. The cause changes what the user needs to know and do.
| Empty-state cause | What the user needs | Suitable next action |
|---|---|---|
| First use | What this feature does | Create or set up the first item |
| User cleared the data | Confirmation that the action worked | Create a new item or undo |
| Search or filter match | That no items match the criteria | Change or clear the filters |
| Permission or availability | Why content cannot be shown | Request access or contact an administrator |
An empty result is different from a failed request. If the server responds successfully with zero items, show an empty state. If the request fails, show an error state with recovery guidance. Keeping these meanings separate prevents users from trying to fix a problem that does not exist.
Give the message a job
An effective empty state usually contains:
- A short heading that names the situation.
- A sentence that explains what the user can do.
- One primary action that moves the user forward.
- Optional secondary help, such as an example or link.
Use specific language. “No projects yet” tells the user what is missing. “Nothing here” does not. Match the action to the cause:
- First use: “Create project”
- No search results: “Clear filters”
- Permission-limited: “Request access”
- Completed workflow: “Start another task”
Keep the heading and action close together. The user should not need to scan the whole page to understand what to do. Do not add several competing buttons. If two actions are equally important, reconsider whether the screen is combining different jobs.
Lay out the empty state in context
Place the message where the content would normally appear. For a table, keep the table heading and controls visible, then show the empty message in the table area. This preserves context and lets users adjust filters without losing their place.
For a full-page first-use state, center the content in the available area. For a local empty state, use less visual weight so it does not compete with surrounding navigation or controls. Make the primary action easy to find, but do not use oversized illustrations that push the explanation below the fold.
Keep the state accessible
Give the empty message a meaningful heading so screen-reader users can identify the region. Make the action keyboard reachable and give it a descriptive name. Do not communicate the situation through color or an illustration alone.
When filters change, update the empty message in the same region as the results. If the result count is important, announce it politely without moving focus unexpectedly. Move focus only when the user starts a new task, such as opening a creation form.
Represent the cause in code
Model the reason explicitly so the interface cannot accidentally show a first-use message for a filtered search:
type EmptyReason = "first-use" | "filtered" | "permission";
type EmptyState = {
title: string;
body: string;
action: string;
};
function getEmptyState(reason: EmptyReason): EmptyState {
switch (reason) {
case "first-use":
return {
title: "No projects yet",
body: "Create a project to organize your work.",
action: "Create project",
};
case "filtered":
return {
title: "No matching projects",
body: "Try changing or clearing your filters.",
action: "Clear filters",
};
case "permission":
return {
title: "Projects are restricted",
body: "Ask an administrator for access.",
action: "Request access",
};
}
}
console.log(getEmptyState("filtered"));Before release, review each empty cause with realistic content. Check narrow screens, long translations, keyboard navigation, zoom, and screen-reader announcements. Verify that the action works and that returning from the action updates the original screen.
Exercise
A project list is empty because the user searched for “design,” but no project matches. What should the heading and primary action communicate?
Show answer
The heading should say that no projects match the search, and the primary action should let the user clear or change the search.