Skip to content
ui8kit

block / marketing

Bento Grid

Tiles of different sizes in one grid; the large tiles hold the main features.

Install

npx ui8kit add bento-grid

Pulls in: card, card-content, compose, empty-state, grid, kit-box, kit-text, lucide-icon, media-frame, section-frame, text, title, utils

Preview

Everything in one place

Fast by default

Pages ship little script and load in under a second.

Ready blocks

Compose a page from tested blocks and variants.

Accessible

Landmarks, labels and focus order are checked.

Light and dark

Every block follows the theme tokens.

One source of data

Pages read collections, never copies.

Private by default

Your data stays in your collections.

Export anywhere

Take pages and data with you.

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 bento-grid
blocks/bento-grid.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. -->
<!--
  Tiles of different sizes in one grid: the large and wide tiles hold the important features. Sizes come from
  the data (large, wide, small). Axes: layout (bento, even: all tiles alike), media (none, image: a picture in
  the large tiles), tone, density.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { Tile } from "./bento-grid.types";

  export type BentoGridProps = {
    id: string;
    title: string;
    tiles: Tile[];
    empty?: string;
    layout?: "bento" | "even";
    media?: "none" | "image";
    tone?: "default" | "muted";
    density?: "default" | "compact";
    landmarkLabel?: string;
  };
</script>

<script lang="ts">
  import Card from "../compose/Card.svelte";
  import CardContent from "../compose/CardContent.svelte";
  import Grid from "../compose/Grid.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";
  import Text from "../compose/Text.svelte";
  import Title from "../compose/Title.svelte";
  import EmptyState from "../components/empty-state.svelte";
  import MediaFrame from "../components/media-frame.svelte";
  import SectionFrame from "../components/section-frame.svelte";
  import { at, cn } from "../utils";

  const SPAN: Record<string, string> = {
    "large": "md:col-span-2 md:row-span-2",
    "wide": "md:col-span-2",
    "small": "",
  };
  let {
    id,
    title,
    tiles,
    empty = "",
    layout = "bento",
    media = "none",
    tone = "default",
    density = "default",
    landmarkLabel,
  }: BentoGridProps = $props();
</script>

