Empty

What to show where content will be.

Say what’s missing, why, and what to do next. The media tile takes an icon.

Preview
basic.tsx
import { FileText } from "lucide-react"

import { Button } from "~/components/ui/button"
import {
  Empty,
  EmptyContent,
  EmptyDescription,
  EmptyHeader,
  EmptyMedia,
  EmptyTitle,
} from "~/components/ui/empty"

export default function Example() {
  return (
    <Empty className="max-w-md">
      <EmptyHeader>
        <EmptyMedia>
          <FileText />
        </EmptyMedia>
        <EmptyTitle>No edition open</EmptyTitle>
        <EmptyDescription>
          Start with a publication, build an edition, then bring the agent into production.
        </EmptyDescription>
      </EmptyHeader>
      <EmptyContent>
        <Button>New edition</Button>
      </EmptyContent>
    </Empty>
  )
}

Dependencies

What it's built from and what's built from it in Base, read from the imports in its source.

UsesTextprimitive
Used byNothing yet.
Packages None.

Installation

Set the project up for Base once first, as Getting started shows. Then add it with the CLI, or by hand.

With the CLI

terminal
npx shadcn@latest add https://design.zepez.dev/r/base/empty.json

Manually

Add the components it uses first, listed under Dependencies.

Then copy the source:

components/ui/empty.tsx
import type * as React from "react"

import { textVariants } from "~/components/ui/text"
import { cn } from "~/lib/utils"

/** What to show where content will be: a message, and what to do about it. */
function Empty({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="empty"
      className={cn(
        "flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-lg rounded-xl border border-dashed border-border p-3xl text-center text-balance",
        className,
      )}
      {...props}
    />
  )
}

/** The icon, 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-sm", className)}
      {...props}
    />
  )
}

/** An icon in a tile above the title. */
function EmptyMedia({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="empty-media"
      aria-hidden="true"
      className={cn(
        "mb-sm flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-5",
        className,
      )}
      {...props}
    />
  )
}

/** Says what's missing. */
function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="empty-title"
      className={cn(textVariants({ size: "lg", weight: "medium", family: "heading" }), className)}
      {...props}
    />
  )
}

/** Says why, and what happens next. */
function EmptyDescription({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="empty-description"
      className={cn(
        textVariants({ size: "sm", leading: "relaxed", tone: "muted" }),
        "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-foreground",
        className,
      )}
      {...props}
    />
  )
}

/** Actions under the message. */
function EmptyContent({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="empty-content"
      className={cn(
        textVariants({ size: "sm" }),
        "flex w-full max-w-sm min-w-0 flex-col items-center gap-lg text-balance",
        className,
      )}
      {...props}
    />
  )
}

export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle }

API reference

Generated from Base's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.

Empty

What to show where content will be: a message, and what to do about it.

Takes the props of a native div.

EmptyContent

Actions under the message.

Takes the props of a native div.

EmptyDescription

Says why, and what happens next.

Takes the props of a native div.

EmptyHeader

The icon, title and description.

Takes the props of a native div.

EmptyMedia

An icon in a tile above the title.

Takes the props of a native div.

EmptyTitle

Says what's missing.

Takes the props of a native div.