Skip to content
ui8kit

component / components

Empty State

Empty State component

Install

npx ui8kit add empty-state

Pulls in: box, compose, icon-badge, kit-box, kit-text, lucide-icon, text, utils

Preview

Your cart is empty

Add something from the catalog and it will show up here.

Code

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdn
npx ui8kit add empty-state
components/empty-state.svelte
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- Empty list or nothing found: a round icon, a title, a hint and an optional action. -->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type EmptyStateProps = {
    icon?: string;
    title: string;
    text?: string;
    class?: string;
    action?: Snippet;
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import IconBadge from "../compose/IconBadge.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";
  import Text from "../compose/Text.svelte";
  import { cn } from "../utils";

  let { icon = "inbox", title, text, class: className, action }: EmptyStateProps = $props();
</script>

<Box
  class={cn(
    "flex min-w-0 flex-col items-center gap-4 rounded bg-card px-6 py-14 text-center inset-ring inset-ring-border",
    className
  )}
  role="status"
  data-slot="empty-state"
>
  <IconBadge size="lg">
    <LucideIcon name={icon} size={20} />
  </IconBadge>
  <Text class="m-0 text-sm font-bold text-foreground">
    {title}
  </Text>
  {#if text}
    <Text class="m-0 max-w-80 text-xs font-medium text-muted-foreground">
      {text}
    </Text>
  {/if}
  {@render action?.()}
</Box>

Svelte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdn
npx ui8kit add empty-state
components/empty-state.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** Empty list or nothing found: a round icon, a title, a hint and an optional action. */
import { type ReactNode } from "react";
import { Box, IconBadge, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { cn } from "../utils";

export type EmptyStateProps = {
  icon?: string;
  title: string;
  text?: string;
  className?: string;
  action?: ReactNode;
};

export function EmptyState({ icon = "inbox", title, text, className, action }: EmptyStateProps) {
  return (
    <Box
      className={cn(
        "flex min-w-0 flex-col items-center gap-4 rounded bg-card px-6 py-14 text-center inset-ring inset-ring-border",
        className
      )}
      role="status"
      data-slot="empty-state"
    >
      <IconBadge size="lg">
        <LucideIcon name={icon} size={20} />
      </IconBadge>
      <Text className="m-0 text-sm font-bold text-foreground">
        {title}
      </Text>
      {text ? (
        <Text className="m-0 max-w-80 text-xs font-medium text-muted-foreground">
          {text}
        </Text>
      ) : null}
      {action}
    </Box>
  );
}

React registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdn
npx ui8kit add empty-state
components/empty-state.vue
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- Empty list or nothing found: a round icon, a title, a hint and an optional action. -->
<script lang="ts">
export type EmptyStateProps = {
  icon?: string;
  title: string;
  text?: string;
  class?: string;
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import IconBadge from "../compose/IconBadge.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Text from "../compose/Text.vue";
import { cn } from "../utils";

const { icon = "inbox", title, text, class: className } = defineProps<EmptyStateProps>();
defineSlots<{ action?(): unknown }>();
</script>

<template>
  <Box
    :class="cn(
      'flex min-w-0 flex-col items-center gap-4 rounded bg-card px-6 py-14 text-center inset-ring inset-ring-border',
      className
    )"
    role="status"
    data-slot="empty-state"
  >
    <IconBadge size="lg">
      <LucideIcon :name="icon" :size="20" />
    </IconBadge>
    <Text class="m-0 text-sm font-bold text-foreground">
      {{ title }}
    </Text>
    <Text v-if="text" class="m-0 max-w-80 text-xs font-medium text-muted-foreground">
      {{ text }}
    </Text>
    <slot name="action" />
  </Box>
</template>

Vue registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdn
npx ui8kit add empty-state
components/empty-state.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** Empty list or nothing found: a round icon, a title, a hint and an optional action. */
import { type JSX } from "solid-js";
import { Box, IconBadge, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { cn } from "../utils";

export type EmptyStateProps = {
  icon?: string;
  title: string;
  text?: string;
  class?: string;
  action?: JSX.Element;
};

export function EmptyState({ icon = "inbox", title, text, class: className, action }: EmptyStateProps) {
  return (
    <Box
      class={cn(
        "flex min-w-0 flex-col items-center gap-4 rounded bg-card px-6 py-14 text-center inset-ring inset-ring-border",
        className
      )}
      role="status"
      data-slot="empty-state"
    >
      <IconBadge size="lg">
        <LucideIcon name={icon} size={20} />
      </IconBadge>
      <Text class="m-0 text-sm font-bold text-foreground">
        {title}
      </Text>
      {text ? (
        <Text class="m-0 max-w-80 text-xs font-medium text-muted-foreground">
          {text}
        </Text>
      ) : null}
      {action}
    </Box>
  );
}

Solid registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdn
npx ui8kit add empty-state
blocks/empty-state.templ
// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/parts/empty-state.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/ui/box"
	"github.com/ui8kit/codegen/generated/templ/compose"
	"github.com/ui8kit/codegen/generated/templ/icons"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// EmptyStateProps are the props of EmptyState; the values are the JSON shapes of the TypeScript props.
type EmptyStateProps struct {
	Icon any `json:"icon"`
	Title any `json:"title"`
	Text any `json:"text"`
	Class string `json:"className"`
	Action templ.Component `json:"-"`
}

// Empty list or nothing found: a round icon, a title, a hint and an optional action.
templ EmptyState(p EmptyStateProps) {
	{{ vIcon := uiutils.Def(p.Icon, "inbox") }}
	{{ vTitle := p.Title }}
	{{ vText := p.Text }}
	@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("flex min-w-0 flex-col items-center gap-4 rounded bg-card px-6 py-14 text-center inset-ring inset-ring-border", p.Class)), Attrs: uiutils.Attrs("role", "status", "data-slot", "empty-state")}}) {
		@compose.IconBadge(compose.IconBadgeProps{Size: "lg", TextProps: text.TextProps{}}) {
			@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(vIcon), Size: 20})
		}
		@compose.Text(compose.TextProps{TextProps: text.TextProps{Class: "m-0 text-sm font-bold text-foreground"}}) {
			{ uiutils.Text(vTitle) }
		}
		if uiutils.T(vText) {
			@compose.Text(compose.TextProps{TextProps: text.TextProps{Class: "m-0 max-w-80 text-xs font-medium text-muted-foreground"}}) {
				{ uiutils.Text(vText) }
			}
		}
		if p.Action != nil {
			@p.Action
		}
	}
}

