Skip to content
Nizivo UI

EmptyState

Figma: "A render, a headline, one action. No paragraphs."

Server component, no client JS

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.

NameTypeDefaultDescription
actionsReactNode–

One action, for example <Button variant="primary">Share your store</Button>.

levelEmptyStateTitleLevel
23456
2
mediaReactNode–

A render or illustration above the title, for example <Image … />.

renderRenderProp<Record<string, never>>–
titlerequiredReactNode–

The headline. Its look is Heading/H3 at every level.

  • Also takes every attribute of <div> except children, title. (Omit<ComponentPropsWithRef<"div">, "title" | "children">)

render takes an element, or, in client code, a function of the props and no state.

Other exports

EmptyStateProps type

import type { EmptyStateProps } from '@nizivo/react/empty-state'

The props of EmptyState, listed above.

EmptyStateTitleLevel type

import 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.

SlotRendered byData attributes
empty-state
.nz-empty-state
EmptyState
root (takes render)
none
empty-state-actions
.nz-empty-state-actions
EmptyState
inner element (CSS only)
none
empty-state-media
.nz-empty-state-media
EmptyState
inner element (CSS only)
none
empty-state-title
.nz-empty-state-title
EmptyState
inner 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.

HookDefaultRead as
--nz-empty-state-bg--nz-bg-subtle
  • background on .nz-empty-state
--nz-empty-state-gap--nz-space-4
  • gap on .nz-empty-state
--nz-empty-state-media-size8.75rem
  • block-size on .nz-empty-state-media
  • inline-size on .nz-empty-state-media
--nz-empty-state-padding--nz-space-8
  • padding on .nz-empty-state
--nz-empty-state-radius--nz-radius-xl
  • border-radius on .nz-empty-state
--nz-empty-state-title-font--nz-font-heading-h3
  • font on .nz-empty-state-title

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.

On this page