<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
  {#if ((tiles?.length ?? 0) === 0)}
    <EmptyState icon="layout-dashboard" title={empty} />
  {:else}
    <Grid cols="1-4" class="auto-rows-fr gap-4" data-slot="items">
      {#each tiles as tile (tile.id)}
        <Card
          variant="default"
          class={cn(
            "h-full overflow-hidden",
            (((density as string) === "compact") ? "gap-4 p-4" : ""),
            (((layout as string) === "bento") ? at(SPAN, tile.size) : "")
          )}
          data-size={(((layout as string) === "bento") ? tile.size : "even")}
        >
          <CardContent class="flex h-full flex-col gap-4">
            <LucideIcon name={tile.icon} size={24} />
            <Title as={3} size="xl" weight="bold">
              {tile.title}
            </Title>
            <Text size="sm" class="text-muted-foreground">
              {tile.text}
            </Text>
            {#if (((media as string) === "image") && ((tile.size === "large") || ((layout as string) === "even")))}
              <MediaFrame alt={tile.title} src={tile.image} ratio="4/3" class="mt-auto" />
            {/if}
          </CardContent>
        </Card>
      {/each}
    </Grid>
  {/if}
</SectionFrame>
blocks/bento-grid.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 Tile = {
  id: string;
  title: string;
  text: string;
  icon: string;
  size: string;
  image?: 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 bento-grid
blocks/bento-grid.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.
/**
 * Tiles of different sizes in one grid: the large and wide tiles hold the important features. Sizes come from
 * the data (large, wide, small). Axes: layout (bento, even: all tiles alike), media (none, image: a picture in
 * the large tiles), tone, density.
 */
import { type ReactNode } from "react";
import { Card, CardContent, Grid, Text, Title } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { at, cn } from "../utils";
import type { Tile } from "./bento-grid.types";

const SPAN: Record<string, string> = {
  "large": "md:col-span-2 md:row-span-2",
  "wide": "md:col-span-2",
  "small": "",
};

export type BentoGridProps = {
  id: string;
  title: string;
  tiles: Tile[];
  empty?: string;
  layout?: "bento" | "even";
  media?: "none" | "image";
  tone?: "default" | "muted";
  density?: "default" | "compact";
  landmarkLabel?: string;
};

export function BentoGrid({
  id,
  title,
  tiles,
  empty = "",
  layout = "bento",
  media = "none",
  tone = "default",
  density = "default",
  landmarkLabel,
}: BentoGridProps) {
  return (
    <SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
      {((tiles?.length ?? 0) === 0) ? (
        <EmptyState icon="layout-dashboard" title={empty} />
      ) : (
        <Grid cols="1-4" className="auto-rows-fr gap-4" data-slot="items">
          {(tiles ?? []).map((tile) => (
            <Card key={tile.id}
              variant="default"
              className={cn(
                "h-full overflow-hidden",
                (((density as string) === "compact") ? "gap-4 p-4" : ""),
                (((layout as string) === "bento") ? at(SPAN, tile.size) : "")
              )}
              data-size={(((layout as string) === "bento") ? tile.size : "even")}
            >
              <CardContent className="flex h-full flex-col gap-4">
                <LucideIcon name={tile.icon} size={24} />
                <Title as={3} size="xl" weight="bold">
                  {tile.title}
                </Title>
                <Text size="sm" className="text-muted-foreground">
                  {tile.text}
                </Text>
                {(((media as string) === "image") && ((tile.size === "large") || ((layout as string) === "even"))) ? (
                  <MediaFrame alt={tile.title} src={tile.image} ratio="4/3" className="mt-auto" />
                ) : null}
              </CardContent>
            </Card>
          ))}
        </Grid>
      )}
    </SectionFrame>
  );
}
blocks/bento-grid.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 Tile = {
  id: string;
  title: string;
  text: string;
  icon: string;
  size: string;
  image?: 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 bento-grid
blocks/bento-grid.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 Tile = {
  id: string;
  title: string;
  text: string;
  icon: string;
  size: string;
  image?: string;
};
blocks/bento-grid.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. -->
<!--
  Tiles of different sizes in one grid: the large and wide tiles hold the important features. Sizes come from
  the data (large, wide, small). Axes: layout (bento, even: all tiles alike), media (none, image: a picture in
  the large tiles), tone, density.
-->
<script lang="ts">
import type { Tile } from "./bento-grid.types";

export type BentoGridProps = {
  id: string;
  title: string;
  tiles: Tile[];
  empty?: string;
  layout?: "bento" | "even";
  media?: "none" | "image";
  tone?: "default" | "muted";
  density?: "default" | "compact";
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Card from "../compose/Card.vue";
import CardContent from "../compose/CardContent.vue";
import Grid from "../compose/Grid.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
import EmptyState from "../components/empty-state.vue";
import MediaFrame from "../components/media-frame.vue";
import SectionFrame from "../components/section-frame.vue";
import { at, cn } from "../utils";

const SPAN: Record<string, string> = {
  "large": "md:col-span-2 md:row-span-2",
  "wide": "md:col-span-2",
  "small": "",
};
const {
  id,
  title,
  tiles,
  empty = "",
  layout = "bento",
  media = "none",
  tone = "default",
  density = "default",
  landmarkLabel,
} = defineProps<BentoGridProps>();
</script>

<template>
  <SectionFrame :id="id" :title="title" :tone="tone" :density="density" :landmarkLabel="landmarkLabel">
    <EmptyState v-if="((tiles?.length ?? 0) === 0)" icon="layout-dashboard" :title="empty" />
    <Grid v-else cols="1-4" class="auto-rows-fr gap-4" data-slot="items">
      <Card v-for="tile in tiles" :key="tile.id"
        variant="default"
        :class="cn(
          'h-full overflow-hidden',
          (((density as string) === 'compact') ? 'gap-4 p-4' : ''),
          (((layout as string) === 'bento') ? at(SPAN, tile.size) : '')
        )"
        :data-size="(((layout as string) === 'bento') ? tile.size : 'even')"
      >
        <CardContent class="flex h-full flex-col gap-4">
          <LucideIcon :name="tile.icon" :size="24" />
          <Title :as="3" size="xl" weight="bold">
            {{ tile.title }}
          </Title>
          <Text size="sm" class="text-muted-foreground">
            {{ tile.text }}
          </Text>
          <MediaFrame
            v-if="(((media as string) === 'image') && ((tile.size === 'large') || ((layout as string) === 'even')))"
            :alt="tile.title"
            :src="tile.image"
            ratio="4/3"
            class="mt-auto"
          />
        </CardContent>
      </Card>
    </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 bento-grid
blocks/bento-grid.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.
/**
 * Tiles of different sizes in one grid: the large and wide tiles hold the important features. Sizes come from
 * the data (large, wide, small). Axes: layout (bento, even: all tiles alike), media (none, image: a picture in
 * the large tiles), tone, density.
 */
import { For, type JSX } from "solid-js";
import { Card, CardContent, Grid, Text, Title } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { at, cn } from "../utils";
import type { Tile } from "./bento-grid.types";

const SPAN: Record<string, string> = {
  "large": "md:col-span-2 md:row-span-2",
  "wide": "md:col-span-2",
  "small": "",
};

export type BentoGridProps = {
  id: string;
  title: string;
  tiles: Tile[];
  empty?: string;
  layout?: "bento" | "even";
  media?: "none" | "image";
  tone?: "default" | "muted";
  density?: "default" | "compact";
  landmarkLabel?: string;
};

export function BentoGrid({
  id,
  title,
  tiles,
  empty = "",
  layout = "bento",
  media = "none",
  tone = "default",
  density = "default",
  landmarkLabel,
}: BentoGridProps) {
  return (
    <SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
      {((tiles?.length ?? 0) === 0) ? (
        <EmptyState icon="layout-dashboard" title={empty} />
      ) : (
        <Grid cols="1-4" class="auto-rows-fr gap-4" data-slot="items">
          <For each={tiles ?? []}>{(tile) => (
            <Card
              variant="default"
              class={cn(
                "h-full overflow-hidden",
                (((density as string) === "compact") ? "gap-4 p-4" : ""),
                (((layout as string) === "bento") ? at(SPAN, tile.size) : "")
              )}
              data-size={(((layout as string) === "bento") ? tile.size : "even")}
            >
              <CardContent class="flex h-full flex-col gap-4">
                <LucideIcon name={tile.icon} size={24} />
                <Title as={3} size="xl" weight="bold">
                  {tile.title}
                </Title>
                <Text size="sm" class="text-muted-foreground">
                  {tile.text}
                </Text>
                {(((media as string) === "image") && ((tile.size === "large") || ((layout as string) === "even"))) ? (
                  <MediaFrame alt={tile.title} src={tile.image} ratio="4/3" class="mt-auto" />
                ) : null}
              </CardContent>
            </Card>
          )}</For>
        </Grid>
      )}
    </SectionFrame>
  );
}
blocks/bento-grid.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 Tile = {
  id: string;
  title: string;
  text: string;
  icon: string;
  size: string;
  image?: 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 bento-grid
blocks/bento-grid.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/bento-grid.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"
)

// BentoGridProps are the props of BentoGrid; the values are the JSON shapes of the TypeScript props.
type BentoGridProps struct {
	Id any `json:"id"`
	Title any `json:"title"`
	Tiles any `json:"tiles"`
	Empty any `json:"empty"`
	Layout any `json:"layout"`
	Media any `json:"media"`
	Tone any `json:"tone"`
	Density any `json:"density"`
	LandmarkLabel any `json:"landmarkLabel"`
}

var bentoGridSpan = map[string]any{
	"large": "md:col-span-2 md:row-span-2",
	"wide": "md:col-span-2",
	"small": "",
}

// Tiles of different sizes in one grid: the large and wide tiles hold the important features. Sizes come from the data (large, wide, small). Axes: layout (bento, even: all tiles alike), media (none, image: a picture in the large tiles), tone, density.
templ BentoGrid(p BentoGridProps) {
	{{ vId := p.Id }}
	{{ vTitle := p.Title }}
	{{ vTiles := p.Tiles }}
	{{ vEmpty := uiutils.Def(p.Empty, "") }}
	{{ vLayout := uiutils.Def(p.Layout, "bento") }}
	{{ vMedia := uiutils.Def(p.Media, "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(vTiles), float64(0)) {
			@EmptyState(EmptyStateProps{Icon: "layout-dashboard", Title: vEmpty})
		} else {
			@compose.Grid(compose.GridProps{Cols: "1-4", BoxProps: box.BoxProps{Class: "auto-rows-fr gap-4", Attrs: uiutils.Attrs("data-slot", "items")}}) {
				for _, vTile := range uiutils.L(vTiles) {
					@compose.Card(compose.CardProps{Variant: "default", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("h-full overflow-hidden", uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "gap-4 p-4", ""), uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "bento")), uiutils.At(bentoGridSpan, uiutils.Get(vTile, "size")), ""))), Attrs: uiutils.Attrs("data-size", uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "bento")), uiutils.Get(vTile, "size"), "even"))}}) {
						@compose.CardContent(compose.CardContentProps{BoxProps: box.BoxProps{Class: "flex h-full flex-col gap-4"}}) {
							@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(uiutils.Get(vTile, "icon")), Size: 24})
							@compose.Title(compose.TitleProps{As: "3", Size: "xl", Weight: "bold", TextProps: text.TextProps{}}) {
								{ uiutils.Text(uiutils.Get(vTile, "title")) }
							}
							@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
								{ uiutils.Text(uiutils.Get(vTile, "text")) }
							}
							if uiutils.T(uiutils.And(uiutils.Eq(vMedia, "image"), uiutils.Or(uiutils.Eq(uiutils.Get(vTile, "size"), "large"), uiutils.Eq(vLayout, "even")))) {
								@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vTile, "title"), Src: uiutils.Get(vTile, "image"), Ratio: "4/3", Class: uiutils.Cnv("mt-auto")})
							}
						}
					}
				}
			}
		}
	}
}

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 bento-grid
blocks/bento-grid.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/bento-grid.json
    Tiles of different sizes in one grid: the large and wide tiles hold the important features. Sizes come from the data (large, wide, small). Axes: layout (bento, even: all tiles alike), media (none, image: a picture in the large tiles), tone, density.
    Props (p): id, title, tiles, empty, layout, media, tone, density, landmarkLabel. -#}
{%- set k_SPAN = {'large': 'md:col-span-2 md:row-span-2', 'wide': 'md:col-span-2', 'small': ''} -%}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_tiles = (p.tiles ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_layout = (p.layout ?? 'bento') -%}
{%- set v_media = (p.media ?? 'none') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_6 -%}
  {%- if og_t(og_eq(og_len(v_tiles), 0)) %}
    {{ include('blocks/empty-state.html.twig', {'p': {'icon': 'layout-dashboard', 'title': v_empty}}, with_context = false) }}
  {%- else %}
    {%- set c_5 -%}
      {%- for v_tile in og_l(v_tiles) %}
        {%- set c_4 -%}
          {%- set c_3 -%}
            {{ include('icons/LucideIcon.html.twig', {'name': og_s(og_get(v_tile, ['icon'])), 'size': 24}, with_context = false) }}
            {%- set c_1 -%}
              {{ og_text(og_get(v_tile, ['title'])) }}
            {%- endset -%}
            {{ include('compose/Title.html.twig', {'as': 3, 'size': 'xl', 'weight': 'bold', 'children': c_1}, with_context = false) }}
            {%- set c_2 -%}
              {{ og_text(og_get(v_tile, ['text'])) }}
            {%- endset -%}
            {{ include('compose/Text.html.twig', {'size': 'sm', 'class': 'text-muted-foreground', 'children': c_2}, with_context = false) }}
            {%- if og_t(og_and([og_eq(v_media, 'image'), og_or([og_eq(og_get(v_tile, ['size']), 'large'), og_eq(v_layout, 'even')])])) %}
              {{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_tile, ['title']), 'src': og_get(v_tile, ['image']), 'ratio': '4/3', 'className': og_cnv(['mt-auto'])}}, with_context = false) }}
            {%- endif %}
          {%- endset -%}
          {{ include('compose/CardContent.html.twig', {'class': 'flex h-full flex-col gap-4', 'children': c_3}, with_context = false) }}
        {%- endset -%}
        {{ include('compose/Card.html.twig', {'variant': 'default', 'class': og_s(og_cnv(['h-full overflow-hidden', (og_t(og_eq(v_density, 'compact')) ? 'gap-4 p-4' : ''), (og_t(og_eq(v_layout, 'bento')) ? og_at(k_SPAN, og_get(v_tile, ['size'])) : '')])), 'attrs': og_attrs(['data-size', (og_t(og_eq(v_layout, 'bento')) ? og_get(v_tile, ['size']) : 'even')]), 'children': c_4}, with_context = false) }}
      {%- endfor %}
    {%- endset -%}
    {{ include('compose/Grid.html.twig', {'cols': '1-4', 'class': 'auto-rows-fr gap-4', 'attrs': og_attrs(['data-slot', 'items']), 'children': c_5}, 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_6)}, 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 bento-grid
blocks/bento-grid.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/bento-grid.json
    Tiles of different sizes in one grid: the large and wide tiles hold the important features. Sizes come from the data (large, wide, small). Axes: layout (bento, even: all tiles alike), media (none, image: a picture in the large tiles), tone, density.
    Props (p): id, title, tiles, empty, layout, media, tone, density, landmarkLabel. *}
{var $k_SPAN = ['large' => 'md:col-span-2 md:row-span-2', 'wide' => 'md:col-span-2', 'small' => '']}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_tiles = ($p['tiles'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_layout = ($p['layout'] ?? 'bento')}
{var $v_media = ($p['media'] ?? 'none')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_6}
  {if og_t(og_eq(og_len($v_tiles), 0))}
    {=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'layout-dashboard', 'title' => $v_empty]])|noescape}
  {else}
    {capture $c_5}
      {foreach og_l($v_tiles) as $v_tile}
        {capture $c_4}
          {capture $c_3}
            {=og_include('icons/LucideIcon.latte', ['name' => og_s(og_get($v_tile, ['icon'])), 'size' => 24])|noescape}
            {capture $c_1}
              {=og_text(og_get($v_tile, ['title']))}
            {/capture}
            {=og_include('compose/Title.latte', ['as' => 3, 'size' => 'xl', 'weight' => 'bold', 'children' => (string) $c_1])|noescape}
            {capture $c_2}
              {=og_text(og_get($v_tile, ['text']))}
            {/capture}
            {=og_include('compose/Text.latte', ['size' => 'sm', 'class' => 'text-muted-foreground', 'children' => (string) $c_2])|noescape}
            {if og_t(og_and([og_eq($v_media, 'image'), og_or([og_eq(og_get($v_tile, ['size']), 'large'), og_eq($v_layout, 'even')])]))}
              {=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_tile, ['title']), 'src' => og_get($v_tile, ['image']), 'ratio' => '4/3', 'className' => og_cnv(['mt-auto'])]])|noescape}
            {/if}
          {/capture}
          {=og_include('compose/CardContent.latte', ['class' => 'flex h-full flex-col gap-4', 'children' => (string) $c_3])|noescape}
        {/capture}
        {=og_include('compose/Card.latte', ['variant' => 'default', 'class' => og_s(og_cnv(['h-full overflow-hidden', (og_t(og_eq($v_density, 'compact')) ? 'gap-4 p-4' : ''), (og_t(og_eq($v_layout, 'bento')) ? og_at($k_SPAN, og_get($v_tile, ['size'])) : '')])), 'attrs' => og_attrs(['data-size', (og_t(og_eq($v_layout, 'bento')) ? og_get($v_tile, ['size']) : 'even')]), 'children' => (string) $c_4])|noescape}
      {/foreach}
    {/capture}
    {=og_include('compose/Grid.latte', ['cols' => '1-4', 'class' => 'auto-rows-fr gap-4', 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_5])|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_6)])|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 bento-grid
