Sub topic 5
Writing and laying out an empty state
This chapter assumes you can already tell why a screen is empty. That means telling first use, cleared by the user, no search results, and no access apart from each other, and telling an empty state from loading and error states. It also assumes basic reading knowledge of HTML and TypeScript. Here you will turn each cause into copy and layout that tells people what happened and what to do next.
What an empty state is made of
An empty state is the content that fills the space where data would normally appear. A good one has up to five parts. Only the headline is always required.
| Part | Purpose | Required |
|---|---|---|
| Headline | Says what is missing or what this place is for | Yes |
| Body text | Explains why it is empty or what the user gains by filling it | Usually |
| Primary action | The single most useful next step, as a button or link | When a step exists |
| Secondary action | A help link, an import option, or a way to undo a filter | Optional |
| Illustration or icon | Adds recognition and softens a blank area | Optional |
The cause decides which parts you include. A "no results" state needs a way to change the search. A "no access" state needs an explanation and a way to request access, and it should not offer a "Create" button the user cannot use.
Writing the copy
Headline
The headline answers "what am I looking at?" in plain words. State the fact, or state the purpose of the space. Avoid a headline that only names the problem from the system's point of view.
- Weak: "No data"
- Better: "No projects yet"
- Better for a search:
No results for "invoice 2031"
Echo the user's own input when it helps, such as the search term. That confirms the system understood the request. It also helps people spot a typo.
Body text
The body adds one of two things: the reason, or the benefit. Keep it to one or two short sentences.
- First use: say what the space is for. "Projects group your files, tasks, and teammates in one place."
- Cleared: confirm the good outcome. "You've handled every message. New ones will show up here."
- No results: give a next step. "Check the spelling or try a broader term."
- No access: say who can fix it. "Ask a workspace admin for access."
Do not blame the user ("You haven't created anything"). Do not use filler such as "Oops!" or "Nothing to see here." Filler wastes the one moment when the user is looking for guidance.
Action label
Write the label as a verb plus the object: "Create project", "Import contacts", "Clear filters". Avoid "Click here", "Get started", or "OK", which do not say what happens. The label should match the wording used elsewhere in the product. If the toolbar says "New project", do not call the same action "Add workspace" here.
Offer one primary action. If you give two equally weighted buttons, the user has to decide between them at the moment they know least about the product. Demote alternatives to a text link.
Match the tone to the cause
| Cause | Tone | Example headline |
|---|---|---|
| First use | Welcoming, instructive | "Create your first project" |
| Cleared by user | Brief, positive | "Inbox zero" or "You're all caught up" |
| No results | Neutral, helpful | `No results for "acme"` |
| No access | Clear, respectful | "You don't have access to this page" |
A cheerful tone fits a cleared inbox. It does not fit "no access", where a joke reads as dismissive. Cheerful copy also does not belong in a state that is really a failure. If the list is empty because the request failed, that is an error state, and it needs the treatment from the error chapters.
Mapping cause to content in code
Keeping the copy in one function that is keyed by cause stops teams from reusing a single generic "Nothing here" message. It also makes the content easy to review and translate. The following TypeScript is complete and runs under Node.
type EmptyCause = "first-use" | "cleared" | "no-results" | "no-access";
interface EmptyContent {
headline: string;
body: string;
action?: { label: string; id: string };
}
interface EmptyContext {
cause: EmptyCause;
query?: string;
canCreate: boolean;
}
function emptyContent(ctx: EmptyContext): EmptyContent {
switch (ctx.cause) {
case "first-use":
return {
headline: "No projects yet",
body: "Projects group your files, tasks, and teammates in one place.",
// Only offer creation if this user is allowed to create.
action: ctx.canCreate
? { label: "Create project", id: "create-project" }
: undefined,
};
case "cleared":
return {
headline: "You're all caught up",
body: "New items will show up here.",
};
case "no-results":
return {
headline: `No results for "${ctx.query ?? ""}"`,
body: "Check the spelling or try a broader term.",
action: { label: "Clear search", id: "clear-search" },
};
case "no-access":
return {
headline: "You don't have access to this page",
body: "Ask a workspace admin to grant you access.",
action: { label: "Request access", id: "request-access" },
};
}
}
console.log(emptyContent({ cause: "no-results", query: "acme", canCreate: true }));
console.log(emptyContent({ cause: "first-use", canCreate: false }));Two details matter here. The canCreate flag removes the action for users who lack permission, so the screen never offers something that will fail. And the headline puts the raw query into a string. That is fine for plain text, but when you render it into HTML, insert it as text content and never as markup, or a search term such as <script> becomes an injection risk.
Choosing content by cause
The decision is mostly about the cause, with a few extra checks for filters and permissions.
The order of the checks is deliberate. Permission comes first, because a user who cannot see the data should not get a "create your first item" prompt. The filter check comes before first use, because a filtered list can be empty even when the full collection is not.
Laying out the empty state
Place it where the content would be
Put the empty state in the same container the data would occupy. Keep the page title, toolbar, tabs, and search field in place. If the empty state replaces the whole page, people lose their orientation and cannot reach the search box to change a failed query.
For a table, keep the column headers visible and place the message in a single row beneath them. This keeps the structure of the screen stable, so the layout does not jump when data arrives.
Scale to the container
| Context | Treatment |
|---|---|
| Full page or main panel | Centered block, optional illustration, headline, body, primary button |
| Side panel or card | Smaller icon, shorter text, link-style action |
| Dashboard widget | One line of text and one link; no illustration |
| Table or list row | Single line of text inside the row, with an inline action |
Do not use a large illustration in a small widget. A dashboard with six widgets that each show a 200-pixel picture and a button gives the screen no hierarchy.
Visual hierarchy
Order the content from top to bottom as illustration, headline, body, action. Make the headline the heaviest text. Constrain the body to a readable line length, roughly 40 to 60 characters per line, and center-align short text only. Left-align text that wraps past two or three lines.
Markup
The following HTML shows a full-page empty state. The image is decorative, so it has an empty alt attribute and screen readers skip it. The headline is a real heading, so it appears in the page outline.
<section class="empty-state" aria-labelledby="empty-title">
<img src="empty-folder.svg" alt="" width="120" height="120">
<h2 id="empty-title">No projects yet</h2>
<p>Projects group your files, tasks, and teammates in one place.</p>
<button type="button">Create project</button>
</section>Use a real <button> for an action that changes data, and a link for navigation. Do not make the whole block clickable, because that hides the action from people who scan for buttons.
Edge cases
- Do not flash the empty state during loading. Show it only after the request has succeeded with zero items. Before then, the user sees the loading state, or the empty message appears for a moment and is then replaced by content.
- Filtered lists. Show the active filters and a "Clear filters" action. Without it, the user can believe the whole collection is empty.
- Empty page in a paginated list. If the user deletes the last item on page 3, send them to the last page that still has items. Do not show an empty state for a page that no longer exists.
- Search with suggestions. If your system can offer alternatives, such as a corrected spelling, show them in the body. If it cannot, a plain hint is better than a wrong guess.
- Partial emptiness. One section of a screen can be empty while others have data. Give each section its own empty state, sized for that section, rather than a page-wide message.
- Long text and translation. A translated headline can be 30 to 50 percent longer. Test the layout with long strings, and do not fix the container height.
- Dark mode and contrast. Illustrations designed for a light background can disappear on a dark one. Check both, and keep text at the same contrast ratio as the rest of the interface.
Review checklist
- Does the headline say what is missing or what this space is for?
- Does the copy differ for each cause you identified?
- Is there at most one primary action, labeled with a verb and an object?
- Is the action hidden or replaced when the user lacks permission?
- Do the page chrome, filters, and search stay in place?
- Is the size of the block right for its container?
- Does it appear only after a successful response with zero items?
Exercise
A user types "blue chair" into a product search and gets zero results. Write the headline, the body text, and one action for the empty state. Then name one thing that must stay visible on the page.
Show answer
Headline: No results for "blue chair". Body: "Check the spelling or try a broader term, such as "chair"." Action: "Clear search". The search field must stay visible and editable so the user can change the query without going back. Keeping the filters and page title visible is also correct.
Exercise
A team lead's "Tasks" page shows "Create your first task" with a Create button, but some team members have view-only permission. What is wrong, and how would you change the design?
Show answer
View-only members see an action they cannot use, and a first-use message that implies they should create something. Check permission before choosing the content. For view-only users, show a headline such as "No tasks yet" and a body such as "Tasks added by your team will appear here", and omit the Create button. In code, this means branching on a flag like canCreate before including the action.
Exercise
A user deletes the only item on page 2 of a paginated list. Which empty-state decision applies, and why?
Show answer
Do not show an empty state for page 2. Move the user to the last page that still has items (page 1), because page 2 no longer exists. If the whole collection is now empty, show the "cleared" or "first use" state, depending on your product's rules.