EmptyState
Figma: "A render, a headline, one action. No paragraphs."
Import
import { EmptyState } from '@nizivo/react/empty-state';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/empty-state.css';Static or interactive
Server. It ships no client JavaScript when a Server Component renders it, in every Next.js build
mode; its code is bundled only when a client component (a 'use client' file) imports it. Its
actions ship whatever their own components ship. How to
choose.
In a client app (a Vite or React Router single-page app, or a 'use client' file) it is an ordinary React component: event handlers, refs and state work as usual. In a client app.
Examples
Basic
Figma Context=Orders and Context=Search are content, not props.
No orders yet
Nothing matches “stoneware”
import type { JSX } from 'react';
import { Button } from '@nizivo/react/button';
import { EmptyState } from '@nizivo/react/empty-state';
/** Stands in for the Figma render (a box illustration); renders are not shipped. */
function BoxRender(): JSX.Element {
return (
<svg viewBox="0 0 140 140" width="140" height="140" aria-hidden="true">
<rect x="30" y="40" width="80" height="70" rx="8" fill="currentColor" opacity="0.2" />
</svg>
);
}
export function EmptyStateExample(): JSX.Element {
return (
<div>
<EmptyState
title="No orders yet"
media={<BoxRender />}
actions={<Button variant="primary">Share your store</Button>}
/>
<EmptyState
level={3}
title="Nothing matches “stoneware”"
actions={<Button>Clear search</Button>}
/>
</div>
);
}
Props
Figma: "A render, a headline, one action. No paragraphs."
Server component Renders data-slot="empty-state" with the class nz-empty-state. Props: EmptyStateProps. Source: src/empty-state/empty-state.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
actions | ReactNode | – | One action, for example |
level | EmptyStateTitleLevel23456 | 2 | |
media | ReactNode | – | A render or illustration above the title, for example |
render | RenderProp<Record<string, never>> | – | |
titlerequired | ReactNode | – | The headline. Its look is Heading/H3 at every |
- Also takes every attribute of
<div>exceptchildren,title. (Omit<ComponentPropsWithRef<"div">, "title" | "children">)
render takes an element, or, in client code, a function of the props and no state.
Other exports
EmptyStatePropstypeimport type { EmptyStateProps } from '@nizivo/react/empty-state'The props of
EmptyState, listed above.EmptyStateTitleLeveltypeimport type { EmptyStateTitleLevel } from '@nizivo/react/empty-state'type EmptyStateTitleLevel = 2 | 3 | 4 | 5 | 6
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
empty-state.nz-empty-state | EmptyStateroot (takes render) | none |
empty-state-actions.nz-empty-state-actions | EmptyStateinner element (CSS only) | none |
empty-state-media.nz-empty-state-media | EmptyStateinner element (CSS only) | none |
empty-state-title.nz-empty-state-title | EmptyStateinner element (CSS only) | none |
CSS hooks
Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.
| Hook | Default | Read as |
|---|---|---|
--nz-empty-state-bg | --nz-bg-subtle |
|
--nz-empty-state-gap | --nz-space-4 |
|
--nz-empty-state-media-size | 8.75rem |
|
--nz-empty-state-padding | --nz-space-8 |
|
--nz-empty-state-radius | --nz-radius-xl |
|
--nz-empty-state-title-font | --nz-font-heading-h3 |
|
Layers: nz.components. Classes: .nz-empty-state, .nz-empty-state-actions, .nz-empty-state-media, .nz-empty-state-title.
Tokens this stylesheet reads (8)
--nz-bg-subtle, --nz-font-heading-h3, --nz-radius-xl, --nz-space-3, --nz-space-4, --nz-space-8, --nz-text-primary, --nz-tracking-heading-h3
Accessibility
Nothing in this component takes focus or keyboard input.
Keyboard
None.
Figma
Node ids from design/component-map.json, which nz gen writes from component.json. The links open the Nizivo Figma library, which may ask you to sign in.
- Canonical: Figma node
7275:15168 - Ghost masters: Figma node
756:1149
Drawer
A modal panel that slides in from an edge of the viewport, for details or a task beside the page, with a header, a body that scrolls and a footer. side="bottom" is a bottom sheet.
Field
The label, help text and error around one form control. A server-safe shell; inside it, Nizivo controls pick up their id, name, flags and description wiring, and native validation messages show inline.