Error empty states
Five failure placeholders driven by semantic tone: a danger-tone server error, a warning-tone offline state, a danger-tone permission wall, a warning-tone timeout and a neutral broken link. Each carries data-tone on the root, is sized, token-driven and renders with default copy and a recovery action.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/empty-errorDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install lucide-reactCopy the source
components/ui/empty-error.tsx"use client"
import type * as React from "react"
import {
CloudOff,
Lock,
RefreshCw,
ServerCrash,
TimerReset,
Unplug,
} from "lucide-react"
import { cn } from "@/lib/utils"
/* Error empty family: 5 error, offline and permission empty states. Every variant drives one semantic tone family (danger / warning / muted) and shows it in the icon badge; its root carries data-tone. Colour comes ONLY from semantic tokens (transparency via color-mix), size = the padding plus icon and text scale. Renders without props too. Static - no motion. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
type Scale = {
root: string
icon: string
badge: string
title: string
description: string
}
const scales: Record<StyledSize, Scale> = {
sm: {
root: "gap-2 p-6",
icon: "size-6",
badge: "size-12",
title: "text-sm",
description: "text-xs",
},
md: {
root: "gap-3 p-8",
icon: "size-8",
badge: "size-16",
title: "text-base",
description: "text-sm",
},
lg: {
root: "gap-3.5 p-10",
icon: "size-10",
badge: "size-20",
title: "text-lg",
description: "text-sm",
},
xl: {
root: "gap-4 p-12",
icon: "size-12",
badge: "size-24",
title: "text-xl",
description: "text-base",
},
}
interface EmptyProps {
className?: string
size?: StyledSize
icon?: React.ReactNode
title?: React.ReactNode
description?: React.ReactNode
action?: React.ReactNode
}
type Tone = "danger" | "warning" | "muted"
/* Ton haritasi: rozet zemini + on-plan rengi + kenar. danger/warning gercek
-soft token'larini kullanir; muted notr yuzeydir. */
const toneBadge: Record<Tone, string> = {
danger:
"bg-danger-soft text-danger-soft-foreground [border-color:color-mix(in_oklab,var(--color-danger)_28%,transparent)]",
warning:
"bg-warning-soft text-warning-soft-foreground [border-color:color-mix(in_oklab,var(--color-warning)_28%,transparent)]",
muted: "bg-muted text-muted-foreground border-border",
}
const rootBase = "flex flex-col items-center justify-center text-center"
const iconBase = "[&_i]:leading-none [&_svg]:size-full"
const retryBtn =
"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border bg-transparent px-4 text-sm font-medium text-foreground outline-none transition-colors duration-(--motion-base) ease-(--motion-ease) hover:bg-[color-mix(in_oklab,var(--color-foreground)_6%,transparent)] focus-visible:ring-[3px] focus-visible:ring-ring/50 motion-reduce:transition-none [&_i]:text-base [&_i]:leading-none [&_svg]:size-4 [&_svg]:shrink-0"
/* Shared shell: a toned badge plus title plus description plus an optional action. */
function ErrorShell({
tone,
fallbackIcon,
className,
size = "md",
icon,
title,
description,
action,
defaultAction,
}: EmptyProps & {
tone: Tone
fallbackIcon: React.ReactNode
defaultAction?: React.ReactNode
}) {
const s = scales[size]
return (
<div
data-slot="styled-empty"
data-tone={tone}
className={cn(rootBase, s.root, className)}
>
<span
aria-hidden="true"
className={cn(
"flex items-center justify-center rounded-full border",
toneBadge[tone],
s.badge
)}
>
<span className={cn(iconBase, s.icon)}>{icon ?? fallbackIcon}</span>
</span>
<p className={cn("font-semibold text-foreground", s.title)}>{title}</p>
{description ? (
<p className={cn("max-w-prose text-muted-foreground", s.description)}>
{description}
</p>
) : null}
{action ?? defaultAction ? (
<div className="mt-2">{action ?? defaultAction}</div>
) : null}
</div>
)
}
/* ErrorEmpty: genel sunucu hatasi, danger tonu + tekrar dene aksiyonu. */
export function ErrorEmpty({
title = "Something went wrong",
description = "We could not load this content. Try again in a moment.",
...props
}: EmptyProps) {
return (
<ErrorShell
tone="danger"
fallbackIcon={<ServerCrash />}
title={title}
description={description}
defaultAction={
<button type="button" data-slot="styled-empty-action" className={retryBtn}>
<RefreshCw />
Try again
</button>
}
{...props}
/>
)
}
/* OfflineEmpty: baglanti yok, warning tonu + yeniden baglan aksiyonu. */
export function OfflineEmpty({
title = "You are offline",
description = "Check your connection. Your changes will sync once you are back online.",
...props
}: EmptyProps) {
return (
<ErrorShell
tone="warning"
fallbackIcon={<CloudOff />}
title={title}
description={description}
defaultAction={
<button type="button" data-slot="styled-empty-action" className={retryBtn}>
<RefreshCw />
Reconnect
</button>
}
{...props}
/>
)
}
/* DeniedEmpty: yetki yok, danger tonu + erisim isteme aksiyonu. */
export function DeniedEmpty({
title = "You do not have access",
description = "Ask a workspace admin to grant you permission to view this page.",
...props
}: EmptyProps) {
return (
<ErrorShell
tone="danger"
fallbackIcon={<Lock />}
title={title}
description={description}
defaultAction={
<button type="button" data-slot="styled-empty-action" className={retryBtn}>
<Lock />
Request access
</button>
}
{...props}
/>
)
}
/* TimeoutEmpty: istek zaman asimi, warning tonu + yeniden yukle aksiyonu. */
export function TimeoutEmpty({
title = "This is taking too long",
description = "The request timed out before it finished. Reload to give it another go.",
...props
}: EmptyProps) {
return (
<ErrorShell
tone="warning"
fallbackIcon={<TimerReset />}
title={title}
description={description}
defaultAction={
<button type="button" data-slot="styled-empty-action" className={retryBtn}>
<RefreshCw />
Reload
</button>
}
{...props}
/>
)
}
/* BrokenEmpty: kirik/eksik kaynak, muted notr ton, aksiyon yok. */
export function BrokenEmpty({
title = "This link is broken",
description = "The page you are looking for was moved or deleted.",
...props
}: EmptyProps) {
return (
<ErrorShell
tone="muted"
fallbackIcon={<Unplug />}
title={title}
description={description}
{...props}
/>
)
}Manual installs skip the @ai2/tokens theme, so add the token CSS from the theming guide or the tone colors will be missing.
Variations
5 takes on the same idea. Each is its own export, and every one accepts a size prop (sm, md, lg, xl) aligned to the base Button scale.
Error
A danger-tone server error with a retry action.
Something went wrong
We could not load this content. Try again in a moment.
import { ErrorEmpty } from "@/components/ui/empty-error"
<ErrorEmpty />Something went wrong
We could not load this content. Try again in a moment.
Something went wrong
We could not load this content. Try again in a moment.
Something went wrong
We could not load this content. Try again in a moment.
Something went wrong
We could not load this content. Try again in a moment.
Offline
A warning-tone offline state with a reconnect action.
You are offline
Check your connection. Your changes will sync once you are back online.
import { OfflineEmpty } from "@/components/ui/empty-error"
<OfflineEmpty />You are offline
Check your connection. Your changes will sync once you are back online.
You are offline
Check your connection. Your changes will sync once you are back online.
You are offline
Check your connection. Your changes will sync once you are back online.
You are offline
Check your connection. Your changes will sync once you are back online.
Denied
A danger-tone permission wall with a request-access action.
You do not have access
Ask a workspace admin to grant you permission to view this page.
import { DeniedEmpty } from "@/components/ui/empty-error"
<DeniedEmpty />You do not have access
Ask a workspace admin to grant you permission to view this page.
You do not have access
Ask a workspace admin to grant you permission to view this page.
You do not have access
Ask a workspace admin to grant you permission to view this page.
You do not have access
Ask a workspace admin to grant you permission to view this page.
Timeout
A warning-tone timeout with a reload action.
This is taking too long
The request timed out before it finished. Reload to give it another go.
import { TimeoutEmpty } from "@/components/ui/empty-error"
<TimeoutEmpty />This is taking too long
The request timed out before it finished. Reload to give it another go.
This is taking too long
The request timed out before it finished. Reload to give it another go.
This is taking too long
The request timed out before it finished. Reload to give it another go.
This is taking too long
The request timed out before it finished. Reload to give it another go.
Broken
A neutral muted state for a broken or missing link.
This link is broken
The page you are looking for was moved or deleted.
import { BrokenEmpty } from "@/components/ui/empty-error"
<BrokenEmpty />This link is broken
The page you are looking for was moved or deleted.
This link is broken
The page you are looking for was moved or deleted.
This link is broken
The page you are looking for was moved or deleted.
This link is broken
The page you are looking for was moved or deleted.
ai2 Error empty states: 5 styled variations on the token system
The ai2 Error empty states are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around error, offline and permission empty states driven by semantic tone. They are free and MIT licensed, and every color comes from a semantic token, so they theme with the rest of ai2 in light and dark.
Motion runs on framer-motion: these are static; no motion library work is required. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, there is no motion to reduce.
What is in the ai2 Error empty states?
5 exports in one file: Error, Offline, Denied, Timeout and Broken. Each renders a native button and takes a size prop (sm, md, lg, xl) aligned to the base Button. They are separate from the base Button on purpose: the base keeps its clean variant, tone and size axes, while the styled layer carries the effects.
You own the file. Copy the one category file and you have all 5 variations, with no runtime dependency on ai2 itself.
Why use it
- On-system by construction: Every color resolves to an ai2 semantic token, so the buttons follow your theme in light and dark with no extra work.
- Effect without the sprawl: The decorations live in a dedicated styled file, so the base Button keeps its clean, predictable API.
- Accessible and honest: Each renders a real button element, keeps a visible focus ring, and respects prefers-reduced-motion.
Features
- Token-driven color: No hardcoded hex or oklch; the look recolors with your theme tokens.
- framer-motion: these are static; no motion library work is required.
- Reduced-motion aware: Under prefers-reduced-motion, there is no motion to reduce.
- Size aligned to the base: Every variation takes sm, md, lg and xl matching the base Button height scale, so styled and base buttons line up in a row.
Production tips
- Use it for emphasis, not everywhere: Styled buttons draw the eye. Reserve them for the one action you want people to take on a screen, and use the base Button for the rest.
- Keep labels as verbs: The decoration adds weight, so a clear action label keeps the button scannable.
- Pick one variation per surface: The variations share a family; using two different ones in the same view competes for attention.
Works with the rest of ai2
The Error empty states sit alongside the base Button and the rest of the @ai2 registry. They share the same token file, so a styled action next to a base button or a badge stays visually consistent in both modes.