Data State
interlace-ui/data-stateFreeComponent
The single conditional swap point for a data surface, and the place the design system says what an ABSENCE is.
Install it
npx shadcn@latest add https://ds.interlace.tools/r/data-state.jsonSource
1import * as React from 'react';23// @interlace/data-state v1.1.0 — Interlace design system.4// Docs, props and live preview: https://ds.interlace.tools/c/data-state5// What changed since: https://ds.interlace.tools/c/data-state#history6// Generated banner — keep it, the upgrade diff reads this version.78/**9 * @interlace/ui — DataState10 *11 * The single conditional swap point for a data surface, and the place the12 * design system says what an ABSENCE is.13 *14 * It started as the four-state ladder every fetch site otherwise re-writes:15 *16 * {isLoading ? <Skeleton /> :17 * error ? <ErrorState /> :18 * !data?.length ? <EmptyState /> :19 * <ListOfThings items={data} />}20 *21 * becomes:22 *23 * <DataState24 * loading={isLoading}25 * error={error}26 * empty={!data?.length}27 * skeletonVariant="article-card"28 * emptyState={<EmptyState>No articles yet</EmptyState>}29 * >30 * {() => <ListOfThings items={data!} />}31 * </DataState>32 *33 * The render-prop child only runs when the surface has real data, so consumers34 * can `data!.map(...)` inside without a null guard.35 *36 * ## Four states was not enough, and the missing five were the interesting ones37 *38 * Six published artifacts were catalogued for phase 10, and every one of them39 * had hand-rolled a vocabulary this component did not have. Not decoration —40 * distinctions that change what the reader is entitled to conclude:41 *42 * - **`not-counted`** — no run happened. Drawn as a diagonal hatch, because43 * a run that returned zero and a run that never happened must not look the44 * same. This is the state `charts/scale.ts` has always encoded as `null`.45 * - **`not-applicable`** — the metric has no meaning for this subject. It46 * recedes: it was never going to have a value, so it should not compete47 * with the cells that do.48 * - **`partial`** — some sources did not report. Every count below is a49 * FLOOR, not a total. Ranked above `truncated` because it is invisible:50 * a reader can see a list stop, but cannot see a source that never replied.51 * - **`truncated`** — the list is cut. Never a denominator.52 * - **`first-measurement`** — a reading exists, a prior does not. This is the53 * one absence that gets the accent colour and a dashed outline, because it54 * is the only one a reader can act on. It exists so a metric with no prior55 * shows "first measurement" instead of `+0%`.56 *57// … truncated
More from interlace-ui
All 140 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| A11y Startera11y-starter | interlace-ui | Components | Free | no deps | |
| Accordionaccordion | interlace-ui | Components | Free | no deps | |
| Alertalert | interlace-ui | Components | Free | no deps | |
| Alert Dialogalert-dialog | interlace-ui | Components | Free | no deps | |
| Animated Gradient Textanimated-gradient-text | interlace-ui | Components | Free | no deps | |
| Animated Grid Patternanimated-grid-pattern | interlace-ui | Components | Free | no deps | |
| Animated Listanimated-list | interlace-ui | Components | Free | no deps | |
| Article Cardarticle-card | interlace-ui | Components | Free | no deps |
