@molecule/app-empty-state-svelte

Feature · empty-state · App (browser) · v1.1.3 · Apache-2.0

Svelte empty-state and CTA-card primitives

npm install @molecule/app-empty-state-svelte

npm · Source on GitHub

How it works

@molecule/app-empty-state-svelte is a ready-made empty-state feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

<script lang="ts">
  import { CtaCard, EmptyState } from '@molecule/app-empty-state-svelte'
  import { Button, Icon } from '@molecule/app-ui-svelte'
</script>

<EmptyState title={t('messages.empty.title', {}, { defaultValue: 'No messages yet' })}>
  {#snippet icon()}<Icon name="mail" size={40} />{/snippet}
  {#snippet description()}
    {t(
      'messages.empty.description',
      {},
      { defaultValue: 'When you receive messages they will appear here.' },
    )}
  {/snippet}
  {#snippet action()}<Button onclick={() => openCompose()}>Send one</Button>{/snippet}
</EmptyState>

<CtaCard title="Connect your bank" description="Link an account to start tracking transactions.">
  {#snippet action()}<Button variant="solid">Connect</Button>{/snippet}
</CtaCard>

Works with: @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte empty-state and CTA-card primitives — the Svelte counterpart of @molecule/app-empty-state-react, with the same props and the same DOM.

Exports:

  • EmptyState — centred icon + title + description + action for lists, feeds, boards, or tables that have no rows to render yet.
  • CtaCard — horizontal or vertical promotional card for "next-step" actions inside a page body.

Both components accept a className prop so apps can layer per-brand accent chrome (dashed borders, gradient CTAs, tinted backgrounds) on top of the structural layout.

A selected list view passes view={emptyByView[selection]}. Each entry pairs its translated title, optional description, and required action element. Keep those entries beside the view definitions so a personal or filtered list does not reuse the whole collection's empty message. The action can be a router link to another view or a button that clears filters. General empty states keep the existing title and optional action props.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

<script lang="ts">
  import { CtaCard, EmptyState } from '@molecule/app-empty-state-svelte'
  import { Button, Icon } from '@molecule/app-ui-svelte'
</script>

<EmptyState title={t('messages.empty.title', {}, { defaultValue: 'No messages yet' })}>
  {#snippet icon()}<Icon name="mail" size={40} />{/snippet}
  {#snippet description()}
    {t(
      'messages.empty.description',
      {},
      { defaultValue: 'When you receive messages they will appear here.' },
    )}
  {/snippet}
  {#snippet action()}<Button onclick={() => openCompose()}>Send one</Button>{/snippet}
</EmptyState>

<CtaCard title="Connect your bank" description="Link an account to start tracking transactions.">
  {#snippet action()}<Button variant="solid">Connect</Button>{/snippet}
</CtaCard>

Type

feature

Installation

npm install @molecule/app-empty-state-svelte @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Interfaces

EmptyStateProps

Props accepted by the EmptyState component.

interface EmptyStateProps {
  /** Visual — typically an icon or an `<img>`. Rendered in a circular badge above the heading. */
  icon?: Snippet | string
  /** Primary heading for a general, unselected collection. */
  title: Snippet | string
  /** Supporting description shown below the heading. */
  description?: Snippet | string
  /** Optional action for a general empty state. */
  action?: Snippet | string
  /** Selected views use the component's view-owned props instead. */
  view?: never
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string
  /** Override outer wrapper classes (for per-app dashed-border, background, padding, etc.). */
  className?: string
  /** Override the icon-badge wrapper classes. */
  iconWrapperClassName?: string
}

CtaCardProps

Props accepted by the CtaCard component.

interface CtaCardProps {
  /** Optional small eyebrow line above the title. */
  eyebrow?: Snippet | string
  /** Primary heading. */
  title: Snippet | string
  /** Supporting copy. */
  description?: Snippet | string
  /** Primary call-to-action. */
  action?: Snippet | string
  /** Optional visual / illustration rendered at the top or side. */
  media?: Snippet | string
  /** `'horizontal'` renders media beside text; `'vertical'` stacks them. Defaults to `'vertical'`. */
  layout?: 'vertical' | 'horizontal'
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string
  /** Override outer wrapper classes. */
  className?: string
}

Constants

CtaCard

const CtaCard: LegacyComponentType

EmptyState

const EmptyState: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-svelte ^3.13.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-svelte ^1.1.0
  • svelte ^5.29.0

Runtime Dependencies

  • @molecule/app-svelte

  • @molecule/app-ui

  • @molecule/app-ui-svelte

  • svelte

  • Name collision: @molecule/app-ui-svelte also exports an EmptyState (the ClassMap-token variant driven by cm.emptyState*). Use THAT one for plain framework-styled empty states; use THIS package when you want the circular icon badge (iconWrapperClassName), per-brand chrome via className, a dataMolId, or the companion <CtaCard>. If you import both packages, alias one import to avoid the clash.

  • All text arrives via props — translate with your t() calls; this package has no locale bond of its own.

  • Styling resolves through getClassMap() — requires a wired ClassMap bond (standard molecule app setup).

  • Node-valued props (icon, title, description, action, eyebrow, media) are snippets, or plain strings.