blocks/bento-grid.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/bento-grid.json
    Tiles of different sizes in one grid: the large and wide tiles hold the important features. Sizes come from the data (large, wide, small). Axes: layout (bento, even: all tiles alike), media (none, image: a picture in the large tiles), tone, density.
    Props (p): id, title, tiles, empty, layout, media, tone, density, landmarkLabel. -#}
{%- set k_SPAN = {'large': 'md:col-span-2 md:row-span-2', 'wide': 'md:col-span-2', 'small': ''} -%}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_tiles = og_def(p['tiles'], none) -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_layout = og_def(p['layout'], 'bento') -%}
{%- set v_media = og_def(p['media'], '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_6 -%}
  {%- if og_t(og_eq(og_len(v_tiles), 0)) %}
    {{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'layout-dashboard', 'title': v_empty}}) }}
  {%- else %}
    {%- set c_5 -%}
      {%- for v_tile in og_l(v_tiles) %}
        {%- set c_4 -%}
          {%- set c_3 -%}
            {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(og_get(v_tile, ['icon'])), 'Size': 24}}) }}
            {%- set c_1 -%}
              {{ og_text(og_get(v_tile, ['title'])) }}
            {%- endset -%}
            {{ og_include('compose/title.html.j2', {'p': {'As': 3, 'Size': 'xl', 'Weight': 'bold'}, 'children': c_1}) }}
            {%- set c_2 -%}
              {{ og_text(og_get(v_tile, ['text'])) }}
            {%- endset -%}
            {{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Class': 'text-muted-foreground'}, 'children': c_2}) }}
            {%- if og_t(og_and([og_eq(v_media, 'image'), og_or([og_eq(og_get(v_tile, ['size']), 'large'), og_eq(v_layout, 'even')])])) %}
              {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_tile, ['title']), 'src': og_get(v_tile, ['image']), 'ratio': '4/3', 'className': og_cnv(['mt-auto'])}}) }}
            {%- endif %}
          {%- endset -%}
          {{ og_include('compose/card-content.html.j2', {'p': {'Class': 'flex h-full flex-col gap-4'}, 'children': c_3}) }}
        {%- endset -%}
        {{ og_include('compose/card.html.j2', {'p': {'Variant': 'default', 'Class': og_s(og_cnv(['h-full overflow-hidden', ('gap-4 p-4' if og_t(og_eq(v_density, 'compact')) else ''), (og_at(k_SPAN, og_get(v_tile, ['size'])) if og_t(og_eq(v_layout, 'bento')) else '')])), 'Attrs': og_attrs(['data-size', (og_get(v_tile, ['size']) if og_t(og_eq(v_layout, 'bento')) else 'even')])}, 'children': c_4}) }}
      {%- endfor %}
    {%- endset -%}
    {{ og_include('compose/grid.html.j2', {'p': {'Cols': '1-4', 'Class': 'auto-rows-fr gap-4', 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_5}) }}
  {%- 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_6)}) }}

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.

Tiles of different sizes in one grid: the large and wide tiles hold the important features. Sizes come from the data (large, wide, small). Axes: layout (bento, even: all tiles alike), media (none, image: a picture in the large tiles), tone, density.

Props of BentoGrid
PropTypeDefault Description
id (required)string-
title (required)string-
tiles (required)Tile[]-
empty string""the text of the empty state (no records), from the dictionary
layout "bento" | "even""bento"
media "none" | "image""none"
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