Skip to content

Empty, loading and error

Download .md

Every list and card has three states besides “full”. Show them in the place where the content would be, at the same size, so the page doesn’t jump.

  • Empty: the collection has nothing yet, or no row matches the filters.
  • Loading: the data is on its way. Show a skeleton in the shape of the content.
  • Error: loading failed. Say what failed and offer a way to try again.
React

Belum ada rilis

Rilis pertamamu akan muncul di sini.

Vue

Belum ada rilis

Rilis pertamamu akan muncul di sini.

A title, one sentence about what will appear, and the one action that fills the space. When filters hide every row, the action clears the filters.

React
Memuat rilis…
Vue
Memuat rilis…

Skeletons in the shape of the rows that are coming, aria-busy="true" on the container, and a sentence for screen readers. Skip the skeleton for loads under about 300 ms.

import { Skeleton } from "@/components/ui/skeleton"
/** Loading: skeletons in the shape of the rows that are coming, and a sentence for screen readers. */
export default function LoadingStateDemo() {
return (
<div aria-busy="true" className="grid w-full max-w-md gap-4 rounded-xl border border-border bg-card p-4">
<span className="sr-only">Memuat rilis…</span>
{[0, 1, 2].map((row) => (
<div key={row} className="flex items-center gap-3" aria-hidden="true">
<Skeleton className="size-10 rounded-md" />
<div className="grid flex-1 gap-2">
<Skeleton className="h-4 w-2/3" />
<Skeleton className="h-3 w-1/3" />
</div>
</div>
))}
</div>
)
}
React
Vue

role="alert", what failed, what to do next, and “Coba lagi”. The message comes from the backend when there is one.

import { RefreshCwIcon, TriangleAlertIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
/** Loading failed: what failed, what to do next, and a way to try again. */
export default function ErrorStateDemo() {
return (
<div
role="alert"
className="flex w-full max-w-md flex-col items-center gap-4 rounded-xl border border-border bg-card px-6 py-10 text-center"
>
<span className="grid size-12 place-items-center rounded-lg bg-destructive-soft text-destructive">
<TriangleAlertIcon className="size-6" />
</span>
<div className="grid gap-1">
<h2 className="text-lg font-semibold">Rilis belum bisa dimuat</h2>
<p className="text-sm text-muted-foreground">Cek koneksimu, lalu coba lagi.</p>
</div>
<Button variant="outline">
<RefreshCwIcon />
Coba lagi
</Button>
</div>
)
}
import { DiscIcon, PlusIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
/** Nothing here yet: what will appear, in one sentence, and the one action that fills it. */
export default function EmptyStateDemo() {
return (
<div className="flex w-full max-w-md flex-col items-center gap-4 rounded-xl border border-dashed border-border px-6 py-10 text-center">
<span className="grid size-12 place-items-center rounded-lg bg-muted text-muted-foreground">
<DiscIcon className="size-6" />
</span>
<div className="grid gap-1">
<h2 className="text-lg font-semibold">Belum ada rilis</h2>
<p className="text-sm text-muted-foreground">Rilis pertamamu akan muncul di sini.</p>
</div>
<Button>
<PlusIcon />
Rilis baru
</Button>
</div>
)
}

Button and the Skeleton that installs with Sidebar.

shadcn_ui has no skeleton widget. Muted boxes with the theme radius do the job. Wrap the error state in Semantics(liveRegion: true).