Empty State
A React empty state component with shadcn/ui's Empty API — icon tile, title, description and actions on a quiet dashed surface — plus an animated empty state block with a floating illustration, drifting icons and a staggered entrance built with Motion.
- shadcn API
- Server Component friendly
- Motion block
- prefers-reduced-motion
Your inbox is empty
New messages from your team and integrations will land here.
"use client";
import { Plus } from "lucide-react";
import { Button } from "@/components/ui/button";
import { AnimatedEmpty } from "@/components/dusk/empty/animated-empty";
export default function AnimatedEmptyDemo() {
return (
<AnimatedEmpty
className="w-full max-w-md"
title="Your inbox is empty"
description="New messages from your team and integrations will land here."
>
<Button>
<Plus />
Compose
</Button>
<Button variant="ghost">Invite teammates</Button>
</AnimatedEmpty>
);
}Installation
$ npx shadcn@latest add https://duskui.com/r/empty.json1. Install the dependencies.
npm install class-variance-authority2. Copy the source into
components/ui/empty.tsx.empty.tsx import * as React from "react"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@/lib/utils"; /** * DuskUI Empty — an empty state for lists, tables, search results and inboxes. * * Same parts and data-slot attributes as shadcn/ui's Empty (Empty, * EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription, EmptyContent) plus: * - A quiet dashed outline for dark surfaces. * - `EmptyMedia variant="icon"`: a neutral tile with a muted icon. * `variant="default"` leaves your illustration untouched. * - `outline={false}` drops the dashed border to sit inside a card. * CSS only, so it works in Server Components. */ function Empty({ className, outline = true, ...props }: React.ComponentProps<"div"> & { /** Draw the dashed border. Turn off when the empty state sits inside a card. */ outline?: boolean; }) { return ( <div data-slot="empty" className={cn( "relative isolate flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-xl p-6 text-center text-balance md:p-12", outline && "border border-dashed", className )} {...props} /> ); } /** Groups the media, title and description. */ function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="empty-header" className={cn("flex max-w-sm flex-col items-center gap-2 text-center", className)} {...props} /> ); } const emptyMediaVariants = cva( "relative mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0", { variants: { variant: { default: "bg-transparent", icon: [ "size-10 rounded-lg border bg-muted text-foreground", "[&_svg:not([class*='size-'])]:size-5", ], }, }, defaultVariants: { variant: "default" }, } ); /** The icon or illustration. Use `variant="icon"` for a single icon in a tile. */ function EmptyMedia({ className, variant = "default", ...props }: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>) { return ( <div data-slot="empty-icon" data-variant={variant} className={cn(emptyMediaVariants({ variant, className }))} {...props} /> ); } /** The headline. A `<div>` like shadcn — nest an `<h2>`/`<h3>` when it belongs in the page outline. */ function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="empty-title" className={cn("text-lg font-medium tracking-tight", className)} {...props} /> ); } /** Supporting text. Links inside are underlined and turn mint on hover. */ function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) { return ( <p data-slot="empty-description" className={cn( "text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-foreground", className )} {...props} /> ); } /** Actions or extra content under the header, e.g. buttons or a search field. */ function EmptyContent({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="empty-content" className={cn("flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance", className)} {...props} /> ); } export { Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent, EmptyMedia, emptyMediaVariants };
Adds components/ui/empty.tsx with the same parts as shadcn's Empty, plus an outline prop. CSS only.
Usage
import { FolderPlus } from "lucide-react"
import { Button } from "@/components/ui/button"
import {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@/components/ui/empty"
export function NoProjects() {
return (
<Empty>
<EmptyHeader>
<EmptyMedia variant="icon">
<FolderPlus />
</EmptyMedia>
<EmptyTitle>No projects yet</EmptyTitle>
<EmptyDescription>Create your first project to get started.</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button>Create project</Button>
</EmptyContent>
</Empty>
)
}Examples
Default
EmptyMedia variant="icon" puts a single icon in a small neutral tile. The surface has a quiet dashed outline.
Create your first project to start shipping, or import one from GitHub.
import { FolderPlus, Upload } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@/components/ui/empty";
export default function EmptyBasicDemo() {
return (
<Empty className="max-w-md">
<EmptyHeader>
<EmptyMedia variant="icon">
<FolderPlus />
</EmptyMedia>
<EmptyTitle>No projects yet</EmptyTitle>
<EmptyDescription>
Create your first project to start shipping, or import one from GitHub.
</EmptyDescription>
</EmptyHeader>
<EmptyContent className="flex-row justify-center gap-2">
<Button>Create project</Button>
<Button variant="outline">
<Upload />
Import
</Button>
</EmptyContent>
</Empty>
);
}No results
Inside a card or panel, pass outline={false} to drop the border. Links in the description are underlined and brighten on hover.
Check the spelling or try a broader term. You can also browse all components.
"use client";
import * as React from "react";
import { SearchX } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@/components/ui/empty";
export default function EmptySearchDemo() {
const [query, setQuery] = React.useState("date range picker");
return (
<div className="w-full max-w-md rounded-xl border bg-card/40">
<div className="border-b p-3">
<Input
type="search"
aria-label="Search components"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Search components…"
/>
</div>
<Empty outline={false} className="py-10">
<EmptyHeader>
<EmptyMedia variant="icon">
<SearchX />
</EmptyMedia>
<EmptyTitle>No results{query ? ` for “${query}”` : ""}</EmptyTitle>
<EmptyDescription>
Check the spelling or try a broader term. You can also <a href="#">browse all components</a>.
</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button variant="outline" size="sm" onClick={() => setQuery("")}>
Clear search
</Button>
</EmptyContent>
</Empty>
</div>
);
}Blocks
Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.
Animated Empty
A floating tile holds your icon while up to three satellite icons drift slowly around it. The title, description and actions rise in one after another when the block scrolls into view. Pass any lucide icons; children become the action row.
Your inbox is empty
New messages from your team and integrations will land here.
"use client";
import { Plus } from "lucide-react";
import { Button } from "@/components/ui/button";
import { AnimatedEmpty } from "@/components/dusk/empty/animated-empty";
export default function AnimatedEmptyDemo() {
return (
<AnimatedEmpty
className="w-full max-w-md"
title="Your inbox is empty"
description="New messages from your team and integrations will land here."
>
<Button>
<Plus />
Compose
</Button>
<Button variant="ghost">Invite teammates</Button>
</AnimatedEmpty>
);
}$ npx shadcn@latest add https://duskui.com/r/animated-empty.json1. Install the dependencies.
npm install motion lucide-react class-variance-authority2. Copy the source into
components/dusk/empty/animated-empty.tsx.animated-empty.tsx "use client"; import * as React from "react"; import { FileText, Inbox, Search, Sparkles, type LucideIcon } from "lucide-react"; import { motion, useReducedMotion, type Variants } from "motion/react"; import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from "@/components/ui/empty"; import { cn } from "@/lib/utils"; export interface AnimatedEmptyProps extends Omit<React.ComponentProps<typeof Empty>, "title"> { /** The main icon in the floating tile. */ icon?: LucideIcon; /** Up to three small icons that drift around the tile. Pass `[]` for none. */ satellites?: LucideIcon[]; title: React.ReactNode; description?: React.ReactNode; /** Heading level for the title, so it fits your page outline. */ titleAs?: "h2" | "h3" | "h4" | "p"; /** Actions under the text, usually one or two Buttons. */ children?: React.ReactNode; } // Where the satellites sit around the tile, and how each one drifts. const orbit = [ { className: "-top-3 -left-9", drift: { x: [0, -1, 0], y: [0, -3, 0], rotate: [-8, -6, -8] }, duration: 6 }, { className: "-right-10 top-1", drift: { x: [0, 1, 0], y: [0, 3, 0], rotate: [8, 10, 8] }, duration: 7 }, { className: "-bottom-4 -left-4", drift: { x: [0, -1, 0], y: [0, 2, 0], rotate: [4, 2, 4] }, duration: 5.5 }, ]; const container: Variants = { hidden: {}, show: { transition: { staggerChildren: 0.08, delayChildren: 0.05 } }, }; /** * An empty state with a floating illustration. A tile holding your icon * floats gently while small satellite icons drift slowly around it; the * title, description and actions rise in one after * another. Built on the DuskUI Empty parts. Under reduced motion everything * simply fades in and stays still. */ export function AnimatedEmpty({ icon: Icon = Inbox, satellites = [Search, FileText, Sparkles], title, description, titleAs: Title = "h3", className, children, ...props }: AnimatedEmptyProps) { const reduceMotion = useReducedMotion() ?? false; // The hidden state is the same either way, so server and client HTML match; // under reduced motion only the opacity animates. const item: Variants = { hidden: { opacity: 0, y: 8 }, show: { opacity: 1, y: 0, transition: reduceMotion ? { opacity: { duration: 0.3 }, y: { duration: 0 } } : { duration: 0.35, ease: "easeOut" }, }, }; return ( <Empty className={cn("overflow-hidden", className)} {...props}> <motion.div variants={container} initial="hidden" whileInView="show" viewport={{ once: true, amount: 0.4 }} className="flex flex-col items-center gap-6" > <EmptyHeader> <motion.div variants={item}> <EmptyMedia className="mb-6 size-24"> {/* Floating tile */} <motion.span aria-hidden className={cn( "relative grid size-16 place-items-center rounded-2xl border border-white/10 bg-card text-foreground shadow-md" )} initial={{ y: 0 }} animate={reduceMotion ? { y: 0 } : { y: [0, -3, 0] }} transition={{ duration: 5, repeat: Infinity, ease: "easeInOut" }} > <Icon className="size-7" /> </motion.span> {/* Satellites */} {satellites.slice(0, 3).map((Satellite, index) => { const spot = orbit[index]; return ( <motion.span key={index} aria-hidden className={cn( "absolute grid size-8 place-items-center rounded-lg border border-white/10 bg-card text-muted-foreground shadow-sm", spot.className )} initial={{ rotate: spot.drift.rotate[0] }} animate={reduceMotion ? { rotate: spot.drift.rotate[0] } : spot.drift} transition={{ duration: spot.duration, repeat: Infinity, ease: "easeInOut", delay: index * 0.4 }} > <Satellite className="size-4" /> </motion.span> ); })} </EmptyMedia> </motion.div> <motion.div variants={item}> <EmptyTitle> <Title className="text-lg font-medium tracking-tight">{title}</Title> </EmptyTitle> </motion.div> {description && ( <motion.div variants={item}> <EmptyDescription>{description}</EmptyDescription> </motion.div> )} </EmptyHeader> {children && ( <motion.div variants={item} className="w-full"> <EmptyContent className="mx-auto flex-row flex-wrap justify-center gap-2">{children}</EmptyContent> </motion.div> )} </motion.div> </Empty> ); }
| Prop | Type | Default | Description |
|---|---|---|---|
| title | ReactNode | — | The headline. Required. |
| description | ReactNode | — | Supporting text. |
| icon | LucideIcon | Inbox | Icon in the floating tile. |
| satellites | LucideIcon[] | [Search, FileText, Sparkles] | Up to three drifting icons. [] for none. |
| titleAs | "h2" | "h3" | "h4" | "p" | "h3" | Heading level of the title, to fit your page outline. |
| children | ReactNode | — | Actions under the text, usually Buttons. |
| outline | boolean | true | Dashed border (from Empty). |
Custom illustration
Swap the icons to fit the moment — a rocket with clouds and bolts for an empty deployments list — and set titleAs so the heading level matches where it sits.
No deployments yet
Push to your main branch or deploy from the CLI and your first build will show up here.
"use client";
import { Bell, Cloud, Rocket, Zap } from "lucide-react";
import { Button } from "@/components/ui/button";
import { AnimatedEmpty } from "@/components/dusk/empty/animated-empty";
export default function AnimatedEmptyCustomDemo() {
return (
<AnimatedEmpty
className="w-full max-w-md"
icon={Rocket}
satellites={[Cloud, Zap, Bell]}
title="No deployments yet"
titleAs="h4"
description="Push to your main branch or deploy from the CLI and your first build will show up here."
>
<Button>Deploy now</Button>
</AnimatedEmpty>
);
}$ npx shadcn@latest add https://duskui.com/r/animated-empty.json1. Install the dependencies.
npm install motion lucide-react class-variance-authority2. Copy the source into
components/dusk/empty/animated-empty.tsx.animated-empty.tsx "use client"; import * as React from "react"; import { FileText, Inbox, Search, Sparkles, type LucideIcon } from "lucide-react"; import { motion, useReducedMotion, type Variants } from "motion/react"; import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from "@/components/ui/empty"; import { cn } from "@/lib/utils"; export interface AnimatedEmptyProps extends Omit<React.ComponentProps<typeof Empty>, "title"> { /** The main icon in the floating tile. */ icon?: LucideIcon; /** Up to three small icons that drift around the tile. Pass `[]` for none. */ satellites?: LucideIcon[]; title: React.ReactNode; description?: React.ReactNode; /** Heading level for the title, so it fits your page outline. */ titleAs?: "h2" | "h3" | "h4" | "p"; /** Actions under the text, usually one or two Buttons. */ children?: React.ReactNode; } // Where the satellites sit around the tile, and how each one drifts. const orbit = [ { className: "-top-3 -left-9", drift: { x: [0, -1, 0], y: [0, -3, 0], rotate: [-8, -6, -8] }, duration: 6 }, { className: "-right-10 top-1", drift: { x: [0, 1, 0], y: [0, 3, 0], rotate: [8, 10, 8] }, duration: 7 }, { className: "-bottom-4 -left-4", drift: { x: [0, -1, 0], y: [0, 2, 0], rotate: [4, 2, 4] }, duration: 5.5 }, ]; const container: Variants = { hidden: {}, show: { transition: { staggerChildren: 0.08, delayChildren: 0.05 } }, }; /** * An empty state with a floating illustration. A tile holding your icon * floats gently while small satellite icons drift slowly around it; the * title, description and actions rise in one after * another. Built on the DuskUI Empty parts. Under reduced motion everything * simply fades in and stays still. */ export function AnimatedEmpty({ icon: Icon = Inbox, satellites = [Search, FileText, Sparkles], title, description, titleAs: Title = "h3", className, children, ...props }: AnimatedEmptyProps) { const reduceMotion = useReducedMotion() ?? false; // The hidden state is the same either way, so server and client HTML match; // under reduced motion only the opacity animates. const item: Variants = { hidden: { opacity: 0, y: 8 }, show: { opacity: 1, y: 0, transition: reduceMotion ? { opacity: { duration: 0.3 }, y: { duration: 0 } } : { duration: 0.35, ease: "easeOut" }, }, }; return ( <Empty className={cn("overflow-hidden", className)} {...props}> <motion.div variants={container} initial="hidden" whileInView="show" viewport={{ once: true, amount: 0.4 }} className="flex flex-col items-center gap-6" > <EmptyHeader> <motion.div variants={item}> <EmptyMedia className="mb-6 size-24"> {/* Floating tile */} <motion.span aria-hidden className={cn( "relative grid size-16 place-items-center rounded-2xl border border-white/10 bg-card text-foreground shadow-md" )} initial={{ y: 0 }} animate={reduceMotion ? { y: 0 } : { y: [0, -3, 0] }} transition={{ duration: 5, repeat: Infinity, ease: "easeInOut" }} > <Icon className="size-7" /> </motion.span> {/* Satellites */} {satellites.slice(0, 3).map((Satellite, index) => { const spot = orbit[index]; return ( <motion.span key={index} aria-hidden className={cn( "absolute grid size-8 place-items-center rounded-lg border border-white/10 bg-card text-muted-foreground shadow-sm", spot.className )} initial={{ rotate: spot.drift.rotate[0] }} animate={reduceMotion ? { rotate: spot.drift.rotate[0] } : spot.drift} transition={{ duration: spot.duration, repeat: Infinity, ease: "easeInOut", delay: index * 0.4 }} > <Satellite className="size-4" /> </motion.span> ); })} </EmptyMedia> </motion.div> <motion.div variants={item}> <EmptyTitle> <Title className="text-lg font-medium tracking-tight">{title}</Title> </EmptyTitle> </motion.div> {description && ( <motion.div variants={item}> <EmptyDescription>{description}</EmptyDescription> </motion.div> )} </EmptyHeader> {children && ( <motion.div variants={item} className="w-full"> <EmptyContent className="mx-auto flex-row flex-wrap justify-center gap-2">{children}</EmptyContent> </motion.div> )} </motion.div> </Empty> ); }
API Reference
Same parts as shadcn/ui: Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription and EmptyContent. Each forwards the props of its element.
| Prop | Type | Default | Description |
|---|---|---|---|
| outline | boolean | true | Empty. Dashed border. Turn off inside cards. |
| variant | "default" | "icon" | "default" | EmptyMedia. icon wraps a single icon in a tile; default leaves your illustration as is. |
Accessibility
EmptyTitleis a<div>like shadcn's; nest a heading inside when the empty state belongs in the page outline. Animated Empty renders one for you (titleAs).- Illustrations and decorative icons are aria-hidden, so screen readers hear only the title, description and actions.
- When an empty state replaces results after a search or filter, put its text in a live region (role="status") so the change is announced.
- Under prefers-reduced-motion the illustration stays still and the content fades in without moving.