Skip to content
ui8kit

component / components

Meat Cards

Meat Cards component

Install

npx ui8kit add meat-cards

Pulls in: box, compose, fieldset, inline, kit-box, kit-label, kit-radio, kit-text, label, legend, media-frame, option-chips, radio, utils

Preview

Meat
$18.90 · per 500 g
$12.90 · per 500 g
$26.90 · per 500 g
$29.90 · per 500 g

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 meat-cards
components/meat-cards.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. -->
<!--
  The meat of a grill dish as picture cards in one radio group (fieldset with role radiogroup named by its
  legend): a picture, the name and the price per 500 g; the first checked.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { DishOption } from "./option-chips.types";

  export type MeatCardsProps = {
    name: string;
    legend: string;
    options: DishOption[];
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import Fieldset from "../compose/Fieldset.svelte";
  import Inline from "../compose/Inline.svelte";
  import Label from "../compose/Label.svelte";
  import Legend from "../compose/Legend.svelte";
  import Radio from "../compose/Radio.svelte";
  import MediaFrame from "../components/media-frame.svelte";
  import { fmtMoney, tpl } from "../utils";

  let { name, legend, options }: MeatCardsProps = $props();
</script>

<Fieldset
  class="flex flex-col gap-2"
  role="radiogroup"
  aria-labelledby={tpl("{0}-legend", name)}
  data-slot="meat"
>
  <Legend size="sm" class="mb-2" id={tpl("{0}-legend", name)}>
    {legend}
  </Legend>
  <Box class="grid grid-cols-2 gap-4 md:grid-cols-4">
    {#each options as o, i (o.id)}
      <Box
        class={"flex flex-col gap-2 rounded p-2 text-sm inset-ring inset-ring-border has-checked:bg-muted " +
          "has-checked:inset-ring-foreground"}
        data-slot="option"
      >
        <MediaFrame alt={o.name} src={o.image} ratio="4/3" />
        <Label class="flex items-center gap-2 font-medium">
          <Radio name={name} value={o.id} checked={(i === 0)} />
          <Inline>
            {o.name}
          </Inline>
        </Label>
        <Inline class="text-xs text-muted-foreground">
          {tpl("{0} · {1}", fmtMoney(o.price, o.currency), o.note)}
        </Inline>
      </Box>
    {/each}
  </Box>
</Fieldset>

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 meat-cards
components/meat-cards.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.
/**
 * The meat of a grill dish as picture cards in one radio group (fieldset with role radiogroup named by its
 * legend): a picture, the name and the price per 500 g; the first checked.
 */
import { type ReactNode } from "react";
import { Box, Fieldset, Inline, Label, Legend, Radio } from "../compose";
import { MediaFrame } from "../components/media-frame";
import { fmtMoney, tpl } from "../utils";
import type { DishOption } from "./option-chips.types";

export type MeatCardsProps = {
  name: string;
  legend: string;
  options: DishOption[];
};

export function MeatCards({ name, legend, options }: MeatCardsProps) {
  return (
    <Fieldset
      className="flex flex-col gap-2"
      role="radiogroup"
      aria-labelledby={tpl("{0}-legend", name)}
      data-slot="meat"
    >
      <Legend size="sm" className="mb-2" id={tpl("{0}-legend", name)}>
        {legend}
      </Legend>
      <Box className="grid grid-cols-2 gap-4 md:grid-cols-4">
        {(options ?? []).map((o, i) => (
          <Box key={o.id}
            className={"flex flex-col gap-2 rounded p-2 text-sm inset-ring inset-ring-border has-checked:bg-muted " +
              "has-checked:inset-ring-foreground"}
            data-slot="option"
          >
            <MediaFrame alt={o.name} src={o.image} ratio="4/3" />
            <Label className="flex items-center gap-2 font-medium">
              <Radio name={name} value={o.id} checked={(i === 0)} />
              <Inline>
                {o.name}
              </Inline>
            </Label>
            <Inline className="text-xs text-muted-foreground">
              {tpl("{0} · {1}", fmtMoney(o.price, o.currency), o.note)}
            </Inline>
          </Box>
        ))}
      </Box>
    </Fieldset>
  );
}

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 meat-cards
components/meat-cards.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. -->
<!--
  The meat of a grill dish as picture cards in one radio group (fieldset with role radiogroup named by its
  legend): a picture, the name and the price per 500 g; the first checked.
-->
<script lang="ts">
import type { DishOption } from "./option-chips.types";

export type MeatCardsProps = {
  name: string;
  legend: string;
  options: DishOption[];
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import Fieldset from "../compose/Fieldset.vue";
import Inline from "../compose/Inline.vue";
import Label from "../compose/Label.vue";
import Legend from "../compose/Legend.vue";
import Radio from "../compose/Radio.vue";
import MediaFrame from "../components/media-frame.vue";
import { fmtMoney, tpl } from "../utils";

const { name, legend, options } = defineProps<MeatCardsProps>();
</script>

<template>
  <Fieldset
    class="flex flex-col gap-2"
    role="radiogroup"
    :aria-labelledby="tpl('{0}-legend', name)"
    data-slot="meat"
  >
    <Legend size="sm" class="mb-2" :id="tpl('{0}-legend', name)">
      {{ legend }}
    </Legend>
    <Box class="grid grid-cols-2 gap-4 md:grid-cols-4">
      <Box v-for="(o, i) in options" :key="o.id"
        :class="'flex flex-col gap-2 rounded p-2 text-sm inset-ring inset-ring-border has-checked:bg-muted ' +
          'has-checked:inset-ring-foreground'"
        data-slot="option"
      >
        <MediaFrame :alt="o.name" :src="o.image" ratio="4/3" />
        <Label class="flex items-center gap-2 font-medium">
          <Radio :name="name" :value="o.id" :checked="(i === 0)" />
          <Inline>
            {{ o.name }}
          </Inline>
        </Label>
        <Inline class="text-xs text-muted-foreground">
          {{ tpl("{0} · {1}", fmtMoney(o.price, o.currency), o.note) }}
        </Inline>
      </Box>
    </Box>
  </Fieldset>
</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 meat-cards
components/meat-cards.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.
/**
 * The meat of a grill dish as picture cards in one radio group (fieldset with role radiogroup named by its
 * legend): a picture, the name and the price per 500 g; the first checked.
 */
import { For, type JSX } from "solid-js";
import { Box, Fieldset, Inline, Label, Legend, Radio } from "../compose";
import { MediaFrame } from "../components/media-frame";
import { fmtMoney, tpl } from "../utils";
import type { DishOption } from "./option-chips.types";

export type MeatCardsProps = {
  name: string;
  legend: string;
  options: DishOption[];
};

export function MeatCards({ name, legend, options }: MeatCardsProps) {
  return (
    <Fieldset
      class="flex flex-col gap-2"
      role="radiogroup"
      aria-labelledby={tpl("{0}-legend", name)}
      data-slot="meat"
    >
      <Legend size="sm" class="mb-2" id={tpl("{0}-legend", name)}>
        {legend}
      </Legend>
      <Box class="grid grid-cols-2 gap-4 md:grid-cols-4">
        <For each={options ?? []}>{(o, iOf) => { const i = iOf(); return (
          <Box
            class={"flex flex-col gap-2 rounded p-2 text-sm inset-ring inset-ring-border has-checked:bg-muted " +
              "has-checked:inset-ring-foreground"}
            data-slot="option"
          >
            <MediaFrame alt={o.name} src={o.image} ratio="4/3" />
            <Label class="flex items-center gap-2 font-medium">
              <Radio name={name} value={o.id} checked={(i === 0)} />
              <Inline>
                {o.name}
              </Inline>
            </Label>
            <Inline class="text-xs text-muted-foreground">
              {tpl("{0} · {1}", fmtMoney(o.price, o.currency), o.note)}
            </Inline>
          </Box>
        ); }}</For>
      </Box>
    </Fieldset>
  );
}

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 meat-cards
blocks/meat-cards.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/meat-cards.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/ui/label"
	"github.com/ui8kit/codegen/generated/templ/ui/radio"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// MeatCardsProps are the props of MeatCards; the values are the JSON shapes of the TypeScript props.
type MeatCardsProps struct {
	Name any `json:"name"`
	Legend any `json:"legend"`
	Options any `json:"options"`
}

// The meat of a grill dish as picture cards in one radio group (fieldset with role radiogroup named by its legend): a picture, the name and the price per 500 g; the first checked.
templ MeatCards(p MeatCardsProps) {
	{{ vName := p.Name }}
	{{ vLegend := p.Legend }}
	{{ vOptions := p.Options }}
	@compose.Fieldset(compose.FieldsetProps{BoxProps: box.BoxProps{Class: "flex flex-col gap-2", Attrs: uiutils.Attrs("role", "radiogroup", "aria-labelledby", uiutils.Tpl("{0}-legend", vName), "data-slot", "meat")}}) {
		@compose.Legend(compose.LegendProps{Size: "sm", TextProps: text.TextProps{Class: "mb-2", Attrs: uiutils.Attrs("id", uiutils.Tpl("{0}-legend", vName))}}) {
			{ uiutils.Text(vLegend) }
		}
		@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "grid grid-cols-2 gap-4 md:grid-cols-4"}}) {
			for vI, vO := range uiutils.L(vOptions) {
				@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex flex-col gap-2 rounded p-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground", Attrs: uiutils.Attrs("data-slot", "option")}}) {
					@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vO, "name"), Src: uiutils.Get(vO, "image"), Ratio: "4/3"})
					@compose.Label(compose.LabelProps{LabelProps: label.LabelProps{Class: "flex items-center gap-2 font-medium"}}) {
						@compose.Radio(compose.RadioProps{RadioProps: radio.RadioProps{Name: uiutils.S(vName), Value: uiutils.SP(uiutils.Get(vO, "id")), Checked: uiutils.T(uiutils.Eq(float64(vI), float64(0)))}})
						@compose.Inline(compose.InlineProps{TextProps: text.TextProps{}}) {
							{ uiutils.Text(uiutils.Get(vO, "name")) }
						}
					}
					@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-xs text-muted-foreground"}}) {
						{ uiutils.Text(uiutils.Tpl("{0} · {1}", uiutils.Money(uiutils.Get(vO, "price"), uiutils.Get(vO, "currency")), uiutils.Get(vO, "note"))) }
					}
				}
			}
		}
	}
}

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 meat-cards
blocks/meat-cards.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/meat-cards.json
    The meat of a grill dish as picture cards in one radio group (fieldset with role radiogroup named by its legend): a picture, the name and the price per 500 g; the first checked.
    Props (p): name, legend, options. -#}
{%- set v_name = (p.name ?? null) -%}
{%- set v_legend = (p.legend ?? null) -%}
{%- set v_options = (p.options ?? null) -%}
{%- set c_7 -%}
  {%- set c_1 -%}
    {{ og_text(v_legend) }}
  {%- endset -%}
  {{ include('compose/Legend.html.twig', {'size': 'sm', 'class': 'mb-2', 'attrs': og_attrs(['id', og_tpl('{0}-legend', [v_name])]), 'children': c_1}, with_context = false) }}
  {%- set c_6 -%}
    {%- for v_o in og_l(v_options) %}
      {%- set v_i = loop.index0 -%}
      {%- set c_5 -%}
        {{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_o, ['name']), 'src': og_get(v_o, ['image']), 'ratio': '4/3'}}, with_context = false) }}
        {%- set c_3 -%}
          {{ include('compose/Radio.html.twig', {'name': og_s(v_name), 'value': og_s(og_get(v_o, ['id'])), 'checked': og_t(og_eq(v_i, 0))}, with_context = false) }}
          {%- set c_2 -%}
            {{ og_text(og_get(v_o, ['name'])) }}
          {%- endset -%}
          {{ include('compose/Inline.html.twig', {'children': c_2}, with_context = false) }}
        {%- endset -%}
        {{ include('compose/Label.html.twig', {'class': 'flex items-center gap-2 font-medium', 'children': c_3}, with_context = false) }}
        {%- set c_4 -%}
          {{ og_text(og_tpl('{0} · {1}', [og_money(og_get(v_o, ['price']), og_get(v_o, ['currency'])), og_get(v_o, ['note'])])) }}
        {%- endset -%}
        {{ include('compose/Inline.html.twig', {'class': 'text-xs text-muted-foreground', 'children': c_4}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Box.html.twig', {'class': 'flex flex-col gap-2 rounded p-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground', 'attrs': og_attrs(['data-slot', 'option']), 'children': c_5}, with_context = false) }}
    {%- endfor %}
  {%- endset -%}
  {{ include('compose/Box.html.twig', {'class': 'grid grid-cols-2 gap-4 md:grid-cols-4', 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/Fieldset.html.twig', {'class': 'flex flex-col gap-2', 'attrs': og_attrs(['role', 'radiogroup', 'aria-labelledby', og_tpl('{0}-legend', [v_name]), 'data-slot', 'meat']), 'children': c_7}, 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 meat-cards
blocks/meat-cards.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/meat-cards.json
    The meat of a grill dish as picture cards in one radio group (fieldset with role radiogroup named by its legend): a picture, the name and the price per 500 g; the first checked.
    Props (p): name, legend, options. *}
{var $v_name = ($p['name'] ?? null)}
{var $v_legend = ($p['legend'] ?? null)}
{var $v_options = ($p['options'] ?? null)}
{capture $c_7}
  {capture $c_1}
    {=og_text($v_legend)}
  {/capture}
  {=og_include('compose/Legend.latte', ['size' => 'sm', 'class' => 'mb-2', 'attrs' => og_attrs(['id', og_tpl('{0}-legend', [$v_name])]), 'children' => (string) $c_1])|noescape}
  {capture $c_6}
    {foreach og_l($v_options) as $v_o}
      {var $v_i = $iterator->counter0}
      {capture $c_5}
        {=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_o, ['name']), 'src' => og_get($v_o, ['image']), 'ratio' => '4/3']])|noescape}
        {capture $c_3}
          {=og_include('compose/Radio.latte', ['name' => og_s($v_name), 'value' => og_s(og_get($v_o, ['id'])), 'checked' => og_t(og_eq($v_i, 0))])|noescape}
          {capture $c_2}
            {=og_text(og_get($v_o, ['name']))}
          {/capture}
          {=og_include('compose/Inline.latte', ['children' => (string) $c_2])|noescape}
        {/capture}
        {=og_include('compose/Label.latte', ['class' => 'flex items-center gap-2 font-medium', 'children' => (string) $c_3])|noescape}
        {capture $c_4}
          {=og_text(og_tpl('{0} · {1}', [og_money(og_get($v_o, ['price']), og_get($v_o, ['currency'])), og_get($v_o, ['note'])]))}
        {/capture}
        {=og_include('compose/Inline.latte', ['class' => 'text-xs text-muted-foreground', 'children' => (string) $c_4])|noescape}
      {/capture}
      {=og_include('compose/Box.latte', ['class' => 'flex flex-col gap-2 rounded p-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground', 'attrs' => og_attrs(['data-slot', 'option']), 'children' => (string) $c_5])|noescape}
    {/foreach}
  {/capture}
  {=og_include('compose/Box.latte', ['class' => 'grid grid-cols-2 gap-4 md:grid-cols-4', 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/Fieldset.latte', ['class' => 'flex flex-col gap-2', 'attrs' => og_attrs(['role', 'radiogroup', 'aria-labelledby', og_tpl('{0}-legend', [$v_name]), 'data-slot', 'meat']), 'children' => (string) $c_7])|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 meat-cards
blocks/meat-cards.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/meat-cards.json
    The meat of a grill dish as picture cards in one radio group (fieldset with role radiogroup named by its legend): a picture, the name and the price per 500 g; the first checked.
    Props (p): name, legend, options. -#}
{%- set v_name = og_def(p['name'], none) -%}
{%- set v_legend = og_def(p['legend'], none) -%}
{%- set v_options = og_def(p['options'], none) -%}
{%- set c_7 -%}
  {%- set c_1 -%}
    {{ og_text(v_legend) }}
  {%- endset -%}
  {{ og_include('compose/legend.html.j2', {'p': {'Size': 'sm', 'Class': 'mb-2', 'Attrs': og_attrs(['id', og_tpl('{0}-legend', [v_name])])}, 'children': c_1}) }}
  {%- set c_6 -%}
    {%- for v_o in og_l(v_options) %}
      {%- set v_i = loop.index0 -%}
      {%- set c_5 -%}
        {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_o, ['name']), 'src': og_get(v_o, ['image']), 'ratio': '4/3'}}) }}
        {%- set c_3 -%}
          {{ og_include('compose/radio.html.j2', {'p': {'Name': og_s(v_name), 'Value': og_s(og_get(v_o, ['id'])), 'Checked': og_t(og_eq(v_i, 0))}}) }}
          {%- set c_2 -%}
            {{ og_text(og_get(v_o, ['name'])) }}
          {%- endset -%}
          {{ og_include('compose/inline.html.j2', {'p': {}, 'children': c_2}) }}
        {%- endset -%}
        {{ og_include('compose/label.html.j2', {'p': {'Class': 'flex items-center gap-2 font-medium'}, 'children': c_3}) }}
        {%- set c_4 -%}
          {{ og_text(og_tpl('{0} · {1}', [og_money(og_get(v_o, ['price']), og_get(v_o, ['currency'])), og_get(v_o, ['note'])])) }}
        {%- endset -%}
        {{ og_include('compose/inline.html.j2', {'p': {'Class': 'text-xs text-muted-foreground'}, 'children': c_4}) }}
      {%- endset -%}
      {{ og_include('compose/box.html.j2', {'p': {'Class': 'flex flex-col gap-2 rounded p-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground', 'Attrs': og_attrs(['data-slot', 'option'])}, 'children': c_5}) }}
    {%- endfor %}
  {%- endset -%}
  {{ og_include('compose/box.html.j2', {'p': {'Class': 'grid grid-cols-2 gap-4 md:grid-cols-4'}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/fieldset.html.j2', {'p': {'Class': 'flex flex-col gap-2', 'Attrs': og_attrs(['role', 'radiogroup', 'aria-labelledby', og_tpl('{0}-legend', [v_name]), 'data-slot', 'meat'])}, 'children': c_7}) }}

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.

The meat of a grill dish as picture cards in one radio group (fieldset with role radiogroup named by its legend): a picture, the name and the price per 500 g; the first checked.

Props of MeatCards
PropTypeDefault Description
name (required)string-name of the radio group; the legend id is `<name>-legend`
legend (required)string-
options (required)DishOption[]-

Used in