Components/EmptyState

EmptyState

A placeholder view for empty, loading, error, and other page states.

VerifiedSince 0.3.4

Usage

Presets and Actions

variant picks the preset title, description, and illustration; primaryAction and secondaryAction generate the buttons.

Loading demo...

Horizontal Layout

Loading demo...

Custom Slots

variant="custom" has no preset copy or illustration; the slots supply everything.

Loading demo...

Dashboard Recovery States

Loading demo...

Best Practices

  • Pick the closest preset before overriding copy: search-empty for filters, no-selection for split panes, permission for access, offline for network failures.
  • Make the title situational and actionable: "No automation rules yet", not "Empty".
  • Switch loading, empty, and error states inside one data container to avoid layout jumps.
  • Use primaryAction / secondaryAction for standard flows; use the actions slot only for a custom layout.
  • Use surface="card" in dashboards and panels; keep plain inside tables, drawers, and cards that already frame it.

API Reference

Props

PropTypeDefaultDescription
variantEmptyStateVariant'empty'Preset title, description, and illustration.
titlestring-Overrides the preset title; an empty string hides it.
descriptionstring-Overrides the preset description; an empty string hides it.
iconTxIconSource | string | null-Icon source or class that replaces the illustration; null hides the icon area.
iconSizenumbersize presetIcon or spinner size in px; defaults to 28, 36, or 44 by size.
layout'vertical' | 'horizontal''vertical'Stacks the icon and content, or places them side by side.
align'start' | 'center' | 'end''center'Aligns the icon, copy, and actions.
size'small' | 'medium' | 'large''medium'Spacing, text scale, and illustration size.
surface'plain' | 'card''plain'card adds a bordered card surface.
primaryActionEmptyStateAction-Renders the primary button, which emits primary.
secondaryActionEmptyStateAction-Renders the secondary button before the primary one; it emits secondary.
actionSizeTxButtonProps['size']'sm'Default size of the generated buttons.
loadingbooleanfalseShows TxSpinner when no custom icon is given.

Events

EventPayloadDescription
primary-Fires when the generated primary button is clicked.
secondary-Fires when the generated secondary button is clicked.

Slots

SlotPropsDescription
icon-Replaces the illustration, the spinner, or icon.
title-Replaces the title.
description-Replaces the description.
actions-Replaces the generated primary and secondary buttons.

Types

EmptyStateAction

PropTypeDefaultDescription
labelstring-Button text.
typeTxButtonProps['type']-Tone forwarded to TxButton.
variantTxButtonProps['variant']-Visual variant forwarded to TxButton.
sizeTxButtonProps['size']-Per-button size; falls back to actionSize.
disabledbooleanfalseDisables the button, which then emits nothing.
iconstring-Icon class forwarded to TxButton.

EmptyStateVariant Defaults

VariantDefault titleDefault descriptionIllustration source
emptyNothing hereThere is nothing to show yet.Built-in SVG illustration.
blank-slateStart from scratchCreate your first item to get started.Built-in SVG illustration.
no-dataNo dataNo data available yet.Built-in SVG illustration.
no-selectionNothing selectedSelect an item to see details.Built-in SVG illustration.
search-emptyNo resultsTry a different keyword or filter.Built-in SVG illustration.
loadingLoadingPlease wait a moment.Built-in skeleton illustration; a spinner when loading=true.
offlineYou are offlineCheck your connection and retry.Built-in SVG illustration.
permissionAccess deniedYou do not have permission to view this content.Built-in SVG illustration.
errorSomething went wrongPlease try again later.Built-in SVG illustration.
guideStart hereFollow the steps to get started.Built-in SVG illustration.
customemptyemptyNone unless icon or the icon slot is provided.

Preset Components

Each preset fixes variant and forwards every other prop, event, and slot to TxEmptyState unchanged.

ComponentForced variantNotes
TxBlankSlateblank-slateDefaults to size="large", layout="vertical", and surface="plain".
TxLoadingStateloadingLoading placeholder.
TxNoSelectionno-selectionDetail pane before a list item is selected.
TxNoDatano-dataSuccessful load with no data.
TxSearchEmptysearch-emptySearch or filter with no matches.
TxOfflineStateofflineNetwork unavailable.
TxPermissionStatepermissionAccess denied.
TxErrorStateerrorError.
TxGuideStateguideGuided onboarding.

Overview

  • The variant preset resolves first, then explicit props apply; a slot wins over generated content in its region.
  • The actions slot replaces both generated buttons; generated buttons render secondary first, then primary.
  • icon=null hides the illustration; loading swaps in TxSpinner only when there is no icon slot and icon is empty.
  • surface="card" adds visual containment only; semantics and button behavior are unchanged.
  • Under reduced motion, every illustration rests on a complete still frame.

Technologies

  • Source: packages/tuffex/packages/components/src/empty-state/; each preset lives in its own directory.
查看源码
packages/tuffex/packages/components/src/empty-state/index.ts