Product Detail
The gallery and the buy box of one product.
Install
npx ui8kit add product-detailPulls in: button, compose, empty-state, group, inline, kit-box, kit-button, kit-text, list, list-item, lucide-icon, number-field, product-card, product-gallery, product-price, rating, section-frame, stack, text, utils
Preview
Arc desk lamp
Warm, dimmable light with a weighted base.
$89
New128 reviews
In stock
- Free shipping over 75 dollars
- Thirty-day returns
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-detail<!-- 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 product page: a gallery (the main picture and optional thumbnails) beside the buy box (badge, rating, price,
stock, quantity, add button, shipping and returns notes). Axes: layout (split, stacked), media side, thumbs
(none, below), buy (full, compact), tone, density.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { ProductDetailLabels } from "./product-detail.types";
import type { Product } from "./product-card.types";
export type ProductDetailProps = {
id: string;
product?: Product;
labels: ProductDetailLabels;
badges: Record<string, string>;
level?: 1 | 2;
layout?: "split" | "stacked";
mediaSide?: "start" | "end";
thumbs?: "none" | "below";
buy?: "full" | "compact";
tone?: "default" | "muted";
density?: "default" | "roomy";
landmarkLabel?: string;
onadd?: (id: string) => void;
};
</script>
<script lang="ts">
import Button from "../compose/Button.svelte";
import Group from "../compose/Group.svelte";
import Inline from "../compose/Inline.svelte";
import List from "../compose/List.svelte";
import ListItem from "../compose/ListItem.svelte";
import LucideIcon from "../icons/LucideIcon.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import EmptyState from "../components/empty-state.svelte";
import NumberField from "../components/number-field.svelte";
import ProductGallery from "../components/product-gallery.svelte";
import ProductPrice from "../components/product-price.svelte";
import Rating from "../components/rating.svelte";
import SectionFrame from "../components/section-frame.svelte";
import { at, tpl } from "../utils";
let {
id,
product,
labels,
badges,
level = 1,
layout = "split",
mediaSide = "start",
thumbs = "below",
buy = "full",
tone = "default",
density = "default",
landmarkLabel,
onadd,
}: ProductDetailProps = $props();
</script>
{#if !product}
<SectionFrame id={id} tone={tone} density={density} landmarkLabel={landmarkLabel}>
<EmptyState icon="package" title={labels.empty} />
</SectionFrame>
{:else}
<SectionFrame
id={id}
title={product?.name}
lead={product?.summary}
heading={{ level }}
layout={(((layout as string) === "split") ? "split" : "stack")}
media={{ show: true, side: mediaSide, align: "start" }}
tone={tone}
density={density}
landmarkLabel={landmarkLabel}
>
<Stack gap="4" align="stretch" data-slot="buy-box">
{#if product?.category}
<Text size="xs" class="uppercase tracking-wide text-muted-foreground" data-slot="category">
{product?.category}
</Text>
{/if}
<ProductPrice
price={product?.price}
compareAt={product?.compareAt}
currency={product?.currency}
badge={(product?.badge ? at(badges, product?.badge) : "")}
was={labels.was}
/>
<Group gap="2">
<Rating value={product?.rating} label={tpl(labels.ratingLabel, product?.rating)} />
<Text size="sm" class="text-muted-foreground">
{tpl(labels.reviews, product?.reviews)}
</Text>
</Group>
<Text
size="sm"
weight="medium"
class={(product?.inStock ? "text-foreground" : "text-destructive")}
data-slot="stock"
>
{(product?.inStock ? labels.inStock : labels.soldOut)}
</Text>
<Group gap="4" class="flex-wrap">
{#if ((buy as string) === "full")}
<NumberField
value="1"
name={tpl("{0}-qty", id)}
min="1"
label={labels.qty}
decrease={labels.decrease}
increase={labels.increase}
/>
{/if}
<Button disabled={!product?.inStock} onclick={() => onadd?.(product?.id)}>
{labels.add}
</Button>
</Group>
{#if ((buy as string) === "full")}
<List tag="ul" class="flex flex-col gap-2 text-sm text-muted-foreground">
<ListItem class="flex items-center gap-2">
<LucideIcon name="truck" size={16} />
<Inline>
{labels.shipping}
</Inline>
</ListItem>
<ListItem class="flex items-center gap-2">
<LucideIcon name="shield-check" size={16} />
<Inline>
{labels.returns}
</Inline>
</ListItem>
</List>
{/if}
</Stack>
{#snippet aside()}
<ProductGallery name={product?.name} image={product?.image} thumbs={thumbs} />
{/snippet}
</SectionFrame>
{/if}
// 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 ProductDetailLabels = {
add: string;
soldOut: string;
inStock: string;
qty: string;
decrease: string;
increase: string;
reviews: string;
ratingLabel: string;
shipping: string;
returns: string;
was: string;
empty: string;
};
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-detail// 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 product page: a gallery (the main picture and optional thumbnails) beside the buy box (badge, rating, price,
* stock, quantity, add button, shipping and returns notes). Axes: layout (split, stacked), media side, thumbs
* (none, below), buy (full, compact), tone, density.
*/
import { type ReactNode } from "react";
import { Button, Group, Inline, List, ListItem, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { NumberField } from "../components/number-field";
import { ProductGallery } from "../components/product-gallery";
import { ProductPrice } from "../components/product-price";
import { Rating } from "../components/rating";
import { SectionFrame } from "../components/section-frame";
import { at, tpl } from "../utils";
import type { ProductDetailLabels } from "./product-detail.types";
import type { Product } from "./product-card.types";
export type ProductDetailProps = {
id: string;
product?: Product;
labels: ProductDetailLabels;
badges: Record<string, string>;
level?: 1 | 2;
layout?: "split" | "stacked";
mediaSide?: "start" | "end";
thumbs?: "none" | "below";
buy?: "full" | "compact";
tone?: "default" | "muted";
density?: "default" | "roomy";
landmarkLabel?: string;
onAdd?: (id: string) => void;
};
export function ProductDetail({
id,
product,
labels,
badges,
level = 1,
layout = "split",
mediaSide = "start",
thumbs = "below",
buy = "full",
tone = "default",
density = "default",
landmarkLabel,
onAdd,
}: ProductDetailProps) {
return (
<>
{!product ? (
<SectionFrame id={id} tone={tone} density={density} landmarkLabel={landmarkLabel}>
<EmptyState icon="package" title={labels.empty} />
</SectionFrame>
) : (
<SectionFrame
id={id}
title={product?.name}
lead={product?.summary}
heading={{ level }}
layout={(((layout as string) === "split") ? "split" : "stack")}
media={{ show: true, side: mediaSide, align: "start" }}
tone={tone}
density={density}
landmarkLabel={landmarkLabel}
aside={(
<ProductGallery name={product?.name} image={product?.image} thumbs={thumbs} />
)}
>
<Stack gap="4" align="stretch" data-slot="buy-box">
{product?.category ? (
<Text size="xs" className="uppercase tracking-wide text-muted-foreground" data-slot="category">
{product?.category}
</Text>
) : null}
<ProductPrice
price={product?.price}
compareAt={product?.compareAt}
currency={product?.currency}
badge={(product?.badge ? at(badges, product?.badge) : "")}
was={labels.was}
/>
<Group gap="2">
<Rating value={product?.rating} label={tpl(labels.ratingLabel, product?.rating)} />
<Text size="sm" className="text-muted-foreground">
{tpl(labels.reviews, product?.reviews)}
</Text>
</Group>
<Text
size="sm"
weight="medium"
className={(product?.inStock ? "text-foreground" : "text-destructive")}
data-slot="stock"
>
{(product?.inStock ? labels.inStock : labels.soldOut)}
</Text>
<Group gap="4" className="flex-wrap">
{((buy as string) === "full") ? (
<NumberField
value="1"
name={tpl("{0}-qty", id)}
min="1"
label={labels.qty}
decrease={labels.decrease}
increase={labels.increase}
/>
) : null}
<Button disabled={!product?.inStock} onClick={() => onAdd?.(product?.id)}>
{labels.add}
</Button>
</Group>
{((buy as string) === "full") ? (
<List tag="ul" className="flex flex-col gap-2 text-sm text-muted-foreground">
<ListItem className="flex items-center gap-2">
<LucideIcon name="truck" size={16} />
<Inline>
{labels.shipping}
</Inline>
</ListItem>
<ListItem className="flex items-center gap-2">
<LucideIcon name="shield-check" size={16} />
<Inline>
{labels.returns}
</Inline>
</ListItem>
</List>
) : null}
</Stack>
</SectionFrame>
)}
</>
);
}
// 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 ProductDetailLabels = {
add: string;
soldOut: string;
inStock: string;
qty: string;
decrease: string;
increase: string;
reviews: string;
ratingLabel: string;
shipping: string;
returns: string;
was: string;
empty: string;
};
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-detail// 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 ProductDetailLabels = {
add: string;
soldOut: string;
inStock: string;
qty: string;
decrease: string;
increase: string;
reviews: string;
ratingLabel: string;
shipping: string;
returns: string;
was: string;
empty: string;
};
<!-- 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 product page: a gallery (the main picture and optional thumbnails) beside the buy box (badge, rating, price,
stock, quantity, add button, shipping and returns notes). Axes: layout (split, stacked), media side, thumbs
(none, below), buy (full, compact), tone, density.
-->
<script lang="ts">
import type { ProductDetailLabels } from "./product-detail.types";
import type { Product } from "./product-card.types";
export type ProductDetailProps = {
id: string;
product?: Product;
labels: ProductDetailLabels;
badges: Record<string, string>;
level?: 1 | 2;
layout?: "split" | "stacked";
mediaSide?: "start" | "end";
thumbs?: "none" | "below";
buy?: "full" | "compact";
tone?: "default" | "muted";
density?: "default" | "roomy";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Button from "../compose/Button.vue";
import Group from "../compose/Group.vue";
import Inline from "../compose/Inline.vue";
import List from "../compose/List.vue";
import ListItem from "../compose/ListItem.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import EmptyState from "../components/empty-state.vue";
import NumberField from "../components/number-field.vue";
import ProductGallery from "../components/product-gallery.vue";
import ProductPrice from "../components/product-price.vue";
import Rating from "../components/rating.vue";
import SectionFrame from "../components/section-frame.vue";
import { at, tpl } from "../utils";
const {
id,
product,
labels,
badges,
level = 1,
layout = "split",
mediaSide = "start",
thumbs = "below",
buy = "full",
tone = "default",
density = "default",
landmarkLabel,
} = defineProps<ProductDetailProps>();
const emit = defineEmits<{ add: [id: string] }>();
</script>
<template>
<SectionFrame v-if="!product" :id="id" :tone="tone" :density="density" :landmarkLabel="landmarkLabel">
<EmptyState icon="package" :title="labels.empty" />
</SectionFrame>
<SectionFrame v-else
:id="id"
:title="product?.name"
:lead="product?.summary"
:heading="{ level }"
:layout="(((layout as string) === 'split') ? 'split' : 'stack')"
:media="{ show: true, side: mediaSide, align: 'start' }"
:tone="tone"
:density="density"
:landmarkLabel="landmarkLabel"
>
<Stack gap="4" align="stretch" data-slot="buy-box">
<Text
v-if="product?.category"
size="xs"
class="uppercase tracking-wide text-muted-foreground"
data-slot="category"
>
{{ product?.category }}
</Text>
<ProductPrice
:price="product?.price"
:compareAt="product?.compareAt"
:currency="product?.currency"
:badge="(product?.badge ? at(badges, product?.badge) : '')"
:was="labels.was"
/>
<Group gap="2">
<Rating :value="product?.rating" :label="tpl(labels.ratingLabel, product?.rating)" />
<Text size="sm" class="text-muted-foreground">
{{ tpl(labels.reviews, product?.reviews) }}
</Text>
</Group>
<Text
size="sm"
weight="medium"
:class="(product?.inStock ? 'text-foreground' : 'text-destructive')"
data-slot="stock"
>
{{ (product?.inStock ? labels.inStock : labels.soldOut) }}
</Text>
<Group gap="4" class="flex-wrap">
<NumberField v-if="((buy as string) === 'full')"
value="1"
:name="tpl('{0}-qty', id)"
min="1"
:label="labels.qty"
:decrease="labels.decrease"
:increase="labels.increase"
/>
<Button :disabled="!product?.inStock" @click="() => emit('add', product?.id)">
{{ labels.add }}
</Button>
</Group>
<List v-if="((buy as string) === 'full')" tag="ul" class="flex flex-col gap-2 text-sm text-muted-foreground">
<ListItem class="flex items-center gap-2">
<LucideIcon name="truck" :size="16" />
<Inline>
{{ labels.shipping }}
</Inline>
</ListItem>
<ListItem class="flex items-center gap-2">
<LucideIcon name="shield-check" :size="16" />
<Inline>
{{ labels.returns }}
</Inline>
</ListItem>
</List>
</Stack>
<template #aside>
<ProductGallery :name="product?.name" :image="product?.image" :thumbs="thumbs" />
</template>
</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-detail// 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 product page: a gallery (the main picture and optional thumbnails) beside the buy box (badge, rating, price,
* stock, quantity, add button, shipping and returns notes). Axes: layout (split, stacked), media side, thumbs
* (none, below), buy (full, compact), tone, density.
*/
import { type JSX } from "solid-js";
import { Button, Group, Inline, List, ListItem, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { NumberField } from "../components/number-field";
import { ProductGallery } from "../components/product-gallery";
import { ProductPrice } from "../components/product-price";
import { Rating } from "../components/rating";
import { SectionFrame } from "../components/section-frame";
import { at, tpl } from "../utils";
import type { ProductDetailLabels } from "./product-detail.types";
import type { Product } from "./product-card.types";
export type ProductDetailProps = {
id: string;
product?: Product;
labels: ProductDetailLabels;
badges: Record<string, string>;
level?: 1 | 2;
layout?: "split" | "stacked";
mediaSide?: "start" | "end";
thumbs?: "none" | "below";
buy?: "full" | "compact";
tone?: "default" | "muted";
density?: "default" | "roomy";
landmarkLabel?: string;
onAdd?: (id: string) => void;
};
export function ProductDetail({
id,
product,
labels,
badges,
level = 1,
layout = "split",
mediaSide = "start",
thumbs = "below",
buy = "full",
tone = "default",
density = "default",
landmarkLabel,
onAdd,
}: ProductDetailProps) {
return (
<>
{!product ? (
<SectionFrame id={id} tone={tone} density={density} landmarkLabel={landmarkLabel}>
<EmptyState icon="package" title={labels.empty} />
</SectionFrame>
) : (
<SectionFrame
id={id}
title={product?.name}
lead={product?.summary}
heading={{ level }}
layout={(((layout as string) === "split") ? "split" : "stack")}
media={{ show: true, side: mediaSide, align: "start" }}
tone={tone}
density={density}
landmarkLabel={landmarkLabel}
aside={(
<ProductGallery name={product?.name} image={product?.image} thumbs={thumbs} />
)}
>
<Stack gap="4" align="stretch" data-slot="buy-box">
{product?.category ? (
<Text size="xs" class="uppercase tracking-wide text-muted-foreground" data-slot="category">
{product?.category}
</Text>
) : null}
<ProductPrice
price={product?.price}
compareAt={product?.compareAt}
currency={product?.currency}
badge={(product?.badge ? at(badges, product?.badge) : "")}
was={labels.was}
/>
<Group gap="2">
<Rating value={product?.rating} label={tpl(labels.ratingLabel, product?.rating)} />
<Text size="sm" class="text-muted-foreground">
{tpl(labels.reviews, product?.reviews)}
</Text>
</Group>
<Text
size="sm"
weight="medium"
class={(product?.inStock ? "text-foreground" : "text-destructive")}
data-slot="stock"
>
{(product?.inStock ? labels.inStock : labels.soldOut)}
</Text>
<Group gap="4" class="flex-wrap">
{((buy as string) === "full") ? (
<NumberField
value="1"
name={tpl("{0}-qty", id)}
min="1"
label={labels.qty}
decrease={labels.decrease}
increase={labels.increase}
/>
) : null}
<Button disabled={!product?.inStock} onClick={() => onAdd?.(product?.id)}>
{labels.add}
</Button>
</Group>
{((buy as string) === "full") ? (
<List tag="ul" class="flex flex-col gap-2 text-sm text-muted-foreground">
<ListItem class="flex items-center gap-2">
<LucideIcon name="truck" size={16} />
<Inline>
{labels.shipping}
</Inline>
</ListItem>
<ListItem class="flex items-center gap-2">
<LucideIcon name="shield-check" size={16} />
<Inline>
{labels.returns}
</Inline>
</ListItem>
</List>
) : null}
</Stack>
</SectionFrame>
)}
</>
);
}
// 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 ProductDetailLabels = {
add: string;
soldOut: string;
inStock: string;
qty: string;
decrease: string;
increase: string;
reviews: string;
ratingLabel: string;
shipping: string;
returns: string;
was: string;
empty: string;
};
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-detail// 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-detail.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/ui/button"
"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"
)
// ProductDetailProps are the props of ProductDetail; the values are the JSON shapes of the TypeScript props.
type ProductDetailProps struct {
Id any `json:"id"`
Product any `json:"product"`
Labels any `json:"labels"`
Badges any `json:"badges"`
Level any `json:"level"`
Layout any `json:"layout"`
MediaSide any `json:"mediaSide"`
Thumbs any `json:"thumbs"`
Buy any `json:"buy"`
Tone any `json:"tone"`
Density any `json:"density"`
LandmarkLabel any `json:"landmarkLabel"`
}
// A product page: a gallery (the main picture and optional thumbnails) beside the buy box (badge, rating, price, stock, quantity, add button, shipping and returns notes). Axes: layout (split, stacked), media side, thumbs (none, below), buy (full, compact), tone, density.
templ ProductDetail(p ProductDetailProps) {
{{ vId := p.Id }}
{{ vProduct := p.Product }}
{{ vLabels := p.Labels }}
{{ vBadges := p.Badges }}
{{ vLevel := uiutils.Def(p.Level, float64(1)) }}
{{ vLayout := uiutils.Def(p.Layout, "split") }}
{{ vMediaSide := uiutils.Def(p.MediaSide, "start") }}
{{ vThumbs := uiutils.Def(p.Thumbs, "below") }}
{{ vBuy := uiutils.Def(p.Buy, "full") }}
{{ vTone := uiutils.Def(p.Tone, "default") }}
{{ vDensity := uiutils.Def(p.Density, "default") }}
{{ vLandmarkLabel := p.LandmarkLabel }}
if !uiutils.T(vProduct) {
@SectionFrame(SectionFrameProps{Id: vId, Tone: vTone, Density: vDensity, LandmarkLabel: vLandmarkLabel}) {
@EmptyState(EmptyStateProps{Icon: "package", Title: uiutils.Get(vLabels, "empty")})
}
} else {
@SectionFrame(SectionFrameProps{Id: vId, Title: uiutils.Get(vProduct, "name"), Lead: uiutils.Get(vProduct, "summary"), Heading: map[string]any{"level": vLevel}, Layout: uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "split")), "split", "stack"), Media: map[string]any{"show": true, "side": vMediaSide, "align": "start"}, Tone: vTone, Density: vDensity, LandmarkLabel: vLandmarkLabel, Aside: productDetailFill1(p, vProduct, vThumbs)}) {
@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "buy-box")}}) {
if uiutils.T(uiutils.Get(vProduct, "category")) {
@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "uppercase tracking-wide text-muted-foreground", Attrs: uiutils.Attrs("data-slot", "category")}}) {
{ uiutils.Text(uiutils.Get(vProduct, "category")) }
}
}
@ProductPrice(ProductPriceProps{Price: uiutils.Get(vProduct, "price"), CompareAt: uiutils.Get(vProduct, "compareAt"), Currency: uiutils.Get(vProduct, "currency"), Badge: uiutils.Cond(uiutils.T(uiutils.Get(vProduct, "badge")), uiutils.At(vBadges, uiutils.Get(vProduct, "badge")), ""), Was: uiutils.Get(vLabels, "was")})
@compose.Group(compose.GroupProps{Gap: "2", BoxProps: box.BoxProps{}}) {
@Rating(RatingProps{Value: uiutils.Get(vProduct, "rating"), Label: uiutils.Tpl(uiutils.Get(vLabels, "ratingLabel"), uiutils.Get(vProduct, "rating"))})
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Tpl(uiutils.Get(vLabels, "reviews"), uiutils.Get(vProduct, "reviews"))) }
}
}
@compose.Text(compose.TextProps{Size: "sm", Weight: "medium", TextProps: text.TextProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Get(vProduct, "inStock")), "text-foreground", "text-destructive")), Attrs: uiutils.Attrs("data-slot", "stock")}}) {
{ uiutils.Text(uiutils.Cond(uiutils.T(uiutils.Get(vProduct, "inStock")), uiutils.Get(vLabels, "inStock"), uiutils.Get(vLabels, "soldOut"))) }
}
@compose.Group(compose.GroupProps{Gap: "4", BoxProps: box.BoxProps{Class: "flex-wrap"}}) {
if uiutils.Eq(vBuy, "full") {
@NumberField(NumberFieldProps{Value: "1", Name: uiutils.Tpl("{0}-qty", vId), Min: "1", Label: uiutils.Get(vLabels, "qty"), Decrease: uiutils.Get(vLabels, "decrease"), Increase: uiutils.Get(vLabels, "increase")})
}
@compose.Button(compose.ButtonProps{ButtonProps: button.ButtonProps{Disabled: uiutils.T(!uiutils.T(uiutils.Get(vProduct, "inStock")))}}) {
{ uiutils.Text(uiutils.Get(vLabels, "add")) }
}
}
if uiutils.Eq(vBuy, "full") {
@compose.List(compose.ListProps{BoxProps: box.BoxProps{Tag: "ul", Class: "flex flex-col gap-2 text-sm text-muted-foreground"}}) {
@compose.ListItem(compose.ListItemProps{BoxProps: box.BoxProps{Class: "flex items-center gap-2"}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "truck", Size: 16})
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vLabels, "shipping")) }
}
}
@compose.ListItem(compose.ListItemProps{BoxProps: box.BoxProps{Class: "flex items-center gap-2"}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "shield-check", Size: 16})
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vLabels, "returns")) }
}
}
}
}
}
}
}
}
templ productDetailFill1(p ProductDetailProps, vProduct any, vThumbs any) {
@ProductGallery(ProductGalleryProps{Name: uiutils.Get(vProduct, "name"), Image: uiutils.Get(vProduct, "image"), Thumbs: vThumbs})
}
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-detail{#- 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-detail.json
A product page: a gallery (the main picture and optional thumbnails) beside the buy box (badge, rating, price, stock, quantity, add button, shipping and returns notes). Axes: layout (split, stacked), media side, thumbs (none, below), buy (full, compact), tone, density.
Props (p): id, product, labels, badges, level, layout, mediaSide, thumbs, buy, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_product = (p.product ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_badges = (p.badges ?? null) -%}
{%- set v_level = (p.level ?? 1) -%}
{%- set v_layout = (p.layout ?? 'split') -%}
{%- set v_mediaSide = (p.mediaSide ?? 'start') -%}
{%- set v_thumbs = (p.thumbs ?? 'below') -%}
{%- set v_buy = (p.buy ?? 'full') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- if og_t(not (og_t(v_product))) %}
{%- set c_1 -%}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'package', 'title': og_get(v_labels, ['empty'])}}, with_context = false) }}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_1)}, with_context = false) }}
{%- else %}
{%- set f_14 -%}
{{ include('blocks/product-gallery.html.twig', {'p': {'name': og_get(v_product, ['name']), 'image': og_get(v_product, ['image']), 'thumbs': v_thumbs}}, with_context = false) }}
{%- endset -%}
{%- set c_15 -%}
{%- set c_13 -%}
{%- if og_t(og_get(v_product, ['category'])) %}
{%- set c_2 -%}
{{ og_text(og_get(v_product, ['category'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'uppercase tracking-wide text-muted-foreground', 'attrs': og_attrs(['data-slot', 'category']), 'children': c_2}, with_context = false) }}
{%- endif %}
{{ include('blocks/product-price.html.twig', {'p': {'price': og_get(v_product, ['price']), 'compareAt': og_get(v_product, ['compareAt']), 'currency': og_get(v_product, ['currency']), 'badge': (og_t(og_get(v_product, ['badge'])) ? og_at(v_badges, og_get(v_product, ['badge'])) : ''), 'was': og_get(v_labels, ['was'])}}, with_context = false) }}
{%- set c_4 -%}
{{ include('blocks/rating.html.twig', {'p': {'value': og_get(v_product, ['rating']), 'label': og_tpl(og_get(v_labels, ['ratingLabel']), [og_get(v_product, ['rating'])])}}, with_context = false) }}
{%- set c_3 -%}
{{ og_text(og_tpl(og_get(v_labels, ['reviews']), [og_get(v_product, ['reviews'])])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'class': 'text-muted-foreground', 'children': c_3}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '2', 'children': c_4}, with_context = false) }}
{%- set c_5 -%}
{{ og_text((og_t(og_get(v_product, ['inStock'])) ? og_get(v_labels, ['inStock']) : og_get(v_labels, ['soldOut']))) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'medium', 'class': og_s((og_t(og_get(v_product, ['inStock'])) ? 'text-foreground' : 'text-destructive')), 'attrs': og_attrs(['data-slot', 'stock']), 'children': c_5}, with_context = false) }}
{%- set c_7 -%}
{%- if og_t(og_eq(v_buy, 'full')) %}
{{ include('blocks/number-field.html.twig', {'p': {'value': '1', 'name': og_tpl('{0}-qty', [v_id]), 'min': '1', 'label': og_get(v_labels, ['qty']), 'decrease': og_get(v_labels, ['decrease']), 'increase': og_get(v_labels, ['increase'])}}, with_context = false) }}
{%- endif %}
{%- set c_6 -%}
{{ og_text(og_get(v_labels, ['add'])) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'disabled': og_t(not (og_t(og_get(v_product, ['inStock'])))), 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'class': 'flex-wrap', 'children': c_7}, with_context = false) }}
{%- if og_t(og_eq(v_buy, 'full')) %}
{%- set c_12 -%}
{%- set c_9 -%}
{{ include('icons/LucideIcon.html.twig', {'name': 'truck', 'size': 16}, with_context = false) }}
{%- set c_8 -%}
{{ og_text(og_get(v_labels, ['shipping'])) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'children': c_8}, with_context = false) }}
{%- endset -%}
{{ include('compose/ListItem.html.twig', {'class': 'flex items-center gap-2', 'children': c_9}, with_context = false) }}
{%- set c_11 -%}
{{ include('icons/LucideIcon.html.twig', {'name': 'shield-check', 'size': 16}, with_context = false) }}
{%- set c_10 -%}
{{ og_text(og_get(v_labels, ['returns'])) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'children': c_10}, with_context = false) }}
{%- endset -%}
{{ include('compose/ListItem.html.twig', {'class': 'flex items-center gap-2', 'children': c_11}, with_context = false) }}
{%- endset -%}
{{ include('compose/List.html.twig', {'tag': 'ul', 'class': 'flex flex-col gap-2 text-sm text-muted-foreground', 'children': c_12}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'buy-box']), 'children': c_13}, with_context = false) }}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': og_get(v_product, ['name']), 'lead': og_get(v_product, ['summary']), 'heading': {'level': v_level}, 'layout': (og_t(og_eq(v_layout, 'split')) ? 'split' : 'stack'), 'media': {'show': true, 'side': v_mediaSide, 'align': 'start'}, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_14)}, 'children': og_markup(c_15)}, with_context = false) }}
{%- endif %}
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-detail{* 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-detail.json
A product page: a gallery (the main picture and optional thumbnails) beside the buy box (badge, rating, price, stock, quantity, add button, shipping and returns notes). Axes: layout (split, stacked), media side, thumbs (none, below), buy (full, compact), tone, density.
Props (p): id, product, labels, badges, level, layout, mediaSide, thumbs, buy, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_product = ($p['product'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_badges = ($p['badges'] ?? null)}
{var $v_level = ($p['level'] ?? 1)}
{var $v_layout = ($p['layout'] ?? 'split')}
{var $v_mediaSide = ($p['mediaSide'] ?? 'start')}
{var $v_thumbs = ($p['thumbs'] ?? 'below')}
{var $v_buy = ($p['buy'] ?? 'full')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{if og_t(!(og_t($v_product)))}
{capture $c_1}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'package', 'title' => og_get($v_labels, ['empty'])]])|noescape}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'tone' => $v_tone, 'density' => $v_density, 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_1)])|noescape}
{else}
{capture $f_14}
{=og_include('blocks/product-gallery.latte', ['p' => ['name' => og_get($v_product, ['name']), 'image' => og_get($v_product, ['image']), 'thumbs' => $v_thumbs]])|noescape}
{/capture}
{capture $c_15}
{capture $c_13}
{if og_t(og_get($v_product, ['category']))}
{capture $c_2}
{=og_text(og_get($v_product, ['category']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'uppercase tracking-wide text-muted-foreground', 'attrs' => og_attrs(['data-slot', 'category']), 'children' => (string) $c_2])|noescape}
{/if}
{=og_include('blocks/product-price.latte', ['p' => ['price' => og_get($v_product, ['price']), 'compareAt' => og_get($v_product, ['compareAt']), 'currency' => og_get($v_product, ['currency']), 'badge' => (og_t(og_get($v_product, ['badge'])) ? og_at($v_badges, og_get($v_product, ['badge'])) : ''), 'was' => og_get($v_labels, ['was'])]])|noescape}
{capture $c_4}
{=og_include('blocks/rating.latte', ['p' => ['value' => og_get($v_product, ['rating']), 'label' => og_tpl(og_get($v_labels, ['ratingLabel']), [og_get($v_product, ['rating'])])]])|noescape}
{capture $c_3}
{=og_text(og_tpl(og_get($v_labels, ['reviews']), [og_get($v_product, ['reviews'])]))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'class' => 'text-muted-foreground', 'children' => (string) $c_3])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'children' => (string) $c_4])|noescape}
{capture $c_5}
{=og_text((og_t(og_get($v_product, ['inStock'])) ? og_get($v_labels, ['inStock']) : og_get($v_labels, ['soldOut'])))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'medium', 'class' => og_s((og_t(og_get($v_product, ['inStock'])) ? 'text-foreground' : 'text-destructive')), 'attrs' => og_attrs(['data-slot', 'stock']), 'children' => (string) $c_5])|noescape}
{capture $c_7}
{if og_t(og_eq($v_buy, 'full'))}
{=og_include('blocks/number-field.latte', ['p' => ['value' => '1', 'name' => og_tpl('{0}-qty', [$v_id]), 'min' => '1', 'label' => og_get($v_labels, ['qty']), 'decrease' => og_get($v_labels, ['decrease']), 'increase' => og_get($v_labels, ['increase'])]])|noescape}
{/if}
{capture $c_6}
{=og_text(og_get($v_labels, ['add']))}
{/capture}
{=og_include('compose/Button.latte', ['disabled' => og_t(!(og_t(og_get($v_product, ['inStock'])))), 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'class' => 'flex-wrap', 'children' => (string) $c_7])|noescape}
{if og_t(og_eq($v_buy, 'full'))}
{capture $c_12}
{capture $c_9}
{=og_include('icons/LucideIcon.latte', ['name' => 'truck', 'size' => 16])|noescape}
{capture $c_8}
{=og_text(og_get($v_labels, ['shipping']))}
{/capture}
{=og_include('compose/Inline.latte', ['children' => (string) $c_8])|noescape}
{/capture}
{=og_include('compose/ListItem.latte', ['class' => 'flex items-center gap-2', 'children' => (string) $c_9])|noescape}
{capture $c_11}
{=og_include('icons/LucideIcon.latte', ['name' => 'shield-check', 'size' => 16])|noescape}
{capture $c_10}
{=og_text(og_get($v_labels, ['returns']))}
{/capture}
{=og_include('compose/Inline.latte', ['children' => (string) $c_10])|noescape}
{/capture}
{=og_include('compose/ListItem.latte', ['class' => 'flex items-center gap-2', 'children' => (string) $c_11])|noescape}
{/capture}
{=og_include('compose/List.latte', ['tag' => 'ul', 'class' => 'flex flex-col gap-2 text-sm text-muted-foreground', 'children' => (string) $c_12])|noescape}
{/if}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'buy-box']), 'children' => (string) $c_13])|noescape}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => og_get($v_product, ['name']), 'lead' => og_get($v_product, ['summary']), 'heading' => ['level' => $v_level], 'layout' => (og_t(og_eq($v_layout, 'split')) ? 'split' : 'stack'), 'media' => ['show' => true, 'side' => $v_mediaSide, 'align' => 'start'], 'tone' => $v_tone, 'density' => $v_density, 'landmarkLabel' => $v_landmarkLabel, 'aside' => og_markup($f_14)], 'children' => og_markup($c_15)])|noescape}
{/if}
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-detail{#- 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-detail.json
A product page: a gallery (the main picture and optional thumbnails) beside the buy box (badge, rating, price, stock, quantity, add button, shipping and returns notes). Axes: layout (split, stacked), media side, thumbs (none, below), buy (full, compact), tone, density.
Props (p): id, product, labels, badges, level, layout, mediaSide, thumbs, buy, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_product = og_def(p['product'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_badges = og_def(p['badges'], none) -%}
{%- set v_level = og_def(p['level'], 1) -%}
{%- set v_layout = og_def(p['layout'], 'split') -%}
{%- set v_mediaSide = og_def(p['mediaSide'], 'start') -%}
{%- set v_thumbs = og_def(p['thumbs'], 'below') -%}
{%- set v_buy = og_def(p['buy'], 'full') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_density = og_def(p['density'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- if og_t(not (og_t(v_product))) %}
{%- set c_1 -%}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'package', 'title': og_get(v_labels, ['empty'])}}) }}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_1)}) }}
{%- else %}
{%- set f_14 -%}
{{ og_include('blocks/product-gallery.html.j2', {'p': {'name': og_get(v_product, ['name']), 'image': og_get(v_product, ['image']), 'thumbs': v_thumbs}}) }}
{%- endset -%}
{%- set c_15 -%}
{%- set c_13 -%}
{%- if og_t(og_get(v_product, ['category'])) %}
{%- set c_2 -%}
{{ og_text(og_get(v_product, ['category'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'uppercase tracking-wide text-muted-foreground', 'Attrs': og_attrs(['data-slot', 'category'])}, 'children': c_2}) }}
{%- endif %}
{{ og_include('blocks/product-price.html.j2', {'p': {'price': og_get(v_product, ['price']), 'compareAt': og_get(v_product, ['compareAt']), 'currency': og_get(v_product, ['currency']), 'badge': (og_at(v_badges, og_get(v_product, ['badge'])) if og_t(og_get(v_product, ['badge'])) else ''), 'was': og_get(v_labels, ['was'])}}) }}
{%- set c_4 -%}
{{ og_include('blocks/rating.html.j2', {'p': {'value': og_get(v_product, ['rating']), 'label': og_tpl(og_get(v_labels, ['ratingLabel']), [og_get(v_product, ['rating'])])}}) }}
{%- set c_3 -%}
{{ og_text(og_tpl(og_get(v_labels, ['reviews']), [og_get(v_product, ['reviews'])])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Class': 'text-muted-foreground'}, 'children': c_3}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '2'}, 'children': c_4}) }}
{%- set c_5 -%}
{{ og_text((og_get(v_labels, ['inStock']) if og_t(og_get(v_product, ['inStock'])) else og_get(v_labels, ['soldOut']))) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'medium', 'Class': og_s(('text-foreground' if og_t(og_get(v_product, ['inStock'])) else 'text-destructive')), 'Attrs': og_attrs(['data-slot', 'stock'])}, 'children': c_5}) }}
{%- set c_7 -%}
{%- if og_t(og_eq(v_buy, 'full')) %}
{{ og_include('blocks/number-field.html.j2', {'p': {'value': '1', 'name': og_tpl('{0}-qty', [v_id]), 'min': '1', 'label': og_get(v_labels, ['qty']), 'decrease': og_get(v_labels, ['decrease']), 'increase': og_get(v_labels, ['increase'])}}) }}
{%- endif %}
{%- set c_6 -%}
{{ og_text(og_get(v_labels, ['add'])) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Disabled': og_t(not (og_t(og_get(v_product, ['inStock']))))}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Class': 'flex-wrap'}, 'children': c_7}) }}
{%- if og_t(og_eq(v_buy, 'full')) %}
{%- set c_12 -%}
{%- set c_9 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'truck', 'Size': 16}}) }}
{%- set c_8 -%}
{{ og_text(og_get(v_labels, ['shipping'])) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {}, 'children': c_8}) }}
{%- endset -%}
{{ og_include('compose/list-item.html.j2', {'p': {'Class': 'flex items-center gap-2'}, 'children': c_9}) }}
{%- set c_11 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'shield-check', 'Size': 16}}) }}
{%- set c_10 -%}
{{ og_text(og_get(v_labels, ['returns'])) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {}, 'children': c_10}) }}
{%- endset -%}
{{ og_include('compose/list-item.html.j2', {'p': {'Class': 'flex items-center gap-2'}, 'children': c_11}) }}
{%- endset -%}
{{ og_include('compose/list.html.j2', {'p': {'Tag': 'ul', 'Class': 'flex flex-col gap-2 text-sm text-muted-foreground'}, 'children': c_12}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'buy-box'])}, 'children': c_13}) }}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': og_get(v_product, ['name']), 'lead': og_get(v_product, ['summary']), 'heading': {'level': v_level}, 'layout': ('split' if og_t(og_eq(v_layout, 'split')) else 'stack'), 'media': {'show': true, 'side': v_mediaSide, 'align': 'start'}, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_14)}, 'children': og_markup(c_15)}) }}
{%- endif %}
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 product page: a gallery (the main picture and optional thumbnails) beside the buy box (badge, rating, price, stock, quantity, add button, shipping and returns notes). Axes: layout (split, stacked), media side, thumbs (none, below), buy (full, compact), tone, density.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| product | Product | - | the product; without one, the empty state (labels.empty) |
| labels (required) | ProductDetailLabels | - | |
| badges (required) | Record<string, string> | - | |
| level | 1 | 2 | 1 | |
| layout | "split" | "stacked" | "split" | |
| mediaSide | "start" | "end" | "start" | |
| thumbs | "none" | "below" | "below" | |
| buy | "full" | "compact" | "full" | |
| tone | "default" | "muted" | "default" | |
| density | "default" | "roomy" | "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 |