Empty state
A message and primary action for views that have nothing to show yet.
Use an empty state where a list, table or page has nothing to show: say what is missing, why, and give the one action that fills it.
No API tokens yet
Create a token to install Pro components from the command line. You see it once, so copy it somewhere safe.
Installation
Pro components install from the Aloxe registry with the shadcn CLI. Once per project, add the registry to components.json and put a registry token in the ALOXE_TOKEN environment variable. Registry has the details.
{
"registries": {
"@aloxe": {
"url": "https://<aloxe-site>/r/{name}.json",
"headers": { "Authorization": "Bearer ${ALOXE_TOKEN}" }
}
}
}Then add the component:
npx shadcn@latest add @aloxe/empty-stateThe CLI copies the source into components/ui/aloxe/, so it never overwrites your own ui components. It also installs @aloxe/react, @aloxe/tokens and @base-ui/react.
Import the tokens once in your global stylesheet, after Tailwind, and add an @source for the copied files and one for @aloxe/react, so Tailwind generates their classes. @source paths are relative to the stylesheet; these assume src/app/globals.css and src/components/ui/aloxe/.
@import "tailwindcss";
@import "@aloxe/tokens/aloxe.css";
@import "@aloxe/tokens/tailwind.css";
@source "../components/ui/aloxe";
@source "../../node_modules/@aloxe/react/dist";Installation covers the theme and brand attributes.
Usage
import { Button } from "@aloxe/react";
import { FileText } from "lucide-react";
import { EmptyState } from "@/components/ui/aloxe/empty-state";
<EmptyState
icon={<FileText />}
title="No invoices yet"
description="Invoices you send appear here with their status and amount."
action={<Button>New invoice</Button>}
/>Write the title as a plain statement of what is empty, and the description as what happens next. Pick headingLevel to fit the page outline; it is h3 by default.
Examples
No results
After a search or a filter, say what matched nothing and offer the way back. A second, quieter action can follow the primary one.
No members match “jonas@acme”
Check the spelling, or search by name instead of email.
Compact, without an action
In a small panel, drop the icon and tighten the padding with className. When there is nothing to do, leave out action.
You're all caught up
New comments and mentions show up here.
Accessibility
| Key | Action |
|---|---|
| Tab | Moves to the action buttons. The message itself isn't focusable. |
- The title is a real heading, so screen reader users find the empty state when they move by heading. Set
headingLevelso it nests under the section it sits in. - The icon is decorative and hidden from screen readers.
- When the empty state replaces results after a search, announce it, for example with an
aria-live="polite"count next to the search field.
API reference
Renders a data-aloxe="empty-state" attribute you can target in CSS. Other props go to the wrapping <div>.
EmptyState
Extends <div>.
| Prop | Type | Default | Description |
|---|---|---|---|
| title (required) | ReactNode | Says what is empty, such as No invoices yet. Rendered as a heading. | |
| description | ReactNode | One or two sentences: why it is empty and what the action does. | |
| icon | ReactNode | A 20 px line icon in a tile above the title. Decorative. | |
| action | ReactNode | The primary action, such as a Button. A second, quieter one may follow. | |
| headingLevel | 2 | 3 | 4 | 3 | The title's heading level, to fit the page outline. |
| children | ReactNode | Extra content between the description and the action. | |
| className | string | Merged with the default classes, such as py-8 for a tighter panel. |
Figma
Matches the Empty state component in the Pro Figma file. Its Title, Description and action map to title, description and action; the icon tile maps to icon.
See Figma for where to get the file and how its names map to code.
Pro
Empty state is part of Aloxe Pro. The previews on this page are open to everyone; the Code tab shows the example source once you sign in with a Pro license. See Access and licenses and Pricing.