Skip to content
Design System
GitHub

One contract for what a data region shows while it loads, when it is empty, failed, forbidden, out of date or ready.

Devices

This did not load

This did not load

Too many requests in a short time. Wait a minute, then try again.Code: RATE_LIMITED

Error

Install
npx shadcn add @syncrobotic/data-state

Also installs: lucide-react@^1, @syncrobotic/cn, @syncrobotic/skeleton, @syncrobotic/button, @syncrobotic/empty-state

Overview

When to use

  • A card, table or panel filled from a server: devices, API keys, members, a usage chart.
  • A list whose refresh can fail while the last page is still worth reading (stale).
  • A region the viewer may not read inside a page they may open (forbidden).

Use something else

  • A whole page that cannot open: the status-pages block (not found, no access, error, offline).
  • A condition on the page that is not about loading, true for a while: Alert or Banner.
  • An empty place with no fetch behind it: Empty state on its own.

Which one: DataState, EmptyState, Skeleton, Spinner, status pages or Banner

More examples

States and real uses. Each example is also a Storybook story and a visual regression test.

Stale

Empty

Loading

Forbidden

Inline

Zh tw

Usage rules

  • Every region that fetches goes through it: a card, a table, a panel. Pick the state with dataStateOf from what the fetch knows, so a page never invents its own order of checks.
  • Empty only when the server's total is 0, never items.length of a page. A search or filter with no match is empty with an action that clears it, not an error.
  • An error's copy comes from its code: pass the envelope's { code, message } and add a sentence per code to labels.errors. The message is for logs; it is never shown or parsed. An unknown code falls back to the general sentence, with the code under it for support.
  • A refetch that fails with data in hand is stale, not an error: keep the content, say how old it is (updatedAt) and offer Try again. Grey stays grey while it is fresh; the warning tint is for out of date.
  • Forbidden is for the viewer's own tenant: say which permission is missing and who grants it. A record in another tenant, or one that does not exist, is a not-found page, so its existence is never confirmed.
  • Loading says what is coming in one line and shapes the bones like the content (skeleton); keep the region's heading and count outside it, as they are known first.

Changelog

  • 0.64.02026-12-01Formatted with Prettier (class order sorted); the code is unchanged.
  • 0.63.12026-11-30Its screen-reader status line stays inside the region; positioned from the page, it made a scrolling app shell's page taller by the region's depth, as blank space.
  • 0.63.02026-11-30A skeleton of your own lays itself out edge to edge; only the default bones sit inset, so a custom skeleton lines up with the heading above it.

How to upgrade