Components
Empty state
A message with an icon and a next step for when there is no content.
No transactions yet
Payments you send or receive will show up here.
Use EmptyState where a list, table or page has nothing to show yet. Say why it is empty and give one clear next step. Don't use it for errors or loading; those need their own messages.
Installation
pnpm dlx shadcn@latest add https://components.abdulqadirmsingi.com/r/empty-state.json
Usage
import { EmptyState } from "@/components/ui/empty-state";
<EmptyState
title="No transactions yet"
description="Payments you send or receive will show up here."
action={<Button>Request a payment</Button>}
/>Props
EmptyState extends native <div> props (except title) and spreads them on, including ref (React 19).
| Prop | Type | Default | Description |
|---|---|---|---|
| title | ReactNode | – | Short heading. Required. |
| description | ReactNode | – | One sentence: why it is empty and what to do. |
| icon | ReactNode | – | Decorative icon or illustration; hidden from assistive technology. |
| action | ReactNode | – | A button or link for the next step. |
| headingLevel | 2 | 3 | 4 | 5 | 6 | 3 | Heading level, to fit your page's outline. |
Accessibility
- The title is a real heading, so users can find it by heading navigation.
- The icon is decorative and hidden. Don't put essential information only in it.
- It is static content. If a list becomes empty after a user action, move focus somewhere sensible or announce the change.
Tokens used
--control-border, --muted-foreground.
Known limitations
- No illustrations are included; bring your own icon or SVG.
Source
import { type ComponentProps, createElement, type ReactNode } from "react";import { cn } from "@/lib/utils";export interface EmptyStateProps extends Omit<ComponentProps<"div">, "title"> { /** Short heading, e.g. "No transactions yet". */ title: ReactNode; /** One sentence that says why it is empty and what to do. */ description?: ReactNode; /** Decorative icon or illustration. It is hidden from assistive technology. */ icon?: ReactNode; /** A button or link for the next step. */ action?: ReactNode; /** Heading level, so the state fits your page's outline. Defaults to 3. */ headingLevel?: 2 | 3 | 4 | 5 | 6;}/** Shown where a list or page has no content yet. Always say what the user can do next. */export function EmptyState({ title, description, icon, action, headingLevel = 3, className, ...props}: EmptyStateProps) { return ( <div className={cn( "flex flex-col items-center gap-3 rounded-xl border border-dashed border-control-border p-8 text-center", className, )} {...props} > {icon ? ( <div aria-hidden="true" className="text-muted-foreground"> {icon} </div> ) : null} {createElement(`h${headingLevel}`, { className: "text-base font-semibold" }, title)} {description ? <p className="max-w-sm text-sm text-muted-foreground">{description}</p> : null} {action ? <div className="mt-2">{action}</div> : null} </div> );}