Empty State
⋯
EmptyState provides the Figma message layout in sm, md, and lg sizes. The application supplies the illustration or icon, copy, and actions.
import { EmptyState } from "@nesra/ui/empty-state";
export function EmptyResults() { return ( <EmptyState.Root> <EmptyState.Content> <EmptyState.Title>No results found</EmptyState.Title> </EmptyState.Content> </EmptyState.Root> );}All parts are also exported from @nesra/ui.
Composition
Section titled “Composition”EmptyState.Root├── EmptyState.Visual (optional consumer illustration or icon)├── EmptyState.Content│ ├── EmptyState.Title│ └── EmptyState.Description (optional)└── EmptyState.Actions (optional consumer buttons or links)Examples
Section titled “Examples”Minimal message
Section titled “Minimal message”import { EmptyState } from "@nesra/ui/empty-state";
export function EmptyStateMinimalExample() { return ( <EmptyState.Root className="mx-auto max-w-128" size="sm"> <EmptyState.Content> <EmptyState.Title>Nothing here yet</EmptyState.Title> </EmptyState.Content> </EmptyState.Root> );}Single action
Section titled “Single action”import { Button } from "@nesra/ui/button";import { EmptyState } from "@nesra/ui/empty-state";import { Plus } from "lucide-react";
export function EmptyStateSingleActionExample() { return ( <EmptyState.Root className="mx-auto max-w-128"> <EmptyState.Content> <EmptyState.Title>No projects yet</EmptyState.Title> <EmptyState.Description> Create a project to start organizing your work. </EmptyState.Description> </EmptyState.Content> <EmptyState.Actions> <Button startIcon={<Plus />}>Create project</Button> </EmptyState.Actions> </EmptyState.Root> );}Two actions
Section titled “Two actions”import { Button, EmptyState } from "@nesra/ui";import { Database, Plus } from "lucide-react";
export function EmptyStateBasicExample() { return ( <EmptyState.Root className="mx-auto max-w-128" size="md"> <EmptyState.Visual> <Database aria-hidden="true" className="size-12 text-nesra-text-support" /> </EmptyState.Visual> <EmptyState.Content> <EmptyState.Title>No data found</EmptyState.Title> <EmptyState.Description> No data available at the moment. Please check back later or try refreshing. </EmptyState.Description> </EmptyState.Content> <EmptyState.Actions> <Button variant="outline">Refresh Data</Button> <Button startIcon={<Plus />}>Create Data</Button> </EmptyState.Actions> </EmptyState.Root> );}Featured icon
Section titled “Featured icon”The application composes the icon frame inside EmptyState.Visual. This example uses the Figma sm treatment: a 48px outer frame with a 40px inner frame and a muted icon.
import { EmptyState } from "@nesra/ui/empty-state";import { Search } from "lucide-react";
export function EmptyStateFeaturedIconExample() { return ( <EmptyState.Root className="mx-auto max-w-128" size="sm"> <EmptyState.Visual> <span className="flex size-12 items-center justify-center rounded-nesra-xl border border-nesra-stroke-border bg-nesra-surface-card-bg-neutral"> <span className="flex size-10 items-center justify-center rounded-nesra-sm border border-nesra-stroke-divider bg-nesra-surface-card-bg-neutral shadow-[0_1px_2px_var(--nesra-shadow-xs),0_3px_3px_var(--nesra-shadow-xs),1px_8px_5px_var(--nesra-shadow-xs),inset_0_-2px_2px_var(--nesra-shadow-xs)]"> <Search aria-hidden="true" className="size-6 text-nesra-icon-muted" /> </span> </span> </EmptyState.Visual> <EmptyState.Content> <EmptyState.Title as="h3">No matching results</EmptyState.Title> <EmptyState.Description>Try a different keyword or remove a filter.</EmptyState.Description> </EmptyState.Content> </EmptyState.Root> );}Consumer illustration
Section titled “Consumer illustration”The artwork below is assembled in this documentation example. @nesra/ui supplies the layout slot and does not bundle an illustration.
import { Button } from "@nesra/ui/button";import { EmptyState } from "@nesra/ui/empty-state";import { FileText, Plus } from "lucide-react";
export function EmptyStateIllustrationExample() { return ( <EmptyState.Root className="mx-auto max-w-128" size="lg"> <EmptyState.Visual> <div className="relative flex h-40 w-55 items-center justify-center" aria-hidden="true"> <span className="absolute size-40 rounded-full bg-nesra-surface-card-bg-gray" /> <span className="relative flex size-24 items-center justify-center rounded-nesra-xl border border-nesra-stroke-border bg-nesra-surface-card-bg-neutral shadow-nesra-xs"> <FileText className="size-12 text-nesra-icon-neutral" /> </span> </div> </EmptyState.Visual> <EmptyState.Content> <EmptyState.Title>No documents yet</EmptyState.Title> <EmptyState.Description>Upload your first document to see it here.</EmptyState.Description> </EmptyState.Content> <EmptyState.Actions> <Button size="lg" startIcon={<Plus />}> Add document </Button> </EmptyState.Actions> </EmptyState.Root> );}The sizes change spacing and message typography. Match composed actions to the same Button size. The consumer remains responsible for sizing its artwork: Figma’s illustration frames are 152×124px for sm, 172×136px for md, and 220×160px for lg; the featured icon frames are 48px for sm and md, and 56px for lg.
import { Button, EmptyState } from "@nesra/ui";import { Inbox } from "lucide-react";
export function EmptyStateSizesExample() { return ( <div className="grid w-full gap-8 md:grid-cols-3"> {(["sm", "md", "lg"] as const).map((size) => ( <EmptyState.Root key={size} size={size}> <EmptyState.Visual> <Inbox aria-hidden="true" className="size-12 text-nesra-text-support" /> </EmptyState.Visual> <EmptyState.Content> <EmptyState.Title as="h3">No results found</EmptyState.Title> <EmptyState.Description>Try adjusting your search or filters.</EmptyState.Description> </EmptyState.Content> <EmptyState.Actions> <Button size={size}>Create data</Button> </EmptyState.Actions> </EmptyState.Root> ))} </div> );}Pass an application image as the visual when using an illustration:
<EmptyState.Visual> <img src={illustrationUrl} alt="" width={172} height={136} /></EmptyState.Visual>Light and Dark
Section titled “Light and Dark”EmptyState.Title uses --nesra-text-headline and EmptyState.Description uses
--nesra-text-support, so text follows the active theme. The application supplies the visual.
Use semantic roles in it so it switches too: the featured icon example uses
--nesra-surface-card-bg-neutral with --nesra-stroke-border and --nesra-stroke-divider frames
and an --nesra-icon-muted icon, as in Figma. Content placed on a brand fill such as
--nesra-action-primary-default uses text-nesra-icon-on-brand and text-nesra-text-on-brand.
Accessibility
Section titled “Accessibility”EmptyState.Title renders as h2 by default. Set as to the heading level appropriate for the page. The visual is hidden from assistive technology by default; set aria-hidden={false} on EmptyState.Visual and provide meaningful alternative text when the artwork conveys information missing from the message. The application owns button behavior and any live announcement when the empty state appears after a search or refresh.
API reference
Section titled “API reference”EmptyState.Root
Section titled “EmptyState.Root”The root centers its composed parts and provides the size context.
| Prop | Type | Default | Effect |
|---|---|---|---|
size |
"sm" | "md" | "lg" |
"md" |
Sets layout spacing and message typography. |
Accepts native div attributes, className, children, and a ref to the root element.
EmptyState.Visual
Section titled “EmptyState.Visual”Holds a consumer supplied illustration or icon above the message.
| Prop | Type | Default | Effect |
|---|---|---|---|
aria-hidden |
boolean | "true" | "false" |
true |
Hides decorative artwork. Set to false for meaningful art. |
Accepts native div attributes, className, children, and a ref. The consumer controls the artwork dimensions.
EmptyState.Content
Section titled “EmptyState.Content”Groups the title and optional description in a centered 352px maximum width.
Accepts native div attributes, className, children, and a ref.
EmptyState.Title
Section titled “EmptyState.Title”| Prop | Type | Default | Effect |
|---|---|---|---|
as |
"h2" | "h3" | "h4" | "h5" | "h6" |
"h2" |
Sets semantic heading level without changing its visual size. |
Accepts native heading attributes, className, children, and a ref to the selected heading element.
EmptyState.Description
Section titled “EmptyState.Description”Renders muted supporting text below the title. Accepts native p attributes, className, children, and a ref.
EmptyState.Actions
Section titled “EmptyState.Actions”Arranges consumer supplied controls with 12px gaps and allows them to wrap. Accepts native div attributes, className, children, and a ref.
The supported light theme uses semantic color roles and typography tokens.