templ registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdn
npx ui8kit add empty-state
blocks/empty-state.html.twig
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/parts/empty-state.json
    Empty list or nothing found: a round icon, a title, a hint and an optional action.
    Props (p): icon, title, text, className, action (slot). -#}
{%- set v_icon = (p.icon ?? 'inbox') -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_text = (p.text ?? null) -%}
{%- set c_4 -%}
  {%- set c_1 -%}
    {{ include('icons/LucideIcon.html.twig', {'name': og_s(v_icon), 'size': 20}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/IconBadge.html.twig', {'size': 'lg', 'children': c_1}, with_context = false) }}
  {%- set c_2 -%}
    {{ og_text(v_title) }}
  {%- endset -%}
  {{ include('compose/Text.html.twig', {'class': 'm-0 text-sm font-bold text-foreground', 'children': c_2}, with_context = false) }}
  {%- if og_t(v_text) %}
    {%- set c_3 -%}
      {{ og_text(v_text) }}
    {%- endset -%}
    {{ include('compose/Text.html.twig', {'class': 'm-0 max-w-80 text-xs font-medium text-muted-foreground', 'children': c_3}, with_context = false) }}
  {%- endif %}
  {{ og_slot((p.action ?? null))|raw }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s(og_cnv(['flex min-w-0 flex-col items-center gap-4 rounded bg-card px-6 py-14 text-center inset-ring inset-ring-border', (p.className ?? '')])), 'attrs': og_attrs(['role', 'status', 'data-slot', 'empty-state']), 'children': c_4}, with_context = false) }}

Twig registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdn
npx ui8kit add empty-state
blocks/empty-state.latte
{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/parts/empty-state.json
    Empty list or nothing found: a round icon, a title, a hint and an optional action.
    Props (p): icon, title, text, className, action (slot). *}
{var $v_icon = ($p['icon'] ?? 'inbox')}
{var $v_title = ($p['title'] ?? null)}
{var $v_text = ($p['text'] ?? null)}
{capture $c_4}
  {capture $c_1}
    {=og_include('icons/LucideIcon.latte', ['name' => og_s($v_icon), 'size' => 20])|noescape}
  {/capture}
  {=og_include('compose/IconBadge.latte', ['size' => 'lg', 'children' => (string) $c_1])|noescape}
  {capture $c_2}
    {=og_text($v_title)}
  {/capture}
  {=og_include('compose/Text.latte', ['class' => 'm-0 text-sm font-bold text-foreground', 'children' => (string) $c_2])|noescape}
  {if og_t($v_text)}
    {capture $c_3}
      {=og_text($v_text)}
    {/capture}
    {=og_include('compose/Text.latte', ['class' => 'm-0 max-w-80 text-xs font-medium text-muted-foreground', 'children' => (string) $c_3])|noescape}
  {/if}
  {=og_slot(($p['action'] ?? null))|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s(og_cnv(['flex min-w-0 flex-col items-center gap-4 rounded bg-card px-6 py-14 text-center inset-ring inset-ring-border', ($p['className'] ?? '')])), 'attrs' => og_attrs(['role', 'status', 'data-slot', 'empty-state']), 'children' => (string) $c_4])|noescape}

Latte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdn
npx ui8kit add empty-state
blocks/empty-state.html.j2
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/parts/empty-state.json
    Empty list or nothing found: a round icon, a title, a hint and an optional action.
    Props (p): icon, title, text, className, action (slot). -#}
{%- set v_icon = og_def(p['icon'], 'inbox') -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_text = og_def(p['text'], none) -%}
{%- set c_4 -%}
  {%- set c_1 -%}
    {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(v_icon), 'Size': 20}}) }}
  {%- endset -%}
  {{ og_include('compose/icon-badge.html.j2', {'p': {'Size': 'lg'}, 'children': c_1}) }}
  {%- set c_2 -%}
    {{ og_text(v_title) }}
  {%- endset -%}
  {{ og_include('compose/text.html.j2', {'p': {'Class': 'm-0 text-sm font-bold text-foreground'}, 'children': c_2}) }}
  {%- if og_t(v_text) %}
    {%- set c_3 -%}
      {{ og_text(v_text) }}
    {%- endset -%}
    {{ og_include('compose/text.html.j2', {'p': {'Class': 'm-0 max-w-80 text-xs font-medium text-muted-foreground'}, 'children': c_3}) }}
  {%- endif %}
  {{ og_slot(og_def(p['action'], none))|safe }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(og_cnv(['flex min-w-0 flex-col items-center gap-4 rounded bg-card px-6 py-14 text-center inset-ring inset-ring-border', og_def(p['className'], '')])), 'Attrs': og_attrs(['role', 'status', 'data-slot', 'empty-state'])}, 'children': c_4}) }}

Jinja2 registry item (JSON)

Props

Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.

Empty list or nothing found: a round icon, a title, a hint and an optional action.

Props of EmptyState
PropTypeDefault Description
icon string"inbox"Lucide name of the icon
title (required)string-
text string-the hint

Used in