Product Grid
Products as cards in a grid, a list or a rail that scrolls sideways.
Install
npx ui8kit add product-gridPulls in: box, compose, empty-state, grid, kit-box, product-card, section-frame, utils
Preview
Popular right now
Arc desk lamp
128 reviews
Warm, dimmable light with a weighted base.
$89
Field backpack
342 reviews
Water-resistant, 22 litres, fits a 16 inch laptop.
$129
Studio headphones
87 reviews
Closed-back, 40 hour battery, wired and wireless.
$199
Laptop stand
210 reviews
Aluminium, folds flat, six heights.
$49
Desk mat
64 reviews
Felt top with a non-slip base, 90 by 40 cm.
$35
Gift card
19 reviews
Delivered by email, never expires.
$50
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-cdnnpx ui8kit add product-grid<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
A section with a heading and the products as cards in a grid, as a list of horizontal cards, or as a rail that
scrolls sideways; an empty state when there are none. Axes: layout (grid, list, rail), columns, ratio, rating,
action, tone, density.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { Product, ProductLabels } from "./product-card.types";
export type ProductGridProps = {
id: string;
title: string;
products: Product[];
labels: ProductLabels;
badges: Record<string, string>;
layout?: "grid" | "list" | "rail";
cols?: "1-2" | "1-3" | "1-4";
ratio?: "4/3" | "1/1" | "3/4";
rating?: "show" | "hide";
action?: "button" | "none";
tone?: "default" | "muted";
density?: "roomy" | "default" | "compact";
landmarkLabel?: string;
onadd?: (id: string) => void;
};
</script>
<script lang="ts">
import Box from "../compose/Box.svelte";
import Grid from "../compose/Grid.svelte";
import EmptyState from "../components/empty-state.svelte";
import ProductCard from "../blocks/product-card.svelte";
import SectionFrame from "../components/section-frame.svelte";
let {
id,
title,
products,
labels,
badges,
layout = "grid",
cols = "1-3",
ratio = "4/3",
rating = "show",
action = "button",
tone = "default",
density = "default",
landmarkLabel,
onadd,
}: ProductGridProps = $props();
</script>
<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{#if ((products?.length ?? 0) === 0)}
<EmptyState icon="package" title={labels.empty} />
{:else if ((layout as string) === "rail")}
<Box class="flex snap-x gap-4 overflow-x-auto pb-4" data-slot="items">
{#each products as p (p.id)}
<Box class="w-64 shrink-0 snap-start" data-slot="product">
<ProductCard
product={p}
labels={labels}
badges={badges}
layout={(((layout as string) === "list") ? "horizontal" : "vertical")}
ratio={ratio}
rating={rating}
action={action}
density={(((density as string) === "compact") ? "compact" : "default")}
onadd={() => onadd?.(p.id)}
/>
</Box>
{/each}
</Box>
{:else}
<Grid cols={(((layout as string) === "list") ? "1" : cols)} class="gap-4" data-slot="items">
{#each products as p (p.id)}
<ProductCard
product={p}
labels={labels}
badges={badges}
layout={(((layout as string) === "list") ? "horizontal" : "vertical")}
ratio={ratio}
rating={rating}
action={action}
density={(((density as string) === "compact") ? "compact" : "default")}
onadd={() => onadd?.(p.id)}
/>
{/each}
</Grid>
{/if}
</SectionFrame>
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-cdnnpx ui8kit add product-grid// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* A section with a heading and the products as cards in a grid, as a list of horizontal cards, or as a rail that
* scrolls sideways; an empty state when there are none. Axes: layout (grid, list, rail), columns, ratio, rating,
* action, tone, density.
*/
import { type ReactNode } from "react";
import { Box, Grid } from "../compose";
import { EmptyState } from "../components/empty-state";
import { ProductCard } from "../blocks/product-card";
import { SectionFrame } from "../components/section-frame";
import type { Product, ProductLabels } from "./product-card.types";
export type ProductGridProps = {
id: string;
title: string;
products: Product[];
labels: ProductLabels;
badges: Record<string, string>;
layout?: "grid" | "list" | "rail";
cols?: "1-2" | "1-3" | "1-4";
ratio?: "4/3" | "1/1" | "3/4";
rating?: "show" | "hide";
action?: "button" | "none";
tone?: "default" | "muted";
density?: "roomy" | "default" | "compact";
landmarkLabel?: string;
onAdd?: (id: string) => void;
};
export function ProductGrid({
id,
title,
products,
labels,
badges,
layout = "grid",
cols = "1-3",
ratio = "4/3",
rating = "show",
action = "button",
tone = "default",
density = "default",
landmarkLabel,
onAdd,
}: ProductGridProps) {
return (
<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{((products?.length ?? 0) === 0) ? (
<EmptyState icon="package" title={labels.empty} />
) : ((layout as string) === "rail") ? (
<Box className="flex snap-x gap-4 overflow-x-auto pb-4" data-slot="items">
{(products ?? []).map((p) => (
<Box key={p.id} className="w-64 shrink-0 snap-start" data-slot="product">
<ProductCard
product={p}
labels={labels}
badges={badges}
layout={(((layout as string) === "list") ? "horizontal" : "vertical")}
ratio={ratio}
rating={rating}
action={action}
density={(((density as string) === "compact") ? "compact" : "default")}
onAdd={() => onAdd?.(p.id)}
/>
</Box>
))}
</Box>
) : (
<Grid cols={(((layout as string) === "list") ? "1" : cols)} className="gap-4" data-slot="items">
{(products ?? []).map((p) => (
<ProductCard key={p.id}
product={p}
labels={labels}
badges={badges}
layout={(((layout as string) === "list") ? "horizontal" : "vertical")}
ratio={ratio}
rating={rating}
action={action}
density={(((density as string) === "compact") ? "compact" : "default")}
onAdd={() => onAdd?.(p.id)}
/>
))}
</Grid>
)}
</SectionFrame>
);
}
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-cdnnpx ui8kit add product-grid<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
A section with a heading and the products as cards in a grid, as a list of horizontal cards, or as a rail that
scrolls sideways; an empty state when there are none. Axes: layout (grid, list, rail), columns, ratio, rating,
action, tone, density.
-->
<script lang="ts">
import type { Product, ProductLabels } from "./product-card.types";
export type ProductGridProps = {
id: string;
title: string;
products: Product[];
labels: ProductLabels;
badges: Record<string, string>;
layout?: "grid" | "list" | "rail";
cols?: "1-2" | "1-3" | "1-4";
ratio?: "4/3" | "1/1" | "3/4";
rating?: "show" | "hide";
action?: "button" | "none";
tone?: "default" | "muted";
density?: "roomy" | "default" | "compact";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Box from "../compose/Box.vue";
import Grid from "../compose/Grid.vue";
import EmptyState from "../components/empty-state.vue";
import ProductCard from "../blocks/product-card.vue";
import SectionFrame from "../components/section-frame.vue";
const {
id,
title,
products,
labels,
badges,
layout = "grid",
cols = "1-3",
ratio = "4/3",
rating = "show",
action = "button",
tone = "default",
density = "default",
landmarkLabel,
} = defineProps<ProductGridProps>();
const emit = defineEmits<{ add: [id: string] }>();
</script>
<template>
<SectionFrame :id="id" :title="title" :tone="tone" :density="density" :landmarkLabel="landmarkLabel">
<EmptyState v-if="((products?.length ?? 0) === 0)" icon="package" :title="labels.empty" />
<Box
v-else-if="((layout as string) === 'rail')"
class="flex snap-x gap-4 overflow-x-auto pb-4"
data-slot="items"
>
<Box v-for="p in products" :key="p.id" class="w-64 shrink-0 snap-start" data-slot="product">
<ProductCard
:product="p"
:labels="labels"
:badges="badges"
:layout="(((layout as string) === 'list') ? 'horizontal' : 'vertical')"
:ratio="ratio"
:rating="rating"
:action="action"
:density="(((density as string) === 'compact') ? 'compact' : 'default')"
@add="() => emit('add', p.id)"
/>
</Box>
</Box>
<Grid v-else :cols="(((layout as string) === 'list') ? '1' : cols)" class="gap-4" data-slot="items">
<ProductCard v-for="p in products" :key="p.id"
:product="p"
:labels="labels"
:badges="badges"
:layout="(((layout as string) === 'list') ? 'horizontal' : 'vertical')"
:ratio="ratio"
:rating="rating"
:action="action"
:density="(((density as string) === 'compact') ? 'compact' : 'default')"
@add="() => emit('add', p.id)"
/>
</Grid>
</SectionFrame>
</template>
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-cdnnpx ui8kit add product-grid// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* A section with a heading and the products as cards in a grid, as a list of horizontal cards, or as a rail that
* scrolls sideways; an empty state when there are none. Axes: layout (grid, list, rail), columns, ratio, rating,
* action, tone, density.
*/
import { For, type JSX } from "solid-js";
import { Box, Grid } from "../compose";
import { EmptyState } from "../components/empty-state";
import { ProductCard } from "../blocks/product-card";
import { SectionFrame } from "../components/section-frame";
import type { Product, ProductLabels } from "./product-card.types";
export type ProductGridProps = {
id: string;
title: string;
products: Product[];
labels: ProductLabels;
badges: Record<string, string>;
layout?: "grid" | "list" | "rail";
cols?: "1-2" | "1-3" | "1-4";
ratio?: "4/3" | "1/1" | "3/4";
rating?: "show" | "hide";
action?: "button" | "none";
tone?: "default" | "muted";
density?: "roomy" | "default" | "compact";
landmarkLabel?: string;
onAdd?: (id: string) => void;
};
export function ProductGrid({
id,
title,
products,
labels,
badges,
layout = "grid",
cols = "1-3",
ratio = "4/3",
rating = "show",
action = "button",
tone = "default",
density = "default",
landmarkLabel,
onAdd,
}: ProductGridProps) {
return (
<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{((products?.length ?? 0) === 0) ? (
<EmptyState icon="package" title={labels.empty} />
) : ((layout as string) === "rail") ? (
<Box class="flex snap-x gap-4 overflow-x-auto pb-4" data-slot="items">
<For each={products ?? []}>{(p) => (
<Box class="w-64 shrink-0 snap-start" data-slot="product">
<ProductCard
product={p}
labels={labels}
badges={badges}
layout={(((layout as string) === "list") ? "horizontal" : "vertical")}
ratio={ratio}
rating={rating}
action={action}
density={(((density as string) === "compact") ? "compact" : "default")}
onAdd={() => onAdd?.(p.id)}
/>
</Box>
)}</For>
</Box>
) : (
<Grid cols={(((layout as string) === "list") ? "1" : cols)} class="gap-4" data-slot="items">
<For each={products ?? []}>{(p) => (
<ProductCard
product={p}
labels={labels}
badges={badges}
layout={(((layout as string) === "list") ? "horizontal" : "vertical")}
ratio={ratio}
rating={rating}
action={action}
density={(((density as string) === "compact") ? "compact" : "default")}
onAdd={() => onAdd?.(p.id)}
/>
)}</For>
</Grid>
)}
</SectionFrame>
);
}
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-cdnnpx ui8kit add product-grid// 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/product-grid.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"
)
// ProductGridProps are the props of ProductGrid; the values are the JSON shapes of the TypeScript props.
type ProductGridProps struct {
Id any `json:"id"`
Title any `json:"title"`
Products any `json:"products"`
Labels any `json:"labels"`
Badges any `json:"badges"`
Layout any `json:"layout"`
Cols any `json:"cols"`
Ratio any `json:"ratio"`
Rating any `json:"rating"`
Action any `json:"action"`
Tone any `json:"tone"`
Density any `json:"density"`
LandmarkLabel any `json:"landmarkLabel"`
}
// A section with a heading and the products as cards in a grid, as a list of horizontal cards, or as a rail that scrolls sideways; an empty state when there are none. Axes: layout (grid, list, rail), columns, ratio, rating, action, tone, density.
templ ProductGrid(p ProductGridProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vProducts := p.Products }}
{{ vLabels := p.Labels }}
{{ vBadges := p.Badges }}
{{ vLayout := uiutils.Def(p.Layout, "grid") }}
{{ vCols := uiutils.Def(p.Cols, "1-3") }}
{{ vRatio := uiutils.Def(p.Ratio, "4/3") }}
{{ vRating := uiutils.Def(p.Rating, "show") }}
{{ vAction := uiutils.Def(p.Action, "button") }}
{{ 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(vProducts), float64(0)) {
@EmptyState(EmptyStateProps{Icon: "package", Title: uiutils.Get(vLabels, "empty")})
} else if uiutils.Eq(vLayout, "rail") {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex snap-x gap-4 overflow-x-auto pb-4", Attrs: uiutils.Attrs("data-slot", "items")}}) {
for _, vP := range uiutils.L(vProducts) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "w-64 shrink-0 snap-start", Attrs: uiutils.Attrs("data-slot", "product")}}) {
@ProductCard(ProductCardProps{Product: vP, Labels: vLabels, Badges: vBadges, Layout: uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "list")), "horizontal", "vertical"), Ratio: vRatio, Rating: vRating, Action: vAction, Density: uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "compact", "default")})
}
}
}
} else {
@compose.Grid(compose.GridProps{Cols: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "list")), "1", vCols)), BoxProps: box.BoxProps{Class: "gap-4", Attrs: uiutils.Attrs("data-slot", "items")}}) {
for _, vP := range uiutils.L(vProducts) {
@ProductCard(ProductCardProps{Product: vP, Labels: vLabels, Badges: vBadges, Layout: uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "list")), "horizontal", "vertical"), Ratio: vRatio, Rating: vRating, Action: vAction, Density: uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "compact", "default")})
}
}
}
}
}
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-cdnnpx ui8kit add product-grid{#- 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/product-grid.json
A section with a heading and the products as cards in a grid, as a list of horizontal cards, or as a rail that scrolls sideways; an empty state when there are none. Axes: layout (grid, list, rail), columns, ratio, rating, action, tone, density.
Props (p): id, title, products, labels, badges, layout, cols, ratio, rating, action, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_products = (p.products ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_badges = (p.badges ?? null) -%}
{%- set v_layout = (p.layout ?? 'grid') -%}
{%- set v_cols = (p.cols ?? '1-3') -%}
{%- set v_ratio = (p.ratio ?? '4/3') -%}
{%- set v_rating = (p.rating ?? 'show') -%}
{%- set v_action = (p.action ?? 'button') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_4 -%}
{%- if og_t(og_eq(og_len(v_products), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'package', 'title': og_get(v_labels, ['empty'])}}, with_context = false) }}
{%- elseif og_t(og_eq(v_layout, 'rail')) %}
{%- set c_2 -%}
{%- for v_p in og_l(v_products) %}
{%- set c_1 -%}
{{ include('blocks/product-card.html.twig', {'p': {'product': v_p, 'labels': v_labels, 'badges': v_badges, 'layout': (og_t(og_eq(v_layout, 'list')) ? 'horizontal' : 'vertical'), 'ratio': v_ratio, 'rating': v_rating, 'action': v_action, 'density': (og_t(og_eq(v_density, 'compact')) ? 'compact' : 'default')}}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'w-64 shrink-0 snap-start', 'attrs': og_attrs(['data-slot', 'product']), 'children': c_1}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'flex snap-x gap-4 overflow-x-auto pb-4', 'attrs': og_attrs(['data-slot', 'items']), 'children': c_2}, with_context = false) }}
{%- else %}
{%- set c_3 -%}
{%- for v_p in og_l(v_products) %}
{{ include('blocks/product-card.html.twig', {'p': {'product': v_p, 'labels': v_labels, 'badges': v_badges, 'layout': (og_t(og_eq(v_layout, 'list')) ? 'horizontal' : 'vertical'), 'ratio': v_ratio, 'rating': v_rating, 'action': v_action, 'density': (og_t(og_eq(v_density, 'compact')) ? 'compact' : 'default')}}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Grid.html.twig', {'cols': og_s((og_t(og_eq(v_layout, 'list')) ? '1' : v_cols)), 'class': 'gap-4', 'attrs': og_attrs(['data-slot', 'items']), 'children': c_3}, 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_4)}, with_context = false) }}
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-cdnnpx ui8kit add product-grid{* 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/product-grid.json
A section with a heading and the products as cards in a grid, as a list of horizontal cards, or as a rail that scrolls sideways; an empty state when there are none. Axes: layout (grid, list, rail), columns, ratio, rating, action, tone, density.
Props (p): id, title, products, labels, badges, layout, cols, ratio, rating, action, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_products = ($p['products'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_badges = ($p['badges'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'grid')}
{var $v_cols = ($p['cols'] ?? '1-3')}
{var $v_ratio = ($p['ratio'] ?? '4/3')}
{var $v_rating = ($p['rating'] ?? 'show')}
{var $v_action = ($p['action'] ?? 'button')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_4}
{if og_t(og_eq(og_len($v_products), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'package', 'title' => og_get($v_labels, ['empty'])]])|noescape}
{elseif og_t(og_eq($v_layout, 'rail'))}
{capture $c_2}
{foreach og_l($v_products) as $v_p}
{capture $c_1}
{=og_include('blocks/product-card.latte', ['p' => ['product' => $v_p, 'labels' => $v_labels, 'badges' => $v_badges, 'layout' => (og_t(og_eq($v_layout, 'list')) ? 'horizontal' : 'vertical'), 'ratio' => $v_ratio, 'rating' => $v_rating, 'action' => $v_action, 'density' => (og_t(og_eq($v_density, 'compact')) ? 'compact' : 'default')]])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'w-64 shrink-0 snap-start', 'attrs' => og_attrs(['data-slot', 'product']), 'children' => (string) $c_1])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'flex snap-x gap-4 overflow-x-auto pb-4', 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_2])|noescape}
{else}
{capture $c_3}
{foreach og_l($v_products) as $v_p}
{=og_include('blocks/product-card.latte', ['p' => ['product' => $v_p, 'labels' => $v_labels, 'badges' => $v_badges, 'layout' => (og_t(og_eq($v_layout, 'list')) ? 'horizontal' : 'vertical'), 'ratio' => $v_ratio, 'rating' => $v_rating, 'action' => $v_action, 'density' => (og_t(og_eq($v_density, 'compact')) ? 'compact' : 'default')]])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Grid.latte', ['cols' => og_s((og_t(og_eq($v_layout, 'list')) ? '1' : $v_cols)), 'class' => 'gap-4', 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_3])|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_4)])|noescape}
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-cdnnpx ui8kit add product-grid{#- 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/product-grid.json
A section with a heading and the products as cards in a grid, as a list of horizontal cards, or as a rail that scrolls sideways; an empty state when there are none. Axes: layout (grid, list, rail), columns, ratio, rating, action, tone, density.
Props (p): id, title, products, labels, badges, layout, cols, ratio, rating, action, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_products = og_def(p['products'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_badges = og_def(p['badges'], none) -%}
{%- set v_layout = og_def(p['layout'], 'grid') -%}
{%- set v_cols = og_def(p['cols'], '1-3') -%}
{%- set v_ratio = og_def(p['ratio'], '4/3') -%}
{%- set v_rating = og_def(p['rating'], 'show') -%}
{%- set v_action = og_def(p['action'], 'button') -%}
{%- 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_4 -%}
{%- if og_t(og_eq(og_len(v_products), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'package', 'title': og_get(v_labels, ['empty'])}}) }}
{%- elif og_t(og_eq(v_layout, 'rail')) %}
{%- set c_2 -%}
{%- for v_p in og_l(v_products) %}
{%- set c_1 -%}
{{ og_include('blocks/product-card.html.j2', {'p': {'product': v_p, 'labels': v_labels, 'badges': v_badges, 'layout': ('horizontal' if og_t(og_eq(v_layout, 'list')) else 'vertical'), 'ratio': v_ratio, 'rating': v_rating, 'action': v_action, 'density': ('compact' if og_t(og_eq(v_density, 'compact')) else 'default')}}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'w-64 shrink-0 snap-start', 'Attrs': og_attrs(['data-slot', 'product'])}, 'children': c_1}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'flex snap-x gap-4 overflow-x-auto pb-4', 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_2}) }}
{%- else %}
{%- set c_3 -%}
{%- for v_p in og_l(v_products) %}
{{ og_include('blocks/product-card.html.j2', {'p': {'product': v_p, 'labels': v_labels, 'badges': v_badges, 'layout': ('horizontal' if og_t(og_eq(v_layout, 'list')) else 'vertical'), 'ratio': v_ratio, 'rating': v_rating, 'action': v_action, 'density': ('compact' if og_t(og_eq(v_density, 'compact')) else 'default')}}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/grid.html.j2', {'p': {'Cols': og_s(('1' if og_t(og_eq(v_layout, 'list')) else v_cols)), 'Class': 'gap-4', 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_3}) }}
{%- 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_4)}) }}
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.
A section with a heading and the products as cards in a grid, as a list of horizontal cards, or as a rail that scrolls sideways; an empty state when there are none. Axes: layout (grid, list, rail), columns, ratio, rating, action, tone, density.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| products (required) | Product[] | - | |
| labels (required) | ProductLabels | - | |
| badges (required) | Record<string, string> | - | |
| layout | "grid" | "list" | "rail" | "grid" | |
| cols | "1-2" | "1-3" | "1-4" | "1-3" | |
| ratio | "4/3" | "1/1" | "3/4" | "4/3" | |
| rating | "show" | "hide" | "show" | |
| action | "button" | "none" | "button" | |
| tone | "default" | "muted" | "default" | |
| density | "roomy" | "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 |