Empty

Displays an empty state.

No notebooks yet

Notebooks you write or import show up here. Start from a blank page or a template.

import * as stylex from "@stylexjs/stylex"
import { Button } from "@/components/ui/button"
import {
  Empty,
  EmptyContent,
  EmptyDescription,
  EmptyHeader,
  EmptyMedia,
  EmptyTitle,
} from "@/components/ui/empty"
import { HStack } from "@/components/ui/stack"
import { FolderSimpleIcon } from "@phosphor-icons/react/dist/csr/FolderSimple"

const styles = stylex.create({
  empty: { width: "100%" },
})

export default function EmptyDemo() {
  return (
    <Empty xstyle={styles.empty}>
      <EmptyHeader>
        <EmptyMedia variant="icon">
          <FolderSimpleIcon aria-hidden="true" />
        </EmptyMedia>
        <EmptyTitle>No notebooks yet</EmptyTitle>
        <EmptyDescription>
          Notebooks you write or import show up here. Start from a blank page or a template.
        </EmptyDescription>
      </EmptyHeader>
      <EmptyContent>
        <HStack gap={2}>
          <Button>New notebook</Button>
          <Button variant="outline">Import notebook</Button>
        </HStack>
      </EmptyContent>
    </Empty>
  )
}

Installation

pnpm dlx shadcn@latest add @arene/empty

Needs the arene setup first.

Usage

import {
  Empty,
  EmptyContent,
  EmptyDescription,
  EmptyHeader,
  EmptyMedia,
  EmptyTitle,
} from "@/components/ui/empty"
<Empty>
  <EmptyHeader>
    <EmptyMedia variant="icon">
      <Icon />
    </EmptyMedia>
    <EmptyTitle>No notebooks yet</EmptyTitle>
    <EmptyDescription>Notebooks you write show up here.</EmptyDescription>
  </EmptyHeader>
  <EmptyContent>
    <Button>New notebook</Button>
  </EmptyContent>
</Empty>

Composition

Empty
├── EmptyHeader
│   ├── EmptyMedia
│   ├── EmptyTitle
│   └── EmptyDescription
└── EmptyContent

EmptyHeader holds the media, title and description close together. EmptyContent follows a wider gap below it.

Avatar

Leave EmptyMedia on its default variant to show an avatar or an image of your own instead of the icon tile.

SG
Away for now

Messages you send now are delivered when they next sign in, usually within a day.

import * as stylex from "@stylexjs/stylex"
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import {
  Empty,
  EmptyContent,
  EmptyDescription,
  EmptyHeader,
  EmptyMedia,
  EmptyTitle,
} from "@/components/ui/empty"

const styles = stylex.create({
  empty: { width: "100%" },
})

export default function EmptyAvatar() {
  return (
    <Empty xstyle={styles.empty}>
      <EmptyHeader>
        <EmptyMedia>
          <Avatar size="lg">
            <AvatarImage src="https://github.com/sachigoyal.png" alt="" />
            <AvatarFallback>SG</AvatarFallback>
          </Avatar>
        </EmptyMedia>
        <EmptyTitle>Away for now</EmptyTitle>
        <EmptyDescription>
          Messages you send now are delivered when they next sign in, usually within a day.
        </EmptyDescription>
      </EmptyHeader>
      <EmptyContent>
        <Button size="sm" variant="outline">
          Send a note
        </Button>
      </EmptyContent>
    </Empty>
  )
}

In a table

Inside a surface that already has a fill, such as a table's body, remove the tray with xstyle.

EndpointEventsSuccess rate
No endpoints

Add an endpoint to start receiving events.

import * as stylex from "@stylexjs/stylex"
import { Button } from "@/components/ui/button"
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { color, space } from "@/theme/tokens.stylex"
import { PlusIcon } from "@phosphor-icons/react/dist/csr/Plus"
import { WebhooksLogoIcon } from "@phosphor-icons/react/dist/csr/WebhooksLogo"

const styles = stylex.create({
  empty: { backgroundColor: color.transparent, paddingBlock: space.s10, whiteSpace: "normal" },
})

export default function EmptyTable() {
  return (
    <Table>
      <TableHeader>
        <TableRow>
          <TableHead>Endpoint</TableHead>
          <TableHead>Events</TableHead>
          <TableHead align="end">Success rate</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow>
          <TableCell colSpan={3}>
            <Empty xstyle={styles.empty}>
              <EmptyHeader>
                <EmptyMedia variant="icon">
                  <WebhooksLogoIcon aria-hidden="true" />
                </EmptyMedia>
                <EmptyTitle>No endpoints</EmptyTitle>
                <EmptyDescription>Add an endpoint to start receiving events.</EmptyDescription>
              </EmptyHeader>
              <Button size="sm" variant="outline" iconPosition="start">
                <PlusIcon aria-hidden="true" />
                Add endpoint
              </Button>
            </Empty>
          </TableCell>
        </TableRow>
      </TableBody>
    </Table>
  )
}

API reference

Pass render to replace a part's element or compose it with another component.

Every part renders through Base UI's useRender, and takes xstyle, className and inline style alongside every attribute of its element. EmptyDescription renders a p; every other part renders a div.

Empty

A centred column on a tray. It grows to fill a flex parent, and its padding widens from 1.5rem to 3rem at the md breakpoint.

EmptyHeader

A column with a 0.25rem gap, at most 24rem wide.

EmptyMedia

PropTypeDefault
variant"default" | "icon""default"

icon puts the glyph on a 2.5rem tile and sizes it to 1.25rem. default centres whatever it holds.

EmptyTitle

Weight 500 at the body size.

EmptyDescription

Muted text at the body size.

EmptyContent

A column with a 1rem gap for actions or anything else, at most 24rem wide.

emptyStyles

The style maps behind the component. Spread them onto any element.

KeyWhat it is
baseThe tray and its centred column
headerThe media, title and description column
mediaThe media's box
mediaVariantsdefault, and icon with the shared iconTile
titleThe title's type
descriptionThe muted description
contentThe column below the header

Data attributes

AttributeOnEffect
data-slot="empty"the rootTargets the root from a parent
data-slot="empty-header"the headerTargets the header from a parent
data-slot="empty-media"the mediaTargets the media from a parent
data-variantthe mediaReflects the media's variant prop
data-slot="empty-title"the titleTargets the title from a parent
data-slot="empty-description"the descriptionTargets the description from a parent
data-slot="empty-content"the contentTargets the content from a parent

CSS variables

VariableOnEffect
--arene-icon-sizethe mediaThe icon's size, read by interop.css. 20px on icon