Back to Shadcn Ui

Empty

apps/v4/content/docs/components/radix/empty.mdx

latest4.2 KB
Original Source

<ComponentPreview styleName="radix-nova" name="empty-demo" previewClassName="h-96 p-0" />

Installation

<CodeTabs> <TabsList> <TabsTrigger value="cli">Command</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">
bash
npx shadcn@latest add empty
</TabsContent> <TabsContent value="manual"> <Steps className="mb-0 pt-2">

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="empty" title="components/ui/empty.tsx" styleName="radix-nova" />

<Step>Update the import paths to match your project setup.</Step>

</Steps> </TabsContent> </CodeTabs>

Usage

tsx
import {
  Empty,
  EmptyContent,
  EmptyDescription,
  EmptyHeader,
  EmptyMedia,
  EmptyTitle,
} from "@/components/ui/empty"
tsx
<Empty>
  <EmptyHeader>
    <EmptyMedia variant="icon">
      <Icon />
    </EmptyMedia>
    <EmptyTitle>No data</EmptyTitle>
    <EmptyDescription>No data found</EmptyDescription>
  </EmptyHeader>
  <EmptyContent>
    <Button>Add data</Button>
  </EmptyContent>
</Empty>

Examples

Outline

Use the border utility class to create an outline empty state.

<ComponentPreview styleName="radix-nova" name="empty-outline" previewClassName="h-96 p-6 md:p-10" />

Background

Use the bg-* and bg-gradient-* utilities to add a background to the empty state.

<ComponentPreview styleName="radix-nova" name="empty-background" previewClassName="h-96 p-0" />

Avatar

Use the EmptyMedia component to display an avatar in the empty state.

<ComponentPreview styleName="radix-nova" name="empty-avatar" previewClassName="h-96 p-0" />

Avatar Group

Use the EmptyMedia component to display an avatar group in the empty state.

<ComponentPreview styleName="radix-nova" name="empty-avatar-group" previewClassName="h-96 p-0" />

InputGroup

You can add an InputGroup component to the EmptyContent component.

<ComponentPreview styleName="radix-nova" name="empty-input-group" previewClassName="h-96 p-0" />

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

<ComponentPreview styleName="radix-nova" name="empty-rtl" direction="rtl" />

API Reference

Empty

The main component of the empty state. Wraps the EmptyHeader and EmptyContent components.

PropTypeDefault
classNamestring
tsx
<Empty>
  <EmptyHeader />
  <EmptyContent />
</Empty>

EmptyHeader

The EmptyHeader component wraps the empty media, title, and description.

PropTypeDefault
classNamestring
tsx
<EmptyHeader>
  <EmptyMedia />
  <EmptyTitle />
  <EmptyDescription />
</EmptyHeader>

EmptyMedia

Use the EmptyMedia component to display the media of the empty state such as an icon or an image. You can also use it to display other components such as an avatar.

PropTypeDefault
variant"default" | "icon"default
classNamestring
tsx
<EmptyMedia variant="icon">
  <Icon />
</EmptyMedia>
tsx
<EmptyMedia>
  <Avatar>
    <AvatarImage src="..." />
    <AvatarFallback>CN</AvatarFallback>
  </Avatar>
</EmptyMedia>

EmptyTitle

Use the EmptyTitle component to display the title of the empty state.

PropTypeDefault
classNamestring
tsx
<EmptyTitle>No data</EmptyTitle>

EmptyDescription

Use the EmptyDescription component to display the description of the empty state.

PropTypeDefault
classNamestring
tsx
<EmptyDescription>You do not have any notifications.</EmptyDescription>

EmptyContent

Use the EmptyContent component to display the content of the empty state such as a button, input or a link.

PropTypeDefault
classNamestring
tsx
<EmptyContent>
  <Button>Add Project</Button>
</EmptyContent>