Skip to content
ui8kit

block / marketing

Comparison Table

Plans, or a product and its rivals, in columns, and the features in rows; yes and no as marks.

Install

npx ui8kit add comparison-table

Pulls in: box, compare-mark, compose, empty-state, kit-box, section-frame, table, table-body, table-caption, table-cell, table-head, table-head-cell, table-row, utils

Preview

Compare the plans

Features by plan
FeatureFreeProTeam
Team seats110Unlimited
Storage1 GB50 GB1 TB
Single sign-onNot includedNot includedIncluded
Priority supportNot includedIncludedIncluded
Data exportIncludedIncludedIncluded

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 comparison-table
blocks/comparison-table.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. -->
<!--
  Plans, or a product and its competitors, as three columns and the features as rows. A value of yes shows a
  check, no a dash (both with a hidden word), anything else is shown as text. Axes: highlight (none, middle
  column), tone, density.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { CompareRow, CompareLabels } from "./comparison-table.types";

  export type ComparisonTableProps = {
    id: string;
    title: string;
    rows: CompareRow[];
    empty?: string;
    labels: CompareLabels;
    highlight?: "none" | "middle";
    tone?: "default" | "muted";
    density?: "default" | "compact";
    landmarkLabel?: string;
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import Table from "../compose/Table.svelte";
  import TableBody from "../compose/TableBody.svelte";
  import TableCaption from "../compose/TableCaption.svelte";
  import TableCell from "../compose/TableCell.svelte";
  import TableHead from "../compose/TableHead.svelte";
  import TableHeadCell from "../compose/TableHeadCell.svelte";
  import TableRow from "../compose/TableRow.svelte";
  import CompareMark from "../components/compare-mark.svelte";
  import EmptyState from "../components/empty-state.svelte";
  import SectionFrame from "../components/section-frame.svelte";
  import { cn } from "../utils";

  let {
    id,
    title,
    rows,
    empty = "",
    labels,
    highlight = "none",
    tone = "default",
    density = "default",
    landmarkLabel,
  }: ComparisonTableProps = $props();
</script>

<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
  {#if ((rows?.length ?? 0) === 0)}
    <EmptyState icon="table" title={empty} />
  {:else}
    <Box class="relative w-full overflow-x-auto">
      <Table class="w-full text-left text-sm" data-slot="compare">
        <TableCaption class="sr-only">
          {labels.caption}
        </TableCaption>
        <TableHead>
          <TableRow>
            <TableHeadCell scope="col" class="py-4">
              {labels.feature}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-4">
              {labels.a}
            </TableHeadCell>
            <TableHeadCell
              scope="col"
              class={cn("py-4", (((highlight as string) === "middle") ? "bg-muted" : ""))}
              data-highlight={(((highlight as string) === "middle") ? "true" : "false")}
            >
              {labels.b}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-4">
              {labels.c}
            </TableHeadCell>
          </TableRow>
        </TableHead>
        <TableBody>
          {#each rows as row (row.id)}
            <TableRow class="border-t border-border" data-slot="item">
              <TableHeadCell scope="row" class={cn("font-medium", (((density as string) === "compact") ? "py-2" : "py-4"))}>
                {row.label}
              </TableHeadCell>
              <TableCell class={cn((((density as string) === "compact") ? "py-2" : "py-4"))}>
                <CompareMark value={row.a} yes={labels.yes} no={labels.no} />
              </TableCell>
              <TableCell
                class={cn(
                  (((density as string) === "compact") ? "py-2" : "py-4"),
                  (((highlight as string) === "middle") ? "bg-muted font-semibold" : "")
                )}
              >
                <CompareMark value={row.b} yes={labels.yes} no={labels.no} />
              </TableCell>
              <TableCell class={(((density as string) === "compact") ? "py-2" : "py-4")}>
                <CompareMark value={row.c} yes={labels.yes} no={labels.no} />
              </TableCell>
            </TableRow>
          {/each}
        </TableBody>
      </Table>
    </Box>
  {/if}
</SectionFrame>
blocks/comparison-table.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 CompareRow = {
  id: string;
  label: string;
  a: string;
  b: string;
  c: string;
};

export type CompareLabels = {
  caption: string;
  feature: string;
  a: string;
  b: string;
  c: string;
  yes: string;
  no: 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 comparison-table
blocks/comparison-table.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.
/**
 * Plans, or a product and its competitors, as three columns and the features as rows. A value of yes shows a
 * check, no a dash (both with a hidden word), anything else is shown as text. Axes: highlight (none, middle
 * column), tone, density.
 */
import { type ReactNode } from "react";
import { Box, Table, TableBody, TableCaption, TableCell, TableHead, TableHeadCell, TableRow } from "../compose";
import { CompareMark } from "../components/compare-mark";
import { EmptyState } from "../components/empty-state";
import { SectionFrame } from "../components/section-frame";
import { cn } from "../utils";
import type { CompareRow, CompareLabels } from "./comparison-table.types";

export type ComparisonTableProps = {
  id: string;
  title: string;
  rows: CompareRow[];
  empty?: string;
  labels: CompareLabels;
  highlight?: "none" | "middle";
  tone?: "default" | "muted";
  density?: "default" | "compact";
  landmarkLabel?: string;
};

export function ComparisonTable({
  id,
  title,
  rows,
  empty = "",
  labels,
  highlight = "none",
  tone = "default",
  density = "default",
  landmarkLabel,
}: ComparisonTableProps) {
  return (
    <SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
      {((rows?.length ?? 0) === 0) ? (
        <EmptyState icon="table" title={empty} />
      ) : (
        <Box className="relative w-full overflow-x-auto">
          <Table className="w-full text-left text-sm" data-slot="compare">
            <TableCaption className="sr-only">
              {labels.caption}
            </TableCaption>
            <TableHead>
              <TableRow>
                <TableHeadCell scope="col" className="py-4">
                  {labels.feature}
                </TableHeadCell>
                <TableHeadCell scope="col" className="py-4">
                  {labels.a}
                </TableHeadCell>
                <TableHeadCell
                  scope="col"
                  className={cn("py-4", (((highlight as string) === "middle") ? "bg-muted" : ""))}
                  data-highlight={(((highlight as string) === "middle") ? "true" : "false")}
                >
                  {labels.b}
                </TableHeadCell>
                <TableHeadCell scope="col" className="py-4">
                  {labels.c}
                </TableHeadCell>
              </TableRow>
            </TableHead>
            <TableBody>
              {(rows ?? []).map((row) => (
                <TableRow key={row.id} className="border-t border-border" data-slot="item">
                  <TableHeadCell
                    scope="row"
                    className={cn("font-medium", (((density as string) === "compact") ? "py-2" : "py-4"))}
                  >
                    {row.label}
                  </TableHeadCell>
                  <TableCell className={cn((((density as string) === "compact") ? "py-2" : "py-4"))}>
                    <CompareMark value={row.a} yes={labels.yes} no={labels.no} />
                  </TableCell>
                  <TableCell
                    className={cn(
                      (((density as string) === "compact") ? "py-2" : "py-4"),
                      (((highlight as string) === "middle") ? "bg-muted font-semibold" : "")
                    )}
                  >
                    <CompareMark value={row.b} yes={labels.yes} no={labels.no} />
                  </TableCell>
                  <TableCell className={(((density as string) === "compact") ? "py-2" : "py-4")}>
                    <CompareMark value={row.c} yes={labels.yes} no={labels.no} />
                  </TableCell>
                </TableRow>
              ))}
            </TableBody>
          </Table>
        </Box>
      )}
    </SectionFrame>
  );
}
blocks/comparison-table.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 CompareRow = {
  id: string;
  label: string;
  a: string;
  b: string;
  c: string;
};

export type CompareLabels = {
  caption: string;
  feature: string;
  a: string;
  b: string;
  c: string;
  yes: string;
  no: 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 comparison-table
blocks/comparison-table.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 CompareRow = {
  id: string;
  label: string;
  a: string;
  b: string;
  c: string;
};

export type CompareLabels = {
  caption: string;
  feature: string;
  a: string;
  b: string;
  c: string;
  yes: string;
  no: string;
};
blocks/comparison-table.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. -->
<!--
  Plans, or a product and its competitors, as three columns and the features as rows. A value of yes shows a
  check, no a dash (both with a hidden word), anything else is shown as text. Axes: highlight (none, middle
  column), tone, density.
-->
<script lang="ts">
import type { CompareRow, CompareLabels } from "./comparison-table.types";

export type ComparisonTableProps = {
  id: string;
  title: string;
  rows: CompareRow[];
  empty?: string;
  labels: CompareLabels;
  highlight?: "none" | "middle";
  tone?: "default" | "muted";
  density?: "default" | "compact";
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import Table from "../compose/Table.vue";
import TableBody from "../compose/TableBody.vue";
import TableCaption from "../compose/TableCaption.vue";
import TableCell from "../compose/TableCell.vue";
import TableHead from "../compose/TableHead.vue";
import TableHeadCell from "../compose/TableHeadCell.vue";
import TableRow from "../compose/TableRow.vue";
import CompareMark from "../components/compare-mark.vue";
import EmptyState from "../components/empty-state.vue";
import SectionFrame from "../components/section-frame.vue";
import { cn } from "../utils";

const {
  id,
  title,
  rows,
  empty = "",
  labels,
  highlight = "none",
  tone = "default",
  density = "default",
  landmarkLabel,
} = defineProps<ComparisonTableProps>();
</script>

<template>
  <SectionFrame :id="id" :title="title" :tone="tone" :density="density" :landmarkLabel="landmarkLabel">
    <EmptyState v-if="((rows?.length ?? 0) === 0)" icon="table" :title="empty" />
    <Box v-else class="relative w-full overflow-x-auto">
      <Table class="w-full text-left text-sm" data-slot="compare">
        <TableCaption class="sr-only">
          {{ labels.caption }}
        </TableCaption>
        <TableHead>
          <TableRow>
            <TableHeadCell scope="col" class="py-4">
              {{ labels.feature }}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-4">
              {{ labels.a }}
            </TableHeadCell>
            <TableHeadCell
              scope="col"
              :class="cn('py-4', (((highlight as string) === 'middle') ? 'bg-muted' : ''))"
              :data-highlight="(((highlight as string) === 'middle') ? 'true' : 'false')"
            >
              {{ labels.b }}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-4">
              {{ labels.c }}
            </TableHeadCell>
          </TableRow>
        </TableHead>
        <TableBody>
          <TableRow v-for="row in rows" :key="row.id" class="border-t border-border" data-slot="item">
            <TableHeadCell scope="row" :class="cn('font-medium', (((density as string) === 'compact') ? 'py-2' : 'py-4'))">
              {{ row.label }}
            </TableHeadCell>
            <TableCell :class="cn((((density as string) === 'compact') ? 'py-2' : 'py-4'))">
              <CompareMark :value="row.a" :yes="labels.yes" :no="labels.no" />
            </TableCell>
            <TableCell
              :class="cn(
                (((density as string) === 'compact') ? 'py-2' : 'py-4'),
                (((highlight as string) === 'middle') ? 'bg-muted font-semibold' : '')
              )"
            >
              <CompareMark :value="row.b" :yes="labels.yes" :no="labels.no" />
            </TableCell>
            <TableCell :class="(((density as string) === 'compact') ? 'py-2' : 'py-4')">
              <CompareMark :value="row.c" :yes="labels.yes" :no="labels.no" />
            </TableCell>
          </TableRow>
        </TableBody>
      </Table>
    </Box>
  </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 comparison-table
blocks/comparison-table.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.
/**
 * Plans, or a product and its competitors, as three columns and the features as rows. A value of yes shows a
 * check, no a dash (both with a hidden word), anything else is shown as text. Axes: highlight (none, middle
 * column), tone, density.
 */
import { For, type JSX } from "solid-js";
import { Box, Table, TableBody, TableCaption, TableCell, TableHead, TableHeadCell, TableRow } from "../compose";
import { CompareMark } from "../components/compare-mark";
import { EmptyState } from "../components/empty-state";
import { SectionFrame } from "../components/section-frame";
import { cn } from "../utils";
import type { CompareRow, CompareLabels } from "./comparison-table.types";

export type ComparisonTableProps = {
  id: string;
  title: string;
  rows: CompareRow[];
  empty?: string;
  labels: CompareLabels;
  highlight?: "none" | "middle";
  tone?: "default" | "muted";
  density?: "default" | "compact";
  landmarkLabel?: string;
};

export function ComparisonTable({
  id,
  title,
  rows,
  empty = "",
  labels,
  highlight = "none",
  tone = "default",
  density = "default",
  landmarkLabel,
}: ComparisonTableProps) {
  return (
    <SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
      {((rows?.length ?? 0) === 0) ? (
        <EmptyState icon="table" title={empty} />
      ) : (
        <Box class="relative w-full overflow-x-auto">
          <Table class="w-full text-left text-sm" data-slot="compare">
            <TableCaption class="sr-only">
              {labels.caption}
            </TableCaption>
            <TableHead>
              <TableRow>
                <TableHeadCell scope="col" class="py-4">
                  {labels.feature}
                </TableHeadCell>
                <TableHeadCell scope="col" class="py-4">
                  {labels.a}
                </TableHeadCell>
                <TableHeadCell
                  scope="col"
                  class={cn("py-4", (((highlight as string) === "middle") ? "bg-muted" : ""))}
                  data-highlight={(((highlight as string) === "middle") ? "true" : "false")}
                >
                  {labels.b}
                </TableHeadCell>
                <TableHeadCell scope="col" class="py-4">
                  {labels.c}
                </TableHeadCell>
              </TableRow>
            </TableHead>
            <TableBody>
              <For each={rows ?? []}>{(row) => (
                <TableRow class="border-t border-border" data-slot="item">
                  <TableHeadCell scope="row" class={cn("font-medium", (((density as string) === "compact") ? "py-2" : "py-4"))}>
                    {row.label}
                  </TableHeadCell>
                  <TableCell class={cn((((density as string) === "compact") ? "py-2" : "py-4"))}>
                    <CompareMark value={row.a} yes={labels.yes} no={labels.no} />
                  </TableCell>
                  <TableCell
                    class={cn(
                      (((density as string) === "compact") ? "py-2" : "py-4"),
                      (((highlight as string) === "middle") ? "bg-muted font-semibold" : "")
                    )}
                  >
                    <CompareMark value={row.b} yes={labels.yes} no={labels.no} />
                  </TableCell>
                  <TableCell class={(((density as string) === "compact") ? "py-2" : "py-4")}>
                    <CompareMark value={row.c} yes={labels.yes} no={labels.no} />
                  </TableCell>
                </TableRow>
              )}</For>
            </TableBody>
          </Table>
        </Box>
      )}
    </SectionFrame>
  );
}
blocks/comparison-table.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 CompareRow = {
  id: string;
  label: string;
  a: string;
  b: string;
  c: string;
};

export type CompareLabels = {
  caption: string;
  feature: string;
  a: string;
  b: string;
  c: string;
  yes: string;
  no: 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 comparison-table
blocks/comparison-table.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/comparison-table.json

package blocks

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

// ComparisonTableProps are the props of ComparisonTable; the values are the JSON shapes of the TypeScript props.
type ComparisonTableProps struct {
	Id any `json:"id"`
	Title any `json:"title"`
	Rows any `json:"rows"`
	Empty any `json:"empty"`
	Labels any `json:"labels"`
	Highlight any `json:"highlight"`
	Tone any `json:"tone"`
	Density any `json:"density"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// Plans, or a product and its competitors, as three columns and the features as rows. A value of yes shows a check, no a dash (both with a hidden word), anything else is shown as text. Axes: highlight (none, middle column), tone, density.
templ ComparisonTable(p ComparisonTableProps) {
	{{ vId := p.Id }}
	{{ vTitle := p.Title }}
	{{ vRows := p.Rows }}
	{{ vEmpty := uiutils.Def(p.Empty, "") }}
	{{ vLabels := p.Labels }}
	{{ vHighlight := uiutils.Def(p.Highlight, "none") }}
	{{ 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(vRows), float64(0)) {
			@EmptyState(EmptyStateProps{Icon: "table", Title: vEmpty})
		} else {
			@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "relative w-full overflow-x-auto"}}) {
				@compose.Table(compose.TableProps{BoxProps: box.BoxProps{Class: "w-full text-left text-sm", Attrs: uiutils.Attrs("data-slot", "compare")}}) {
					@compose.TableCaption(compose.TableCaptionProps{BoxProps: box.BoxProps{Class: "sr-only"}}) {
						{ uiutils.Text(uiutils.Get(vLabels, "caption")) }
					}
					@compose.TableHead(compose.TableHeadProps{BoxProps: box.BoxProps{}}) {
						@compose.TableRow(compose.TableRowProps{BoxProps: box.BoxProps{}}) {
							@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: "py-4", Attrs: uiutils.Attrs("scope", "col")}}) {
								{ uiutils.Text(uiutils.Get(vLabels, "feature")) }
							}
							@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: "py-4", Attrs: uiutils.Attrs("scope", "col")}}) {
								{ uiutils.Text(uiutils.Get(vLabels, "a")) }
							}
							@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("py-4", uiutils.Cond(uiutils.T(uiutils.Eq(vHighlight, "middle")), "bg-muted", ""))), Attrs: uiutils.Attrs("scope", "col", "data-highlight", uiutils.Cond(uiutils.T(uiutils.Eq(vHighlight, "middle")), "true", "false"))}}) {
								{ uiutils.Text(uiutils.Get(vLabels, "b")) }
							}
							@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: "py-4", Attrs: uiutils.Attrs("scope", "col")}}) {
								{ uiutils.Text(uiutils.Get(vLabels, "c")) }
							}
						}
					}
					@compose.TableBody(compose.TableBodyProps{BoxProps: box.BoxProps{}}) {
						for _, vRow := range uiutils.L(vRows) {
							@compose.TableRow(compose.TableRowProps{BoxProps: box.BoxProps{Class: "border-t border-border", Attrs: uiutils.Attrs("data-slot", "item")}}) {
								@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("font-medium", uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "py-2", "py-4"))), Attrs: uiutils.Attrs("scope", "row")}}) {
									{ uiutils.Text(uiutils.Get(vRow, "label")) }
								}
								@compose.TableCell(compose.TableCellProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv(uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "py-2", "py-4")))}}) {
									@CompareMark(CompareMarkProps{Value: uiutils.Get(vRow, "a"), Yes: uiutils.Get(vLabels, "yes"), No: uiutils.Get(vLabels, "no")})
								}
								@compose.TableCell(compose.TableCellProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv(uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "py-2", "py-4"), uiutils.Cond(uiutils.T(uiutils.Eq(vHighlight, "middle")), "bg-muted font-semibold", "")))}}) {
									@CompareMark(CompareMarkProps{Value: uiutils.Get(vRow, "b"), Yes: uiutils.Get(vLabels, "yes"), No: uiutils.Get(vLabels, "no")})
								}
								@compose.TableCell(compose.TableCellProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "py-2", "py-4"))}}) {
									@CompareMark(CompareMarkProps{Value: uiutils.Get(vRow, "c"), Yes: uiutils.Get(vLabels, "yes"), No: uiutils.Get(vLabels, "no")})
								}
							}
						}
					}
				}
			}
		}
	}
}

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 comparison-table
blocks/comparison-table.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/comparison-table.json
    Plans, or a product and its competitors, as three columns and the features as rows. A value of yes shows a check, no a dash (both with a hidden word), anything else is shown as text. Axes: highlight (none, middle column), tone, density.
    Props (p): id, title, rows, empty, labels, highlight, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_rows = (p.rows ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_highlight = (p.highlight ?? 'none') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_16 -%}
  {%- if og_t(og_eq(og_len(v_rows), 0)) %}
    {{ include('blocks/empty-state.html.twig', {'p': {'icon': 'table', 'title': v_empty}}, with_context = false) }}
  {%- else %}
    {%- set c_15 -%}
      {%- set c_14 -%}
        {%- set c_1 -%}
          {{ og_text(og_get(v_labels, ['caption'])) }}
        {%- endset -%}
        {{ include('compose/TableCaption.html.twig', {'class': 'sr-only', 'children': c_1}, with_context = false) }}
        {%- set c_7 -%}
          {%- set c_6 -%}
            {%- set c_2 -%}
              {{ og_text(og_get(v_labels, ['feature'])) }}
            {%- endset -%}
            {{ include('compose/TableHeadCell.html.twig', {'class': 'py-4', 'attrs': og_attrs(['scope', 'col']), 'children': c_2}, with_context = false) }}
            {%- set c_3 -%}
              {{ og_text(og_get(v_labels, ['a'])) }}
            {%- endset -%}
            {{ include('compose/TableHeadCell.html.twig', {'class': 'py-4', 'attrs': og_attrs(['scope', 'col']), 'children': c_3}, with_context = false) }}
            {%- set c_4 -%}
              {{ og_text(og_get(v_labels, ['b'])) }}
            {%- endset -%}
            {{ include('compose/TableHeadCell.html.twig', {'class': og_s(og_cnv(['py-4', (og_t(og_eq(v_highlight, 'middle')) ? 'bg-muted' : '')])), 'attrs': og_attrs(['scope', 'col', 'data-highlight', (og_t(og_eq(v_highlight, 'middle')) ? 'true' : 'false')]), 'children': c_4}, with_context = false) }}
            {%- set c_5 -%}
              {{ og_text(og_get(v_labels, ['c'])) }}
            {%- endset -%}
            {{ include('compose/TableHeadCell.html.twig', {'class': 'py-4', 'attrs': og_attrs(['scope', 'col']), 'children': c_5}, with_context = false) }}
          {%- endset -%}
          {{ include('compose/TableRow.html.twig', {'children': c_6}, with_context = false) }}
        {%- endset -%}
        {{ include('compose/TableHead.html.twig', {'children': c_7}, with_context = false) }}
        {%- set c_13 -%}
          {%- for v_row in og_l(v_rows) %}
            {%- set c_12 -%}
              {%- set c_8 -%}
                {{ og_text(og_get(v_row, ['label'])) }}
              {%- endset -%}
              {{ include('compose/TableHeadCell.html.twig', {'class': og_s(og_cnv(['font-medium', (og_t(og_eq(v_density, 'compact')) ? 'py-2' : 'py-4')])), 'attrs': og_attrs(['scope', 'row']), 'children': c_8}, with_context = false) }}
              {%- set c_9 -%}
                {{ include('blocks/compare-mark.html.twig', {'p': {'value': og_get(v_row, ['a']), 'yes': og_get(v_labels, ['yes']), 'no': og_get(v_labels, ['no'])}}, with_context = false) }}
              {%- endset -%}
              {{ include('compose/TableCell.html.twig', {'class': og_s(og_cnv([(og_t(og_eq(v_density, 'compact')) ? 'py-2' : 'py-4')])), 'children': c_9}, with_context = false) }}
              {%- set c_10 -%}
                {{ include('blocks/compare-mark.html.twig', {'p': {'value': og_get(v_row, ['b']), 'yes': og_get(v_labels, ['yes']), 'no': og_get(v_labels, ['no'])}}, with_context = false) }}
              {%- endset -%}
              {{ include('compose/TableCell.html.twig', {'class': og_s(og_cnv([(og_t(og_eq(v_density, 'compact')) ? 'py-2' : 'py-4'), (og_t(og_eq(v_highlight, 'middle')) ? 'bg-muted font-semibold' : '')])), 'children': c_10}, with_context = false) }}
              {%- set c_11 -%}
                {{ include('blocks/compare-mark.html.twig', {'p': {'value': og_get(v_row, ['c']), 'yes': og_get(v_labels, ['yes']), 'no': og_get(v_labels, ['no'])}}, with_context = false) }}
              {%- endset -%}
              {{ include('compose/TableCell.html.twig', {'class': og_s((og_t(og_eq(v_density, 'compact')) ? 'py-2' : 'py-4')), 'children': c_11}, with_context = false) }}
            {%- endset -%}
            {{ include('compose/TableRow.html.twig', {'class': 'border-t border-border', 'attrs': og_attrs(['data-slot', 'item']), 'children': c_12}, with_context = false) }}
          {%- endfor %}
        {%- endset -%}
        {{ include('compose/TableBody.html.twig', {'children': c_13}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Table.html.twig', {'class': 'w-full text-left text-sm', 'attrs': og_attrs(['data-slot', 'compare']), 'children': c_14}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Box.html.twig', {'class': 'relative w-full overflow-x-auto', 'children': c_15}, 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_16)}, 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 comparison-table
blocks/comparison-table.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/comparison-table.json
    Plans, or a product and its competitors, as three columns and the features as rows. A value of yes shows a check, no a dash (both with a hidden word), anything else is shown as text. Axes: highlight (none, middle column), tone, density.
    Props (p): id, title, rows, empty, labels, highlight, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_rows = ($p['rows'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_highlight = ($p['highlight'] ?? 'none')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_16}
  {if og_t(og_eq(og_len($v_rows), 0))}
    {=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'table', 'title' => $v_empty]])|noescape}
  {else}
    {capture $c_15}
      {capture $c_14}
        {capture $c_1}
          {=og_text(og_get($v_labels, ['caption']))}
        {/capture}
        {=og_include('compose/TableCaption.latte', ['class' => 'sr-only', 'children' => (string) $c_1])|noescape}
        {capture $c_7}
          {capture $c_6}
            {capture $c_2}
              {=og_text(og_get($v_labels, ['feature']))}
            {/capture}
            {=og_include('compose/TableHeadCell.latte', ['class' => 'py-4', 'attrs' => og_attrs(['scope', 'col']), 'children' => (string) $c_2])|noescape}
            {capture $c_3}
              {=og_text(og_get($v_labels, ['a']))}
            {/capture}
            {=og_include('compose/TableHeadCell.latte', ['class' => 'py-4', 'attrs' => og_attrs(['scope', 'col']), 'children' => (string) $c_3])|noescape}
            {capture $c_4}
              {=og_text(og_get($v_labels, ['b']))}
            {/capture}
            {=og_include('compose/TableHeadCell.latte', ['class' => og_s(og_cnv(['py-4', (og_t(og_eq($v_highlight, 'middle')) ? 'bg-muted' : '')])), 'attrs' => og_attrs(['scope', 'col', 'data-highlight', (og_t(og_eq($v_highlight, 'middle')) ? 'true' : 'false')]), 'children' => (string) $c_4])|noescape}
            {capture $c_5}
              {=og_text(og_get($v_labels, ['c']))}
            {/capture}
            {=og_include('compose/TableHeadCell.latte', ['class' => 'py-4', 'attrs' => og_attrs(['scope', 'col']), 'children' => (string) $c_5])|noescape}
          {/capture}
          {=og_include('compose/TableRow.latte', ['children' => (string) $c_6])|noescape}
        {/capture}
        {=og_include('compose/TableHead.latte', ['children' => (string) $c_7])|noescape}
        {capture $c_13}
          {foreach og_l($v_rows) as $v_row}
            {capture $c_12}
              {capture $c_8}
                {=og_text(og_get($v_row, ['label']))}
              {/capture}
              {=og_include('compose/TableHeadCell.latte', ['class' => og_s(og_cnv(['font-medium', (og_t(og_eq($v_density, 'compact')) ? 'py-2' : 'py-4')])), 'attrs' => og_attrs(['scope', 'row']), 'children' => (string) $c_8])|noescape}
              {capture $c_9}
                {=og_include('blocks/compare-mark.latte', ['p' => ['value' => og_get($v_row, ['a']), 'yes' => og_get($v_labels, ['yes']), 'no' => og_get($v_labels, ['no'])]])|noescape}
              {/capture}
              {=og_include('compose/TableCell.latte', ['class' => og_s(og_cnv([(og_t(og_eq($v_density, 'compact')) ? 'py-2' : 'py-4')])), 'children' => (string) $c_9])|noescape}
              {capture $c_10}
                {=og_include('blocks/compare-mark.latte', ['p' => ['value' => og_get($v_row, ['b']), 'yes' => og_get($v_labels, ['yes']), 'no' => og_get($v_labels, ['no'])]])|noescape}
              {/capture}
              {=og_include('compose/TableCell.latte', ['class' => og_s(og_cnv([(og_t(og_eq($v_density, 'compact')) ? 'py-2' : 'py-4'), (og_t(og_eq($v_highlight, 'middle')) ? 'bg-muted font-semibold' : '')])), 'children' => (string) $c_10])|noescape}
              {capture $c_11}
                {=og_include('blocks/compare-mark.latte', ['p' => ['value' => og_get($v_row, ['c']), 'yes' => og_get($v_labels, ['yes']), 'no' => og_get($v_labels, ['no'])]])|noescape}
              {/capture}
              {=og_include('compose/TableCell.latte', ['class' => og_s((og_t(og_eq($v_density, 'compact')) ? 'py-2' : 'py-4')), 'children' => (string) $c_11])|noescape}
            {/capture}
            {=og_include('compose/TableRow.latte', ['class' => 'border-t border-border', 'attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_12])|noescape}
          {/foreach}
        {/capture}
        {=og_include('compose/TableBody.latte', ['children' => (string) $c_13])|noescape}
      {/capture}
      {=og_include('compose/Table.latte', ['class' => 'w-full text-left text-sm', 'attrs' => og_attrs(['data-slot', 'compare']), 'children' => (string) $c_14])|noescape}
    {/capture}
    {=og_include('compose/Box.latte', ['class' => 'relative w-full overflow-x-auto', 'children' => (string) $c_15])|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_16)])|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 comparison-table
blocks/comparison-table.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/comparison-table.json
    Plans, or a product and its competitors, as three columns and the features as rows. A value of yes shows a check, no a dash (both with a hidden word), anything else is shown as text. Axes: highlight (none, middle column), tone, density.
    Props (p): id, title, rows, empty, labels, highlight, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_rows = og_def(p['rows'], none) -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_highlight = og_def(p['highlight'], 'none') -%}
{%- 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_16 -%}
  {%- if og_t(og_eq(og_len(v_rows), 0)) %}
    {{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'table', 'title': v_empty}}) }}
  {%- else %}
    {%- set c_15 -%}
      {%- set c_14 -%}
        {%- set c_1 -%}
          {{ og_text(og_get(v_labels, ['caption'])) }}
        {%- endset -%}
        {{ og_include('compose/table-caption.html.j2', {'p': {'Class': 'sr-only'}, 'children': c_1}) }}
        {%- set c_7 -%}
          {%- set c_6 -%}
            {%- set c_2 -%}
              {{ og_text(og_get(v_labels, ['feature'])) }}
            {%- endset -%}
            {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': 'py-4', 'Attrs': og_attrs(['scope', 'col'])}, 'children': c_2}) }}
            {%- set c_3 -%}
              {{ og_text(og_get(v_labels, ['a'])) }}
            {%- endset -%}
            {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': 'py-4', 'Attrs': og_attrs(['scope', 'col'])}, 'children': c_3}) }}
            {%- set c_4 -%}
              {{ og_text(og_get(v_labels, ['b'])) }}
            {%- endset -%}
            {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': og_s(og_cnv(['py-4', ('bg-muted' if og_t(og_eq(v_highlight, 'middle')) else '')])), 'Attrs': og_attrs(['scope', 'col', 'data-highlight', ('true' if og_t(og_eq(v_highlight, 'middle')) else 'false')])}, 'children': c_4}) }}
            {%- set c_5 -%}
              {{ og_text(og_get(v_labels, ['c'])) }}
            {%- endset -%}
            {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': 'py-4', 'Attrs': og_attrs(['scope', 'col'])}, 'children': c_5}) }}
          {%- endset -%}
          {{ og_include('compose/table-row.html.j2', {'p': {}, 'children': c_6}) }}
        {%- endset -%}
        {{ og_include('compose/table-head.html.j2', {'p': {}, 'children': c_7}) }}
        {%- set c_13 -%}
          {%- for v_row in og_l(v_rows) %}
            {%- set c_12 -%}
              {%- set c_8 -%}
                {{ og_text(og_get(v_row, ['label'])) }}
              {%- endset -%}
              {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': og_s(og_cnv(['font-medium', ('py-2' if og_t(og_eq(v_density, 'compact')) else 'py-4')])), 'Attrs': og_attrs(['scope', 'row'])}, 'children': c_8}) }}
              {%- set c_9 -%}
                {{ og_include('blocks/compare-mark.html.j2', {'p': {'value': og_get(v_row, ['a']), 'yes': og_get(v_labels, ['yes']), 'no': og_get(v_labels, ['no'])}}) }}
              {%- endset -%}
              {{ og_include('compose/table-cell.html.j2', {'p': {'Class': og_s(og_cnv([('py-2' if og_t(og_eq(v_density, 'compact')) else 'py-4')]))}, 'children': c_9}) }}
              {%- set c_10 -%}
                {{ og_include('blocks/compare-mark.html.j2', {'p': {'value': og_get(v_row, ['b']), 'yes': og_get(v_labels, ['yes']), 'no': og_get(v_labels, ['no'])}}) }}
              {%- endset -%}
              {{ og_include('compose/table-cell.html.j2', {'p': {'Class': og_s(og_cnv([('py-2' if og_t(og_eq(v_density, 'compact')) else 'py-4'), ('bg-muted font-semibold' if og_t(og_eq(v_highlight, 'middle')) else '')]))}, 'children': c_10}) }}
              {%- set c_11 -%}
                {{ og_include('blocks/compare-mark.html.j2', {'p': {'value': og_get(v_row, ['c']), 'yes': og_get(v_labels, ['yes']), 'no': og_get(v_labels, ['no'])}}) }}
              {%- endset -%}
              {{ og_include('compose/table-cell.html.j2', {'p': {'Class': og_s(('py-2' if og_t(og_eq(v_density, 'compact')) else 'py-4'))}, 'children': c_11}) }}
            {%- endset -%}
            {{ og_include('compose/table-row.html.j2', {'p': {'Class': 'border-t border-border', 'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_12}) }}
          {%- endfor %}
        {%- endset -%}
        {{ og_include('compose/table-body.html.j2', {'p': {}, 'children': c_13}) }}
      {%- endset -%}
      {{ og_include('compose/table.html.j2', {'p': {'Class': 'w-full text-left text-sm', 'Attrs': og_attrs(['data-slot', 'compare'])}, 'children': c_14}) }}
    {%- endset -%}
    {{ og_include('compose/box.html.j2', {'p': {'Class': 'relative w-full overflow-x-auto'}, 'children': c_15}) }}
  {%- 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_16)}) }}

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.

Plans, or a product and its competitors, as three columns and the features as rows. A value of yes shows a check, no a dash (both with a hidden word), anything else is shown as text. Axes: highlight (none, middle column), tone, density.

Props of ComparisonTable
PropTypeDefault Description
id (required)string-
title (required)string-
rows (required)CompareRow[]-
empty string""the text of the empty state (no records), from the dictionary
labels (required)CompareLabels-
highlight "none" | "middle""none"middle: the second column stands out
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