Empty State

The <smart-empty-state> component renders an empty-state placeholder with an optional centered icon, title, description, primary actions and a list of starting-points / templates / recommendations. It is typically shown when a list, page or section has no content yet (e.g. No projects, Create your first project, Add team members). It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract EmptyStateBaseComponent defines the shared API — options (IEmptyStateOptions), cssClass (alias class), and the actionClick / itemClick outputs. EmptyStateStandardComponent is a barebones placeholder using native <h3>, <p>, <a>, <button>, <ul> and <li> elements. EmptyStateComponent is the public wrapper that renders EmptyStateStandardComponent by default and accepts a custom replacement via EMPTY_STATE_STANDARD_COMPONENT_TOKEN.


Usage

<smart-empty-state [options]="options" (actionClick)="onActionClick($event)" />
@if (lastAction(); as action) {
  <p>Last action: {{ action }}</p>
}

The preview renders the code above in an application that registers every preset (provideSmartPresets(), see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.

Components

EmptyStateComponent (<smart-empty-state>)

Main wrapper. Delegates to EmptyStateStandardComponent by default. When EMPTY_STATE_STANDARD_COMPONENT_TOKEN is provided, renders the injected component via NgComponentOutlet. Re-emits actionClick and itemClick of whichever implementation it renders.

EmptyStateStandardComponent (<smart-empty-state-standard>)

Barebones placeholder using native HTML. Renders an outer wrapper with cssClass, a <div class="empty-state"> containing optional iconTpl (rendered via NgTemplateOutlet), <h3 class="title">{{ options.title }}</h3>, <p class="description">{{ options.description }}</p>, an optional formTpl slot, an optional row of action buttons or anchors (<button class="action variant-{variant}"> or <a> when action.href provided), an optional list of items (<a class="item-link"> when item.href provided, otherwise <button class="item-button">) with title / description / meta / icon / image, and an optional footer link.

EmptyStatePresetComponent (<smart-empty-state-preset>)

Fully-styled drop-in replacement for EmptyStateStandardComponent, adapting Preline's "Invoice Table Empty State" centered block: a rounded icon tile (iconTpl), title, description, a "Learn more" text link (footerLinkLabel / footerLinkHref) and a row of action buttons. Optional items render as a simple bordered list so it stays a full drop-in. All Tailwind classes are smart:-prefixed with explicit dark: variants. Action variant maps to primary (blue button), secondary (white/layer button), ghost (text + hover) and link (inline blue link); without a variant an action with href is a link and one without is primary. Register it for EMPTY_STATE_STANDARD_COMPONENT_TOKEN to restyle every <smart-empty-state> (or every preset at once with provideSmartPresets()), or use the selector directly. The preset declares cssClass without the class alias, so bind [cssClass] on the <smart-empty-state-preset> selector; class on <smart-empty-state> reaches it through the wrapper.

EmptyStateBaseComponent (abstract)

Abstract base directive. Exposes:

  • options: InputSignal<IEmptyStateOptions | undefined>
  • cssClass: InputSignal<string> (alias class)
  • actionClick: OutputEmitterRef<IEmptyStateActionClick>
  • itemClick: OutputEmitterRef<IEmptyStateItemClick>

IEmptyStateActionClick = { actionId: string } IEmptyStateItemClick = { itemId: string }

API

Inputs

InputTypeDefaultDescription
optionsInputSignal<IEmptyStateOptions | undefined>-Empty state configuration
classInputSignal<string>''Classes on the root element (cssClass input, alias class)

Outputs

OutputTypeDescription
actionClickOutputEmitterRef<IEmptyStateActionClick>Emitted when a button-type action is clicked
itemClickOutputEmitterRef<IEmptyStateItemClick>Emitted when an item without href is clicked

IEmptyStateOptions

All fields are optional. The standard and the preset read every field except layout.

FieldTypeDefaultDescription
titlestring-Heading.
descriptionstring-Text under the heading.
iconTplTemplateRef<unknown>-Icon or illustration above the title.
actionsIEmptyStateAction[][]Buttons / links under the description.
itemsIEmptyStateItem[][]Suggested items (starting points, templates, recommendations) listed below.
itemsTitlestring-Heading of the items list.
formTplTemplateRef<unknown>-A form slot (e.g. an invite input).
footerLinkLabelstring-Text of the footer link (a plain text without footerLinkHref).
footerLinkHrefstring-Target of the footer link.
layoutSmartEmptyStateLayout-Not read by the built-in implementations; available to a custom implementation.

SmartEmptyStateLayout is 'simple' | 'dashed-border' | 'starting-points' | 'with-recommendations' | 'with-templates' | 'with-recommendations-grid'.

IEmptyStateAction

FieldTypeDefaultDescription
idstringrequiredReported as actionId.
labelstring-Button / link text.
hrefstring-Renders a link instead of a button (a link emits no actionClick).
variant'primary' | 'secondary' | 'ghost' | 'link'-Look of the action; defaults to link with href, primary without.
iconTplTemplateRef<unknown>-Icon next to the label.

IEmptyStateItem

FieldTypeDefaultDescription
idstringrequiredReported as itemId.
titlestring-Item title.
descriptionstring-Item text.
hrefstring-Renders the item as a link (no itemClick) instead of a button.
iconTplTemplateRef<unknown>-Item icon.
imageUrlstring-Item image.
imageAltstring-Alt text of the image.
metastring-Small extra text.

EMPTY_STATE_STANDARD_COMPONENT_TOKEN

Provide a Type<EmptyStateBaseComponent> for EMPTY_STATE_STANDARD_COMPONENT_TOKEN to render it in every <smart-empty-state> below that injector; the wrapper passes options and the class on and re-emits its actionClick and itemClick.

Extending the base class

import {
  ChangeDetectionStrategy,
  Component,
  signal,
  ViewEncapsulation,
} from '@angular/core';

import {
  EMPTY_STATE_STANDARD_COMPONENT_TOKEN,
  EmptyStateBaseComponent,
  EmptyStateComponent,
  IEmptyStateOptions,
} from '@smartsoft001/angular';

@Component({
  selector: 'docs-custom-empty-state',
  template: `
    <div class="docs-empty-state" [class]="cssClass()">
      @if (options()?.title) {
        <h3 class="docs-empty-state__title">{{ options()?.title }}</h3>
      }
      @if (options()?.description) {
        <p class="docs-empty-state__description">
          {{ options()?.description }}
        </p>
      }
      @for (action of options()?.actions ?? []; track action.id) {
        <button
          type="button"
          class="docs-empty-state__action"
          [attr.data-variant]="action.variant ?? 'primary'"
          (click)="actionClick.emit({ actionId: action.id })"
        >
          {{ action.label }}
        </button>
      }
    </div>
  `,
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomEmptyStateComponent extends EmptyStateBaseComponent {}

@Component({
  selector: 'docs-empty-state-custom-example',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [EmptyStateComponent],
  // The token swaps the standard empty state for the custom one everywhere
  // below this component, so consumers keep writing `<smart-empty-state>`.
  providers: [
    {
      provide: EMPTY_STATE_STANDARD_COMPONENT_TOKEN,
      useValue: CustomEmptyStateComponent,
    },
  ],
  // The wrapper re-emits the implementation's `actionClick` and `itemClick`,
  // so the handlers stay on `<smart-empty-state>`.
  template: `
    <smart-empty-state
      [options]="options"
      (actionClick)="lastAction.set($event.actionId)"
    />
  `,
})
export class EmptyStateCustomExampleComponent {
  lastAction = signal<string | null>(null);

  options: IEmptyStateOptions = {
    title: 'No draft invoices',
    description: 'Draft an invoice and send it to a customer.',
    actions: [
      { id: 'create', label: 'Create a new invoice', variant: 'primary' },
      { id: 'template', label: 'Use a template', variant: 'secondary' },
    ],
  };
}

Source

The component lives in packages/shared/angular/src/lib/components/empty-state and is documented for Claude Code by the angular-components-empty-state skill.

SmartEmptyState fills the space where content would be: an icon, a title and description, a row of actions, an optional list of suggested items (starting points, templates, recommendations), a form slot and a footer link. Actions and items with href render as links; the others as buttons reported through onActionClick({ actionId }) / onItemClick({ itemId }).


Usage

import { useState } from 'react';

import {
  IEmptyStateActionClick,
  IEmptyStateOptions,
  SmartEmptyState,
} from '@smartsoft001/react';

const options: IEmptyStateOptions = {
  title: 'No projects',
  description: 'Get started by creating a new project.',
  actions: [{ id: 'new-project', label: 'New project', variant: 'primary' }],
};

export function EmptyStateUsageExample() {
  const [lastAction, setLastAction] = useState<string | null>(null);

  const onActionClick = ({ actionId }: IEmptyStateActionClick) =>
    setLastAction(actionId);

  return (
    <>
      <SmartEmptyState options={options} onActionClick={onActionClick} />
      {lastAction && <p>Last action: {lastAction}</p>}
    </>
  );
}

The preview renders the code above in an application that registers every preset (SMART_PRESET_COMPONENTS on SmartProvider, see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.

Exports

All from @smartsoft001/react.

ExportKindWhat it is
SmartEmptyStatecomponentRenders the implementation registered as components['empty-state'] on SmartProvider, SmartEmptyStateStandard by default.
SmartEmptyStatePresetcomponentStyled empty-state variation (preset).
SmartEmptyStateStandardcomponentThe default empty-state rendering: icon, title, description, form slot, actions (anchors when href is set, otherwise buttons calling onActionClick), an optional items list (anchors or buttons calling onItemClick) and a footer link.

The preset's class helpers (getEmptyStateActionClasses, EMPTY_STATE_CONTAINER, EMPTY_STATE_ICON_WRAP, EMPTY_STATE_TITLE, EMPTY_STATE_DESCRIPTION, EMPTY_STATE_FORM, EMPTY_STATE_FOOTER_LINK, EMPTY_STATE_FOOTER_WRAP, EMPTY_STATE_ACTIONS, EMPTY_STATE_ITEMS_TITLE, EMPTY_STATE_ITEMS_LIST, EMPTY_STATE_ITEM, EMPTY_STATE_ITEM_ICON, EMPTY_STATE_ITEM_IMAGE, EMPTY_STATE_ITEM_CONTENT, EMPTY_STATE_ITEM_TITLE, EMPTY_STATE_ITEM_DESCRIPTION, EMPTY_STATE_ITEM_META) are exported too, for a custom implementation that wants the preset look.

Props and Types

SmartEmptyStateProps

PropTypeDefaultDescription
options?IEmptyStateOptions—Content of the empty state.
className?string—Classes on the root element.
onActionClick?(event: IEmptyStateActionClick) => void—Called when an action without href is clicked.
onItemClick?(event: IEmptyStateItemClick) => void—Called when an item without href is clicked.

IEmptyStateOptions

FieldTypeDefaultDescription
title?string—Heading.
description?string—Text under the heading.
layout?SmartEmptyStateLayout—Declared (SmartEmptyStateLayout); neither the standard nor the preset rendering reads it.
iconTpl?ReactNode—Icon or illustration above the title.
actions?IEmptyStateAction[][]Buttons / links under the description.
items?IEmptyStateItem[][]Suggested items listed below.
itemsTitle?string—Heading of the items list.
formTpl?ReactNode—A form slot (e.g. an invite input).
footerLinkLabel?string—Text of the footer link.
footerLinkHref?string—Target of the footer link.

IEmptyStateActionClick

Payload of onActionClick.

FieldTypeDefaultDescription
actionIdstringrequiredThe id of the clicked action.

IEmptyStateItemClick

Payload of onItemClick.

FieldTypeDefaultDescription
itemIdstringrequiredThe id of the clicked item.

IEmptyStateAction

FieldTypeDefaultDescription
idstringrequiredReported as actionId.
label?string—Button / link text.
href?string—Renders a link instead of a button.
variant?'primary' | 'secondary' | 'ghost' | 'link'—Look of the action (the preset defaults to link with href, primary otherwise).
iconTpl?ReactNode—Icon next to the label.

IEmptyStateItem

FieldTypeDefaultDescription
idstringrequiredReported as itemId.
title?string—Item title.
description?string—Item text.
href?string—Renders the item as a link instead of a button.
iconTpl?ReactNode—Item icon.
imageUrl?string—Item image.
imageAlt?string—Alt text of the image.
meta?string—Small extra text.
  • SmartEmptyStateLayout: 'simple' \| 'dashed-border' \| 'starting-points' \| 'with-recommendations' \| 'with-templates' \| 'with-recommendations-grid'

Replacing the Implementation

SmartEmptyState renders the component registered under the 'empty-state' key of SmartProvider's components, and SmartEmptyStateStandard when nothing is registered there. Every SmartEmptyState below the provider then renders the registered component, which receives the same props.

SmartEmptyStatePreset is the styled (preset) implementation: register it under the 'empty-state' key of SmartProvider's components, render it directly in place of SmartEmptyState, or spread SMART_PRESET_COMPONENTS on the provider to register every preset at once (see the react-provider skill). Pass components as a stable object (a module constant or a memoised value), or the context changes on every render.

import {
  cn,
  IEmptyStateOptions,
  SmartEmptyState,
  SmartEmptyStateProps,
  SmartProvider,
} from '@smartsoft001/react';

export function CustomEmptyState({
  options,
  className,
  onActionClick,
}: SmartEmptyStateProps) {
  return (
    <div className={cn('docs-empty-state', className)}>
      {options?.title && (
        <h3 className="docs-empty-state__title">{options.title}</h3>
      )}
      {options?.description && (
        <p className="docs-empty-state__description">{options.description}</p>
      )}
      {(options?.actions ?? []).map((action) => (
        <button
          key={action.id}
          type="button"
          className="docs-empty-state__action"
          data-variant={action.variant ?? 'primary'}
          onClick={() => onActionClick?.({ actionId: action.id })}
        >
          {action.label}
        </button>
      ))}
    </div>
  );
}

// A module constant: a new object on every render would change the context.
const components = { 'empty-state': CustomEmptyState };

const options: IEmptyStateOptions = {
  title: 'No draft invoices',
  description: 'Draft an invoice and send it to a customer.',
  actions: [
    { id: 'create', label: 'Create a new invoice', variant: 'primary' },
    { id: 'template', label: 'Use a template', variant: 'secondary' },
  ],
};

export function EmptyStateCustomExample() {
  // Every SmartEmptyState below the provider renders CustomEmptyState.
  return (
    <SmartProvider components={components}>
      <SmartEmptyState options={options} />
    </SmartProvider>
  );
}

Styling

  • The standard rendering is unstyled markup with class hooks (title, form, items-title, ...); SmartEmptyStatePreset renders the centred block (icon tile, title, description, link and actions) with smart:dark: variants.
  • className is appended to the root element.

Source

The component lives in packages/shared/react/src/lib/components/empty-state and is documented for Claude Code by the react-components-empty-state skill.