Command palette

@yasinsensoy/web

Web · Components

EmptyState

Placeholder area shown when there is no data to show: empty list, a search with no results, an error, no connection, no permission.

5 exports

Live example

Preview

Nothing here yet

Code

import { EmptyState, Button } from "@yasinsensoy/web";

<EmptyState variant="dashed"
  action={<Button>Yeni ekle</Button>} />

Events

  1. Events appear here when you interact with the preview.

Import

import { EmptyState } from "@yasinsensoy/web";

EmptyState

componentClient component

Placeholder area shown when there is no data to show: empty list, a search with no results, an error, no connection, no permission. Icon, title, description and action buttons are given as props.

  • With preset, icon and texts come ready-made (multilingual); change what you want with title/description/icon.
  • Show it when loading has finished and the list is empty; while loading use Skeleton.
  • Announced to screen readers as a region (role="status"), so the user is informed when a search result becomes empty.
EmptyState({ preset, title, description, icon, image, action, secondaryAction, tone, variant: variantProp, size, align, titleAs: Title, children, classNames, className, ...props }: EmptyStateProps): JSX.Element

Examples

<EmptyState title="No products yet" description="Start by adding your first product."
  icon="box" action={<Button icon="plus">Add product</Button>} />

<EmptyState preset="search" variant="dashed"
  action={<Button variant="outline" onClick={clearFilters}>Clear filters</Button>} />

<EmptyState preset="error" action={<Button onClick={reload}>Try again</Button>} />

Preset: sets the icon, color and (if not given) the title/description text. The texts come from the UIProvider dictionary.

  • empty: no records yet (first use).
  • search: the search or filter returned no results.
  • error: loading failed.
  • offline: no internet connection.
  • noAccess: no permission.
type EmptyStatePreset = "empty" | "search" | "error" | "offline" | "noAccess"

Appearance.

  • plain: borderless; inside a page or card.
  • dashed: dashed box; emphasizes that an area is empty (e.g. a drag-and-drop zone, an empty board column).
  • card: card with a solid border.
type EmptyStateVariant = "plain" | "dashed" | "card"

Classes that can be passed to the inner parts of EmptyState.

NameTypeDescription
media?stringBox of the icon or illustration.
title?stringTitle.
description?stringDescription.
actions?stringRow of action buttons.

Props of the EmptyState component.

Extends: Omit<ComponentProps<"div">, "title">

NameTypeDefaultDescription
preset?EmptyStatePreset"empty"Preset. See EmptyStatePreset.
title?ReactNodeTitle. If omitted, the preset's text is used. Hidden with null.
description?ReactNodeDescription. If omitted, the preset's text (if any) is used. Hidden with null.
icon?IconProp | nullIcon: a name or an element. If omitted, the preset's icon. Hidden with null.
image?ReactNodeIllustration shown instead of the icon (drawing, <Image>, SVG). If given, the icon is not drawn.
action?ReactNodePrimary action, usually a Button (e.g. "Add product").
secondaryAction?ReactNodeSecondary action (e.g. a "Read the docs" link).
tone?ToneColor of the icon box. If omitted, chosen by the preset.
variant?EmptyStateVariant | CustomVariant<"emptyState">"plain"Appearance: built-in (EmptyStateVariant) or a custom appearance added with defineAppearance. If omitted, UIProvider appearance.defaults.emptyState.variant.
size?Size"md"Size; changes the padding and font size.
align?"center" | "start""center"Alignment.
titleAs?"h2" | "h3" | "h4" | "p""h3"HTML element of the title; change it to match the page's heading order.
children?ReactNodeExtra content shown below the description and above the actions.
classNames?EmptyStateClassNamesClasses added to the inner parts.