Skip to content
ui8kit

block / dashboard

Metric Row

Key counters of a dashboard.

Install

npx ui8kit add metric-row

Pulls in: box, compose, empty-state, grid, group, kit-box, kit-text, lucide-icon, section-frame, stack, stat-tile, text, utils

Preview

Overview

Revenue

$48,200

+8% this month

Orders

1,284

+3% this month

Visitors

92,410

+12% this month

Churn

1.9%

-0.2% this month

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 metric-row
blocks/metric-row.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. -->
<!--
  Dashboard counters in a row or a grid: tiles with an icon, a number and a caption, or compact figures. Axes:
  columns (2, 4), item (tile, compact), tone (default, muted), density (default, compact).
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { Metric } from "./metric-row.types";

  export type MetricRowProps = {
    id: string;
    title: string;
    metrics: Metric[];
    empty?: string;
    cols?: "2" | "4";
    item?: "tile" | "compact";
    tone?: "default" | "muted";
    density?: "default" | "compact";
    landmarkLabel?: string;
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import Grid from "../compose/Grid.svelte";
  import Group from "../compose/Group.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";
  import Stack from "../compose/Stack.svelte";
  import Text from "../compose/Text.svelte";
  import EmptyState from "../components/empty-state.svelte";
  import SectionFrame from "../components/section-frame.svelte";
  import StatTile from "../components/stat-tile.svelte";

  let {
    id,
    title,
    metrics,
    empty = "",
    cols = "4",
    item = "tile",
    tone = "default",
    density = "default",
    landmarkLabel,
  }: MetricRowProps = $props();
</script>

<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
  {#if ((metrics?.length ?? 0) === 0)}
    <EmptyState icon="gauge" title={empty} />
  {:else}
    <Grid cols={(((cols as string) === "2") ? "1-2" : "1-4")} class="gap-4" data-slot="items">
      {#each metrics as m (m.id)}
        {#if ((item as string) === "tile")}
          <Box data-slot="item">
            <StatTile label={m.label} value={m.value} icon={m.icon} hint={m.hint} />
          </Box>
        {:else}
          <Stack gap="0" class="rounded bg-card p-4 inset-ring inset-ring-border" data-slot="item">
            <Group gap="2" align="center" class="text-muted-foreground">
              <LucideIcon name={m.icon} size={16} />
              <Text size="xs">
                {m.label}
              </Text>
            </Group>
            <Text size="2xl" weight="bold">
              {m.value}
            </Text>
            <Text size="xs" class="text-muted-foreground">
              {m.hint}
            </Text>
          </Stack>
        {/if}
      {/each}
    </Grid>
  {/if}
</SectionFrame>
blocks/metric-row.types.ts
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.

export type Metric = {
  id: string;
  label: string;
  value: string;
  icon: string;
  hint: string;
};

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 metric-row
blocks/metric-row.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.
/**
 * Dashboard counters in a row or a grid: tiles with an icon, a number and a caption, or compact figures. Axes:
 * columns (2, 4), item (tile, compact), tone (default, muted), density (default, compact).
 */
import { Fragment, type ReactNode } from "react";
import { Box, Grid, Group, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { SectionFrame } from "../components/section-frame";
import { StatTile } from "../components/stat-tile";
import type { Metric } from "./metric-row.types";

export type MetricRowProps = {
  id: string;
  title: string;
  metrics: Metric[];
  empty?: string;
  cols?: "2" | "4";
  item?: "tile" | "compact";
  tone?: "default" | "muted";
  density?: "default" | "compact";
  landmarkLabel?: string;
};

export function MetricRow({
  id,
  title,
  metrics,
  empty = "",
  cols = "4",
  item = "tile",
  tone = "default",
  density = "default",
  landmarkLabel,
}: MetricRowProps) {
  return (
    <SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
      {((metrics?.length ?? 0) === 0) ? (
        <EmptyState icon="gauge" title={empty} />
      ) : (
        <Grid cols={(((cols as string) === "2") ? "1-2" : "1-4")} className="gap-4" data-slot="items">
          {(metrics ?? []).map((m) => (
            <Fragment key={m.id}>
              {((item as string) === "tile") ? (
                <Box data-slot="item">
                  <StatTile label={m.label} value={m.value} icon={m.icon} hint={m.hint} />
                </Box>
              ) : (
                <Stack gap="0" className="rounded bg-card p-4 inset-ring inset-ring-border" data-slot="item">
                  <Group gap="2" align="center" className="text-muted-foreground">
                    <LucideIcon name={m.icon} size={16} />
                    <Text size="xs">
                      {m.label}
                    </Text>
                  </Group>
                  <Text size="2xl" weight="bold">
                    {m.value}
                  </Text>
                  <Text size="xs" className="text-muted-foreground">
                    {m.hint}
                  </Text>
                </Stack>
              )}
            </Fragment>
          ))}
        </Grid>
      )}
    </SectionFrame>
  );
}
blocks/metric-row.types.ts
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.

export type Metric = {
  id: string;
  label: string;
  value: string;
  icon: string;
  hint: string;
};

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 metric-row
blocks/metric-row.types.ts
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.

export type Metric = {
  id: string;
  label: string;
  value: string;
  icon: string;
  hint: string;
};
blocks/metric-row.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. -->
<!--
  Dashboard counters in a row or a grid: tiles with an icon, a number and a caption, or compact figures. Axes:
  columns (2, 4), item (tile, compact), tone (default, muted), density (default, compact).
-->
<script lang="ts">
import type { Metric } from "./metric-row.types";

export type MetricRowProps = {
  id: string;
  title: string;
  metrics: Metric[];
  empty?: string;
  cols?: "2" | "4";
  item?: "tile" | "compact";
  tone?: "default" | "muted";
  density?: "default" | "compact";
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import Grid from "../compose/Grid.vue";
import Group from "../compose/Group.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import EmptyState from "../components/empty-state.vue";
import SectionFrame from "../components/section-frame.vue";
import StatTile from "../components/stat-tile.vue";

const {
  id,
  title,
  metrics,
  empty = "",
  cols = "4",
  item = "tile",
  tone = "default",
  density = "default",
  landmarkLabel,
} = defineProps<MetricRowProps>();
</script>

<template>
  <SectionFrame :id="id" :title="title" :tone="tone" :density="density" :landmarkLabel="landmarkLabel">
    <EmptyState v-if="((metrics?.length ?? 0) === 0)" icon="gauge" :title="empty" />
    <Grid v-else :cols="(((cols as string) === '2') ? '1-2' : '1-4')" class="gap-4" data-slot="items">
      <template v-for="m in metrics" :key="m.id">
        <Box v-if="((item as string) === 'tile')" data-slot="item">
          <StatTile :label="m.label" :value="m.value" :icon="m.icon" :hint="m.hint" />
        </Box>
        <Stack v-else gap="0" class="rounded bg-card p-4 inset-ring inset-ring-border" data-slot="item">
          <Group gap="2" align="center" class="text-muted-foreground">
            <LucideIcon :name="m.icon" :size="16" />
            <Text size="xs">
              {{ m.label }}
            </Text>
          </Group>
          <Text size="2xl" weight="bold">
            {{ m.value }}
          </Text>
          <Text size="xs" class="text-muted-foreground">
            {{ m.hint }}
          </Text>
        </Stack>
      </template>
    </Grid>
  </SectionFrame>
</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 metric-row
blocks/metric-row.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.
/**
 * Dashboard counters in a row or a grid: tiles with an icon, a number and a caption, or compact figures. Axes:
 * columns (2, 4), item (tile, compact), tone (default, muted), density (default, compact).
 */
import { For, type JSX } from "solid-js";
import { Box, Grid, Group, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { SectionFrame } from "../components/section-frame";
import { StatTile } from "../components/stat-tile";
import type { Metric } from "./metric-row.types";

export type MetricRowProps = {
  id: string;
  title: string;
  metrics: Metric[];
  empty?: string;
  cols?: "2" | "4";
  item?: "tile" | "compact";
  tone?: "default" | "muted";
  density?: "default" | "compact";
  landmarkLabel?: string;
};

export function MetricRow({
  id,
  title,
  metrics,
  empty = "",
  cols = "4",
  item = "tile",
  tone = "default",
  density = "default",
  landmarkLabel,
}: MetricRowProps) {
  return (
    <SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
      {((metrics?.length ?? 0) === 0) ? (
        <EmptyState icon="gauge" title={empty} />
      ) : (
        <Grid cols={(((cols as string) === "2") ? "1-2" : "1-4")} class="gap-4" data-slot="items">
          <For each={metrics ?? []}>{(m) => (
            <>
              {((item as string) === "tile") ? (
                <Box data-slot="item">
                  <StatTile label={m.label} value={m.value} icon={m.icon} hint={m.hint} />
                </Box>
              ) : (
                <Stack gap="0" class="rounded bg-card p-4 inset-ring inset-ring-border" data-slot="item">
                  <Group gap="2" align="center" class="text-muted-foreground">
                    <LucideIcon name={m.icon} size={16} />
                    <Text size="xs">
                      {m.label}
                    </Text>
                  </Group>
                  <Text size="2xl" weight="bold">
                    {m.value}
                  </Text>
                  <Text size="xs" class="text-muted-foreground">
                    {m.hint}
                  </Text>
                </Stack>
              )}
            </>
          )}</For>
        </Grid>
      )}
    </SectionFrame>
  );
}
blocks/metric-row.types.ts
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.

export type Metric = {
  id: string;
  label: string;
  value: string;
  icon: string;
  hint: string;
};

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 metric-row
blocks/metric-row.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/metric-row.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"
)

// MetricRowProps are the props of MetricRow; the values are the JSON shapes of the TypeScript props.
type MetricRowProps struct {
	Id any `json:"id"`
	Title any `json:"title"`
	Metrics any `json:"metrics"`
	Empty any `json:"empty"`
	Cols any `json:"cols"`
	Item any `json:"item"`
	Tone any `json:"tone"`
	Density any `json:"density"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// Dashboard counters in a row or a grid: tiles with an icon, a number and a caption, or compact figures. Axes: columns (2, 4), item (tile, compact), tone (default, muted), density (default, compact).
templ MetricRow(p MetricRowProps) {
	{{ vId := p.Id }}
	{{ vTitle := p.Title }}
	{{ vMetrics := p.Metrics }}
	{{ vEmpty := uiutils.Def(p.Empty, "") }}
	{{ vCols := uiutils.Def(p.Cols, "4") }}
	{{ vItem := uiutils.Def(p.Item, "tile") }}
	{{ vTone := uiutils.Def(p.Tone, "default") }}
	{{ vDensity := uiutils.Def(p.Density, "default") }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Tone: vTone, Density: vDensity, LandmarkLabel: vLandmarkLabel}) {
		if uiutils.Eq(uiutils.Len(vMetrics), float64(0)) {
			@EmptyState(EmptyStateProps{Icon: "gauge", Title: vEmpty})
		} else {
			@compose.Grid(compose.GridProps{Cols: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vCols, "2")), "1-2", "1-4")), BoxProps: box.BoxProps{Class: "gap-4", Attrs: uiutils.Attrs("data-slot", "items")}}) {
				for _, vM := range uiutils.L(vMetrics) {
					if uiutils.Eq(vItem, "tile") {
						@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "item")}}) {
							@StatTile(StatTileProps{Label: uiutils.Get(vM, "label"), Value: uiutils.Get(vM, "value"), Icon: uiutils.Get(vM, "icon"), Hint: uiutils.Get(vM, "hint")})
						}
					} else {
						@compose.Stack(compose.StackProps{Gap: "0", BoxProps: box.BoxProps{Class: "rounded bg-card p-4 inset-ring inset-ring-border", Attrs: uiutils.Attrs("data-slot", "item")}}) {
							@compose.Group(compose.GroupProps{Gap: "2", Align: "center", BoxProps: box.BoxProps{Class: "text-muted-foreground"}}) {
								@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(uiutils.Get(vM, "icon")), Size: 16})
								@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{}}) {
									{ uiutils.Text(uiutils.Get(vM, "label")) }
								}
							}
							@compose.Text(compose.TextProps{Size: "2xl", Weight: "bold", TextProps: text.TextProps{}}) {
								{ uiutils.Text(uiutils.Get(vM, "value")) }
							}
							@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
								{ uiutils.Text(uiutils.Get(vM, "hint")) }
							}
						}
					}
				}
			}
		}
	}
}

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 metric-row
blocks/metric-row.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/metric-row.json
    Dashboard counters in a row or a grid: tiles with an icon, a number and a caption, or compact figures. Axes: columns (2, 4), item (tile, compact), tone (default, muted), density (default, compact).
    Props (p): id, title, metrics, empty, cols, item, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_metrics = (p.metrics ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_cols = (p.cols ?? '4') -%}
{%- set v_item = (p.item ?? 'tile') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_8 -%}
  {%- if og_t(og_eq(og_len(v_metrics), 0)) %}
    {{ include('blocks/empty-state.html.twig', {'p': {'icon': 'gauge', 'title': v_empty}}, with_context = false) }}
  {%- else %}
    {%- set c_7 -%}
      {%- for v_m in og_l(v_metrics) %}
        {%- if og_t(og_eq(v_item, 'tile')) %}
          {%- set c_1 -%}
            {{ include('blocks/stat-tile.html.twig', {'p': {'label': og_get(v_m, ['label']), 'value': og_get(v_m, ['value']), 'icon': og_get(v_m, ['icon']), 'hint': og_get(v_m, ['hint'])}}, with_context = false) }}
          {%- endset -%}
          {{ include('compose/Box.html.twig', {'attrs': og_attrs(['data-slot', 'item']), 'children': c_1}, with_context = false) }}
        {%- else %}
          {%- set c_6 -%}
            {%- set c_3 -%}
              {{ include('icons/LucideIcon.html.twig', {'name': og_s(og_get(v_m, ['icon'])), 'size': 16}, with_context = false) }}
              {%- set c_2 -%}
                {{ og_text(og_get(v_m, ['label'])) }}
              {%- endset -%}
              {{ include('compose/Text.html.twig', {'size': 'xs', 'children': c_2}, with_context = false) }}
            {%- endset -%}
            {{ include('compose/Group.html.twig', {'gap': '2', 'align': 'center', 'class': 'text-muted-foreground', 'children': c_3}, with_context = false) }}
            {%- set c_4 -%}
              {{ og_text(og_get(v_m, ['value'])) }}
            {%- endset -%}
            {{ include('compose/Text.html.twig', {'size': '2xl', 'weight': 'bold', 'children': c_4}, with_context = false) }}
            {%- set c_5 -%}
              {{ og_text(og_get(v_m, ['hint'])) }}
            {%- endset -%}
            {{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_5}, with_context = false) }}
          {%- endset -%}
          {{ include('compose/Stack.html.twig', {'gap': '0', 'class': 'rounded bg-card p-4 inset-ring inset-ring-border', 'attrs': og_attrs(['data-slot', 'item']), 'children': c_6}, with_context = false) }}
        {%- endif %}
      {%- endfor %}
    {%- endset -%}
    {{ include('compose/Grid.html.twig', {'cols': og_s((og_t(og_eq(v_cols, '2')) ? '1-2' : '1-4')), 'class': 'gap-4', 'attrs': og_attrs(['data-slot', 'items']), 'children': c_7}, with_context = false) }}
  {%- endif %}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_8)}, 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 metric-row
blocks/metric-row.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/metric-row.json
    Dashboard counters in a row or a grid: tiles with an icon, a number and a caption, or compact figures. Axes: columns (2, 4), item (tile, compact), tone (default, muted), density (default, compact).
    Props (p): id, title, metrics, empty, cols, item, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_metrics = ($p['metrics'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_cols = ($p['cols'] ?? '4')}
{var $v_item = ($p['item'] ?? 'tile')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_8}
  {if og_t(og_eq(og_len($v_metrics), 0))}
    {=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'gauge', 'title' => $v_empty]])|noescape}
  {else}
    {capture $c_7}
      {foreach og_l($v_metrics) as $v_m}
        {if og_t(og_eq($v_item, 'tile'))}
          {capture $c_1}
            {=og_include('blocks/stat-tile.latte', ['p' => ['label' => og_get($v_m, ['label']), 'value' => og_get($v_m, ['value']), 'icon' => og_get($v_m, ['icon']), 'hint' => og_get($v_m, ['hint'])]])|noescape}
          {/capture}
          {=og_include('compose/Box.latte', ['attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_1])|noescape}
        {else}
          {capture $c_6}
            {capture $c_3}
              {=og_include('icons/LucideIcon.latte', ['name' => og_s(og_get($v_m, ['icon'])), 'size' => 16])|noescape}
              {capture $c_2}
                {=og_text(og_get($v_m, ['label']))}
              {/capture}
              {=og_include('compose/Text.latte', ['size' => 'xs', 'children' => (string) $c_2])|noescape}
            {/capture}
            {=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'center', 'class' => 'text-muted-foreground', 'children' => (string) $c_3])|noescape}
            {capture $c_4}
              {=og_text(og_get($v_m, ['value']))}
            {/capture}
            {=og_include('compose/Text.latte', ['size' => '2xl', 'weight' => 'bold', 'children' => (string) $c_4])|noescape}
            {capture $c_5}
              {=og_text(og_get($v_m, ['hint']))}
            {/capture}
            {=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_5])|noescape}
          {/capture}
          {=og_include('compose/Stack.latte', ['gap' => '0', 'class' => 'rounded bg-card p-4 inset-ring inset-ring-border', 'attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_6])|noescape}
        {/if}
      {/foreach}
    {/capture}
    {=og_include('compose/Grid.latte', ['cols' => og_s((og_t(og_eq($v_cols, '2')) ? '1-2' : '1-4')), 'class' => 'gap-4', 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_7])|noescape}
  {/if}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'tone' => $v_tone, 'density' => $v_density, 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_8)])|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 metric-row
blocks/metric-row.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/metric-row.json
    Dashboard counters in a row or a grid: tiles with an icon, a number and a caption, or compact figures. Axes: columns (2, 4), item (tile, compact), tone (default, muted), density (default, compact).
    Props (p): id, title, metrics, empty, cols, item, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_metrics = og_def(p['metrics'], none) -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_cols = og_def(p['cols'], '4') -%}
{%- set v_item = og_def(p['item'], 'tile') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_density = og_def(p['density'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_8 -%}
  {%- if og_t(og_eq(og_len(v_metrics), 0)) %}
    {{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'gauge', 'title': v_empty}}) }}
  {%- else %}
    {%- set c_7 -%}
      {%- for v_m in og_l(v_metrics) %}
        {%- if og_t(og_eq(v_item, 'tile')) %}
          {%- set c_1 -%}
            {{ og_include('blocks/stat-tile.html.j2', {'p': {'label': og_get(v_m, ['label']), 'value': og_get(v_m, ['value']), 'icon': og_get(v_m, ['icon']), 'hint': og_get(v_m, ['hint'])}}) }}
          {%- endset -%}
          {{ og_include('compose/box.html.j2', {'p': {'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_1}) }}
        {%- else %}
          {%- set c_6 -%}
            {%- set c_3 -%}
              {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(og_get(v_m, ['icon'])), 'Size': 16}}) }}
              {%- set c_2 -%}
                {{ og_text(og_get(v_m, ['label'])) }}
              {%- endset -%}
              {{ og_include('compose/text.html.j2', {'p': {'Size': 'xs'}, 'children': c_2}) }}
            {%- endset -%}
            {{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'center', 'Class': 'text-muted-foreground'}, 'children': c_3}) }}
            {%- set c_4 -%}
              {{ og_text(og_get(v_m, ['value'])) }}
            {%- endset -%}
            {{ og_include('compose/text.html.j2', {'p': {'Size': '2xl', 'Weight': 'bold'}, 'children': c_4}) }}
            {%- set c_5 -%}
              {{ og_text(og_get(v_m, ['hint'])) }}
            {%- endset -%}
            {{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_5}) }}
          {%- endset -%}
          {{ og_include('compose/stack.html.j2', {'p': {'Gap': '0', 'Class': 'rounded bg-card p-4 inset-ring inset-ring-border', 'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_6}) }}
        {%- endif %}
      {%- endfor %}
    {%- endset -%}
    {{ og_include('compose/grid.html.j2', {'p': {'Cols': og_s(('1-2' if og_t(og_eq(v_cols, '2')) else '1-4')), 'Class': 'gap-4', 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_7}) }}
  {%- endif %}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_8)}) }}

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.

Dashboard counters in a row or a grid: tiles with an icon, a number and a caption, or compact figures. Axes: columns (2, 4), item (tile, compact), tone (default, muted), density (default, compact).

Props of MetricRow
PropTypeDefault Description
id (required)string-
title (required)string-
metrics (required)Metric[]-
empty string""the text of the empty state (no records), from the dictionary
cols "2" | "4""4"
item "tile" | "compact""tile"
tone "default" | "muted""default"
density "default" | "compact""default"
landmarkLabel string-accessible name of the landmark of this component when the page shows it more than once (a variant); replaces the heading name of the root landmark, follows the name of a nested one

Used in