Skip to content
ui8kit

component / components

Stat Figure

Stat Figure component

Install

npx ui8kit add stat-figure

Pulls in: compose, kit-box, kit-text, lucide-icon, presets, stack, stat-tile, stats-band, text, utils

Preview

12,400

Sites published

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 stat-figure
components/stat-figure.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. -->
<!-- One key number of StatsBand: a card (StatTile), or the value over its label, optionally under a Lucide icon. -->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { Stat } from "../blocks/stats-band.types";

  export type StatFigureProps = {
    stat: Stat;
    item?: "plain" | "card" | "icon";
    align?: "start" | "center";
  };
</script>

<script lang="ts">
  import LucideIcon from "../icons/LucideIcon.svelte";
  import Stack from "../compose/Stack.svelte";
  import Text from "../compose/Text.svelte";
  import StatTile from "../components/stat-tile.svelte";
  import { defaults } from "../presets/defaults";
  import { cn } from "../utils";

  let { stat, item = "plain", align = "center" }: StatFigureProps = $props();
</script>

{#if ((item as string) === "card")}
  <StatTile label={stat.label} value={stat.value} icon={stat.icon} hint={stat.hint} />
{:else}
  <Stack
    gap="6"
    align={(((align as string) === "center") ? "center" : "start")}
    class={cn((((align as string) === "center") ? "text-center" : ""), defaults.stats.column)}
    data-slot="item"
  >
    {#if ((item as string) === "icon")}
      <LucideIcon name={stat.icon} size={24} />
    {/if}
    <Stack gap="2" align={(((align as string) === "center") ? "center" : "start")}>
      <Text size="5xl" weight="medium" class={cn("flex items-center", defaults.stats.figure)}>
        {stat.value}
      </Text>
      <Text size="sm" weight="semibold" class="leading-5 text-muted-foreground">
        {stat.label}
      </Text>
    </Stack>
  </Stack>
{/if}

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 stat-figure
components/stat-figure.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.
/** One key number of StatsBand: a card (StatTile), or the value over its label, optionally under a Lucide icon. */
import { type ReactNode } from "react";
import { Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { StatTile } from "../components/stat-tile";
import { defaults } from "../presets/defaults";
import { cn } from "../utils";
import type { Stat } from "../blocks/stats-band.types";

export type StatFigureProps = {
  stat: Stat;
  item?: "plain" | "card" | "icon";
  align?: "start" | "center";
};

export function StatFigure({ stat, item = "plain", align = "center" }: StatFigureProps) {
  return (
    <>
      {((item as string) === "card") ? (
        <StatTile label={stat.label} value={stat.value} icon={stat.icon} hint={stat.hint} />
      ) : (
        <Stack
          gap="6"
          align={(((align as string) === "center") ? "center" : "start")}
          className={cn((((align as string) === "center") ? "text-center" : ""), defaults.stats.column)}
          data-slot="item"
        >
          {((item as string) === "icon") ? (
            <LucideIcon name={stat.icon} size={24} />
          ) : null}
          <Stack gap="2" align={(((align as string) === "center") ? "center" : "start")}>
            <Text size="5xl" weight="medium" className={cn("flex items-center", defaults.stats.figure)}>
              {stat.value}
            </Text>
            <Text size="sm" weight="semibold" className="leading-5 text-muted-foreground">
              {stat.label}
            </Text>
          </Stack>
        </Stack>
      )}
    </>
  );
}

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 stat-figure
components/stat-figure.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. -->
<!-- One key number of StatsBand: a card (StatTile), or the value over its label, optionally under a Lucide icon. -->
<script lang="ts">
import type { Stat } from "../blocks/stats-band.types";

export type StatFigureProps = {
  stat: Stat;
  item?: "plain" | "card" | "icon";
  align?: "start" | "center";
};
</script>

<script setup lang="ts">
import LucideIcon from "../icons/LucideIcon.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import StatTile from "../components/stat-tile.vue";
import { defaults } from "../presets/defaults";
import { cn } from "../utils";

const { stat, item = "plain", align = "center" } = defineProps<StatFigureProps>();
</script>

<template>
  <StatTile
    v-if="((item as string) === 'card')"
    :label="stat.label"
    :value="stat.value"
    :icon="stat.icon"
    :hint="stat.hint"
  />
  <Stack v-else
    gap="6"
    :align="(((align as string) === 'center') ? 'center' : 'start')"
    :class="cn((((align as string) === 'center') ? 'text-center' : ''), defaults.stats.column)"
    data-slot="item"
  >
    <LucideIcon v-if="((item as string) === 'icon')" :name="stat.icon" :size="24" />
    <Stack gap="2" :align="(((align as string) === 'center') ? 'center' : 'start')">
      <Text size="5xl" weight="medium" :class="cn('flex items-center', defaults.stats.figure)">
        {{ stat.value }}
      </Text>
      <Text size="sm" weight="semibold" class="leading-5 text-muted-foreground">
        {{ stat.label }}
      </Text>
    </Stack>
  </Stack>
</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 stat-figure
components/stat-figure.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.
/** One key number of StatsBand: a card (StatTile), or the value over its label, optionally under a Lucide icon. */
import { type JSX } from "solid-js";
import { Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { StatTile } from "../components/stat-tile";
import { defaults } from "../presets/defaults";
import { cn } from "../utils";
import type { Stat } from "../blocks/stats-band.types";

export type StatFigureProps = {
  stat: Stat;
  item?: "plain" | "card" | "icon";
  align?: "start" | "center";
};

export function StatFigure({ stat, item = "plain", align = "center" }: StatFigureProps) {
  return (
    <>
      {((item as string) === "card") ? (
        <StatTile label={stat.label} value={stat.value} icon={stat.icon} hint={stat.hint} />
      ) : (
        <Stack
          gap="6"
          align={(((align as string) === "center") ? "center" : "start")}
          class={cn((((align as string) === "center") ? "text-center" : ""), defaults.stats.column)}
          data-slot="item"
        >
          {((item as string) === "icon") ? (
            <LucideIcon name={stat.icon} size={24} />
          ) : null}
          <Stack gap="2" align={(((align as string) === "center") ? "center" : "start")}>
            <Text size="5xl" weight="medium" class={cn("flex items-center", defaults.stats.figure)}>
              {stat.value}
            </Text>
            <Text size="sm" weight="semibold" class="leading-5 text-muted-foreground">
              {stat.label}
            </Text>
          </Stack>
        </Stack>
      )}
    </>
  );
}

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 stat-figure
blocks/stat-figure.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/organisms/stat-figure.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"
)

// StatFigureProps are the props of StatFigure; the values are the JSON shapes of the TypeScript props.
type StatFigureProps struct {
	Stat any `json:"stat"`
	Item any `json:"item"`
	Align any `json:"align"`
}

// One key number of StatsBand: a card (StatTile), or the value over its label, optionally under a Lucide icon.
templ StatFigure(p StatFigureProps) {
	{{ vStat := p.Stat }}
	{{ vItem := uiutils.Def(p.Item, "plain") }}
	{{ vAlign := uiutils.Def(p.Align, "center") }}
	if uiutils.Eq(vItem, "card") {
		@StatTile(StatTileProps{Label: uiutils.Get(vStat, "label"), Value: uiutils.Get(vStat, "value"), Icon: uiutils.Get(vStat, "icon"), Hint: uiutils.Get(vStat, "hint")})
	} else {
		@compose.Stack(compose.StackProps{Gap: "6", Align: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vAlign, "center")), "center", "start")), BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv(uiutils.Cond(uiutils.T(uiutils.Eq(vAlign, "center")), "text-center", ""), uiutils.Get(presetDefaults, "stats", "column"))), Attrs: uiutils.Attrs("data-slot", "item")}}) {
			if uiutils.Eq(vItem, "icon") {
				@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(uiutils.Get(vStat, "icon")), Size: 24})
			}
			@compose.Stack(compose.StackProps{Gap: "2", Align: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vAlign, "center")), "center", "start")), BoxProps: box.BoxProps{}}) {
				@compose.Text(compose.TextProps{Size: "5xl", Weight: "medium", TextProps: text.TextProps{Class: uiutils.S(uiutils.Cnv("flex items-center", uiutils.Get(presetDefaults, "stats", "figure")))}}) {
					{ uiutils.Text(uiutils.Get(vStat, "value")) }
				}
				@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{Class: "leading-5 text-muted-foreground"}}) {
					{ uiutils.Text(uiutils.Get(vStat, "label")) }
				}
			}
		}
	}
}

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 stat-figure
blocks/stat-figure.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/organisms/stat-figure.json
    One key number of StatsBand: a card (StatTile), or the value over its label, optionally under a Lucide icon.
    Props (p): stat, item, align. -#}
{%- set v_stat = (p.stat ?? null) -%}
{%- set v_item = (p.item ?? 'plain') -%}
{%- set v_align = (p.align ?? 'center') -%}
{%- if og_t(og_eq(v_item, 'card')) %}
  {{ include('blocks/stat-tile.html.twig', {'p': {'label': og_get(v_stat, ['label']), 'value': og_get(v_stat, ['value']), 'icon': og_get(v_stat, ['icon']), 'hint': og_get(v_stat, ['hint'])}}, with_context = false) }}
{%- else %}
  {%- set c_4 -%}
    {%- if og_t(og_eq(v_item, 'icon')) %}
      {{ include('icons/LucideIcon.html.twig', {'name': og_s(og_get(v_stat, ['icon'])), 'size': 24}, with_context = false) }}
    {%- endif %}
    {%- set c_3 -%}
      {%- set c_1 -%}
        {{ og_text(og_get(v_stat, ['value'])) }}
      {%- endset -%}
      {{ include('compose/Text.html.twig', {'size': '5xl', 'weight': 'medium', 'class': og_s(og_cnv(['flex items-center', og_preset('blocks/presets/defaults.json', ['stats', 'figure'])])), 'children': c_1}, with_context = false) }}
      {%- set c_2 -%}
        {{ og_text(og_get(v_stat, ['label'])) }}
      {%- endset -%}
      {{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'class': 'leading-5 text-muted-foreground', 'children': c_2}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Stack.html.twig', {'gap': '2', 'align': og_s((og_t(og_eq(v_align, 'center')) ? 'center' : 'start')), 'children': c_3}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Stack.html.twig', {'gap': '6', 'align': og_s((og_t(og_eq(v_align, 'center')) ? 'center' : 'start')), 'class': og_s(og_cnv([(og_t(og_eq(v_align, 'center')) ? 'text-center' : ''), og_preset('blocks/presets/defaults.json', ['stats', 'column'])])), 'attrs': og_attrs(['data-slot', 'item']), 'children': c_4}, with_context = false) }}
{%- endif %}

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 stat-figure
blocks/stat-figure.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/organisms/stat-figure.json
    One key number of StatsBand: a card (StatTile), or the value over its label, optionally under a Lucide icon.
    Props (p): stat, item, align. *}
{var $v_stat = ($p['stat'] ?? null)}
{var $v_item = ($p['item'] ?? 'plain')}
{var $v_align = ($p['align'] ?? 'center')}
{if og_t(og_eq($v_item, 'card'))}
  {=og_include('blocks/stat-tile.latte', ['p' => ['label' => og_get($v_stat, ['label']), 'value' => og_get($v_stat, ['value']), 'icon' => og_get($v_stat, ['icon']), 'hint' => og_get($v_stat, ['hint'])]])|noescape}
{else}
  {capture $c_4}
    {if og_t(og_eq($v_item, 'icon'))}
      {=og_include('icons/LucideIcon.latte', ['name' => og_s(og_get($v_stat, ['icon'])), 'size' => 24])|noescape}
    {/if}
    {capture $c_3}
      {capture $c_1}
        {=og_text(og_get($v_stat, ['value']))}
      {/capture}
      {=og_include('compose/Text.latte', ['size' => '5xl', 'weight' => 'medium', 'class' => og_s(og_cnv(['flex items-center', og_preset('blocks/presets/defaults.json', ['stats', 'figure'])])), 'children' => (string) $c_1])|noescape}
      {capture $c_2}
        {=og_text(og_get($v_stat, ['label']))}
      {/capture}
      {=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'class' => 'leading-5 text-muted-foreground', 'children' => (string) $c_2])|noescape}
    {/capture}
    {=og_include('compose/Stack.latte', ['gap' => '2', 'align' => og_s((og_t(og_eq($v_align, 'center')) ? 'center' : 'start')), 'children' => (string) $c_3])|noescape}
  {/capture}
  {=og_include('compose/Stack.latte', ['gap' => '6', 'align' => og_s((og_t(og_eq($v_align, 'center')) ? 'center' : 'start')), 'class' => og_s(og_cnv([(og_t(og_eq($v_align, 'center')) ? 'text-center' : ''), og_preset('blocks/presets/defaults.json', ['stats', 'column'])])), 'attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_4])|noescape}
{/if}

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 stat-figure
blocks/stat-figure.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/organisms/stat-figure.json
    One key number of StatsBand: a card (StatTile), or the value over its label, optionally under a Lucide icon.
    Props (p): stat, item, align. -#}
{%- set v_stat = og_def(p['stat'], none) -%}
{%- set v_item = og_def(p['item'], 'plain') -%}
{%- set v_align = og_def(p['align'], 'center') -%}
{%- if og_t(og_eq(v_item, 'card')) %}
  {{ og_include('blocks/stat-tile.html.j2', {'p': {'label': og_get(v_stat, ['label']), 'value': og_get(v_stat, ['value']), 'icon': og_get(v_stat, ['icon']), 'hint': og_get(v_stat, ['hint'])}}) }}
{%- else %}
  {%- set c_4 -%}
    {%- if og_t(og_eq(v_item, 'icon')) %}
      {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(og_get(v_stat, ['icon'])), 'Size': 24}}) }}
    {%- endif %}
    {%- set c_3 -%}
      {%- set c_1 -%}
        {{ og_text(og_get(v_stat, ['value'])) }}
      {%- endset -%}
      {{ og_include('compose/text.html.j2', {'p': {'Size': '5xl', 'Weight': 'medium', 'Class': og_s(og_cnv(['flex items-center', og_preset('blocks/presets/defaults.json', ['stats', 'figure'])]))}, 'children': c_1}) }}
      {%- set c_2 -%}
        {{ og_text(og_get(v_stat, ['label'])) }}
      {%- endset -%}
      {{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold', 'Class': 'leading-5 text-muted-foreground'}, 'children': c_2}) }}
    {%- endset -%}
    {{ og_include('compose/stack.html.j2', {'p': {'Gap': '2', 'Align': og_s(('center' if og_t(og_eq(v_align, 'center')) else 'start'))}, 'children': c_3}) }}
  {%- endset -%}
  {{ og_include('compose/stack.html.j2', {'p': {'Gap': '6', 'Align': og_s(('center' if og_t(og_eq(v_align, 'center')) else 'start')), 'Class': og_s(og_cnv([('text-center' if og_t(og_eq(v_align, 'center')) else ''), og_preset('blocks/presets/defaults.json', ['stats', 'column'])])), 'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_4}) }}
{%- endif %}

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.

One key number of StatsBand: a card (StatTile), or the value over its label, optionally under a Lucide icon.

Props of StatFigure
PropTypeDefault Description
stat (required)Stat-
item "plain" | "card" | "icon""plain"
align "start" | "center""center"

Used in