Loading, empty & error
Loading, empty, failed and loaded each look different and say so. Nobody should have to guess which one a blank area is.
Every surface that loads has four states, and each one looks like itself: a skeleton while it loads, a sentence and a next step when it is empty, the error and a retry when it failed, and then the content.
Step through the tabs: the skeleton has the rows' shape, the empty list says what a note is and offers New note, and the failure names what failed. Press Retry there: it is disabled while the read runs, and the notes arrive.
Do and don't#
Draw a Skeleton in the shape of the content that is coming, so the page does not jump when it
arrives.
Cover the whole page with a spinner while one list loads: everything else on it was already usable.
No notes yet
A note is markdown, kept in this tab. Start one with a # heading.
Say what would be here and how to get some: "No notes yet", a line on what a note is, and a New note button.
No data
Leave "No data" in an empty box. It reads the same as a failed load or a filter that hides everything.
The states#
| State | Show | Component |
|---|---|---|
| Loading, first time | Placeholders in the shape of the content | Skeleton |
| Loading, short (under about 500ms) | Nothing new: the skeleton waits that long before it fades in, so a fast load does not flash | DelayedSkeleton |
| Loaded, nothing there | What would be here, why it is empty, and the action that fills it | EmptyState |
| Loaded, nothing matches a filter | That the filter hid everything, and a way to clear it | EmptyState |
| Loaded, but not set up yet | What is missing, and the action that sets it up | EmptyState |
| No permission to see it | What is held back, and how to get access when there is a way | EmptyState |
| Failed, nothing to show, in a line or a list | The error, the server's own words in detail, and Retry | LoadFailure |
| Failed, nothing to show, filling a pane or a page | What failed as the title, the server's own words below it, and Retry | LoadFailure with orientation |
| Refresh failed, older data still shown | That the data is stale, the server's own words in detail, and Retry | RefreshFailure |
| Loading more of a list | A Load more button that turns into its own failure and retry | LoadMoreFooter with usePagedAppend |
Retry design
The fetch task gives up on the first network error, and most of the failures in CI last week were a single dropped connection.
The first note answers in 0.2 s, before its skeleton would show: the pane is blank that long, then
holds the note. The second takes 2 s: its skeleton fades in after 500ms
and holds the note's place until it arrives. The wait is DelayedSkeleton's own: the Skeletons
inside it are laid out as the note will be, and nothing times them.
When one skeleton gives way to another for the same wait, as a route's does to the page's own once
the page has mounted, wrap the place in a DelayedSkeletonProvider. The page's skeleton then
carries on the route's wait: it fades in once, and one already shown stays shown, rather than
blinking out and waiting all over again.
An empty state that comes from a filter is not the same as an empty list. "No notes yet" invites writing one; "No notes match" invites clearing the filter.
Add #release to #ci: no note has both, and the list says so with Clear filter rather than "No notes yet".
Filling the space or sharing it#
An EmptyState that is the only thing in its pane, list or page stands vertical, centred in the
space. One that shares its space with other content, such as a section of a settings page, a
sidebar group or a card among other cards, lies on one row with orientation="horizontal", so it
takes no more height than the content it stands in for.
An icon and a title are a whole empty state. Add the description only when the title leaves the reader asking why, and the action only when there is a next step.
The failed section is a LoadFailure with orientation="horizontal": it keeps the same row as
the empty ones and says what failed in its title. The red is not what tells
it apart from the empty sections: the title and Retry do that.
Press Refresh: the first one fails, and the conversations already shown stay under the warning. Press Load more twice: the second page fails in place of the button, and its Retry loads only that page.
Files a document names#
A file that a document links or embeds looks one way while the app looks it up, another when there is no such file, and another once it was deleted, so the reader knows before clicking whether it will open.
Read the appendix before tagging; the old plan it replaced is gone. The new mark: sprite.png
The first logo, logo.svg, is not coming back.
Press Reload and the note asks for its files again. The links are chips at once; the picture, the card's lines and the comparison's sides show their placeholders a moment later. Then the answers arrive: the files that exist draw, the old plan is not found, and the first logo says it was deleted.
| The app's lookup | A link | A picture | An embedded file |
|---|---|---|---|
| Still running | The chip it will be, a plain link to the address | Nothing at first, then PendingAttachmentMark | The card, named by the address, over ContentLoading |
| Found | AttachmentLink, which opens the viewer | The picture | The card, its size and its contents |
| No such file | MissingAttachmentMark | MissingAttachmentMark | MissingAttachmentMark |
| Deleted | DeletedAttachmentMark | DeletedAttachmentMark | DeletedAttachmentMark |
A file found to be one no renderer draws in a document, such as a PDF behind an address whose name
reads like a picture or a text file, is an AttachmentLink wherever it was embedded, never a
broken picture.
A link is the same chip whether the lookup has answered or not; only what a click does changes, so nothing on the line moves when the answer comes. A picture and a card's body wait as Loading, short says above: a lookup that answers quickly never shows a placeholder. Looking a file up, fetching the renderer that draws it and reading its text are one wait to the reader, so a card draws the same lines for all three, and they fade in once, however the wait passes from one to the next.
An app tells the plugins what it knows through useSource, beside the resolve that reads the
address:
- While the lookup runs, return
undefined. - Return
nullonly when the app knows there is no such file. A file the reader may not see, or one in another place the app does not look, is not a missing file. - When the lookup fails, or there is nothing more to know, return the source
useSourcewas handed: the file is drawn as its address says, and an address that works keeps working. - Give a text file its
size. A card does not load text of unknown size until the reader asks.
Retrying#
A failure does not recover by itself, so its way out is a control, not a promise to try again
later. Retry reruns only the read that failed, and is disabled while it runs. When an overlay
opened from a failed surface closes, send focus to its Retry through retryRef: the overlay's
own trigger may be gone. LoadFailure wires both in every orientation, so a failure that fills
a pane is a LoadFailure too, not an EmptyState with a Retry of its own.
A renderer whose code does not arrive (the reader went offline, or a new release replaced the
chunk an open page asked for) is one such failure: a LoadFailure takes its place, and under it
the text stays readable as written, or the file stays a download link, so the content is never
lost behind the failure.
On each platform#
Desktop & pointer#
- Keep what loaded already in place while the next page or a refresh loads; replace only what changed.
- A failure on one line (
LoadFailure,RefreshFailure, the Load more footer's) puts the raw error in itstitle, so hovering it shows the detail.
Touch#
- Hover shows nothing on a phone, so an error message names what failed in words, not only in a tooltip.
- Prefer a Load more button at the end of a list to loading on scroll alone: a thumb flicking past the end should not start requests it did not ask for, and a failure needs a place to sit.
In the demos
- ReleasesPick a place in the sidebar for skeleton rows in the list's own columns. Search for what no release has for No releases match with Clear filters, and in Services billing's status page fails with Retry.
- GalleryFilter for a name no component has: the sheet says No components match and offers Clear filter, rather than leaving an empty page.
- AdminUsage and billing's invoices fail on their first load, with Retry. Pick Field notes in the workspace menu for a new workspace's set-up list and empty audit log, and Design guild for billing held back by its owner.
- TasksFilter until nothing is left: No tasks match, with Clear filters. Scroll to the end, and Load more fetches the next page and says how many remain.
- MailOpen an empty folder for what it holds and how mail gets there, search for a word no mail has for the filter's own empty state, and scroll to the end for Load more.
- NotesFilter for a word no note has: No notes match, with Clear filter. Delete every note, and the empty notebook says what a note is, with New note.
- Pull requestReload the page: each log, diff and the comment box shows a skeleton in its shape until it is drawn, so nothing jumps.
- RepositoryOpen scripts/ for an empty folder, docs/old-guide.md for a file deleted from disk, and filter for a word no path holds.
- Binary inspectorPick another sample: skeleton rows hold its place while it loads. Should the fetch fail, the error takes that place, with Retry.