Skip to content

Empty

What to show when there is nothing here yet.

View as Markdown

Example

Installation

npx fizzy-ui add empty

Copies empty.ts into src/app/ui/ and installs what it needs. Run init once first.

Accessibility

No axe-core violations axe-core 4.14.0 checks this example, closed and with its panels open, on every build; the site is not published otherwise.

  • Use a real heading for fzEmptyTitle, at the level that fits the page.
  • The icon is decorative: mark it aria-hidden.

Source

The exact file add copies. It is yours to edit.

empty.ts
import { Directive } from '@angular/core';

/**
 * What to show when there is nothing yet: `<div fzEmpty>` with an optional `fzEmptyMedia` (an icon),
 * a heading `fzEmptyTitle` at the level that fits your page, an `fzEmptyDescription` and actions.
 */
@Directive({
  selector: '[fzEmpty]',
  host: { class: 'flex w-full flex-col items-center justify-center gap-4 rounded-lg border border-dashed p-8 text-center text-balance' },
})
export class FzEmpty {}

/** The icon: decorative, so mark the svg `aria-hidden="true"`. */
@Directive({
  selector: '[fzEmptyMedia]',
  host: { class: 'flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground [&_svg]:size-6' },
})
export class FzEmptyMedia {}

@Directive({ selector: '[fzEmptyTitle]', host: { class: 'text-lg font-semibold tracking-tight' } })
export class FzEmptyTitle {}

@Directive({ selector: '[fzEmptyDescription]', host: { class: '-mt-2 max-w-sm text-sm text-muted-foreground' } })
export class FzEmptyDescription {}

export const FZ_EMPTY = [FzEmpty, FzEmptyMedia, FzEmptyTitle, FzEmptyDescription] as const;