Side Checks
Side Checks component
Install
npx ui8kit add side-checksPulls in: checkbox, compose, fieldset, inline, kit-box, kit-checkbox, kit-label, kit-text, label, legend, option-chips, utils
Preview
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 side-checks<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Extras to tick: a fieldset named by its legend, one checkbox per option with its note and price. Static
markup.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { DishOption } from "./option-chips.types";
export type SideChecksProps = {
name: string;
legend: string;
options: DishOption[];
};
</script>
<script lang="ts">
import Checkbox from "../compose/Checkbox.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 { fmtMoney, tpl } from "../utils";
let { name, legend, options }: SideChecksProps = $props();
</script>
<Fieldset class="flex flex-col gap-2" data-slot="sides">
<Legend size="sm" class="mb-2">
{legend}
</Legend>
{#each options as o (o.id)}
<Label
class={"flex items-center justify-between gap-4 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted"}
data-slot="dish-option"
>
<Inline class="flex items-center gap-2">
<Checkbox name={tpl("{0}-{1}", name, o.id)} value="on" />
<Inline>
{o.name}
</Inline>
</Inline>
<Inline class="text-muted-foreground">
{tpl("{0} · {1}", o.note, fmtMoney(o.price, o.currency))}
</Inline>
</Label>
{/each}
</Fieldset>
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 side-checks// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Extras to tick: a fieldset named by its legend, one checkbox per option with its note and price. Static
* markup.
*/
import { type ReactNode } from "react";
import { Checkbox, Fieldset, Inline, Label, Legend } from "../compose";
import { fmtMoney, tpl } from "../utils";
import type { DishOption } from "./option-chips.types";
export type SideChecksProps = {
name: string;
legend: string;
options: DishOption[];
};
export function SideChecks({ name, legend, options }: SideChecksProps) {
return (
<Fieldset className="flex flex-col gap-2" data-slot="sides">
<Legend size="sm" className="mb-2">
{legend}
</Legend>
{(options ?? []).map((o) => (
<Label key={o.id}
className={"flex items-center justify-between gap-4 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted"}
data-slot="dish-option"
>
<Inline className="flex items-center gap-2">
<Checkbox name={tpl("{0}-{1}", name, o.id)} value="on" />
<Inline>
{o.name}
</Inline>
</Inline>
<Inline className="text-muted-foreground">
{tpl("{0} · {1}", o.note, fmtMoney(o.price, o.currency))}
</Inline>
</Label>
))}
</Fieldset>
);
}
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 side-checks<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Extras to tick: a fieldset named by its legend, one checkbox per option with its note and price. Static
markup.
-->
<script lang="ts">
import type { DishOption } from "./option-chips.types";
export type SideChecksProps = {
name: string;
legend: string;
options: DishOption[];
};
</script>
<script setup lang="ts">
import Checkbox from "../compose/Checkbox.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 { fmtMoney, tpl } from "../utils";
const { name, legend, options } = defineProps<SideChecksProps>();
</script>
<template>
<Fieldset class="flex flex-col gap-2" data-slot="sides">
<Legend size="sm" class="mb-2">
{{ legend }}
</Legend>
<Label v-for="o in options" :key="o.id"
:class="'flex items-center justify-between gap-4 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted'"
data-slot="dish-option"
>
<Inline class="flex items-center gap-2">
<Checkbox :name="tpl('{0}-{1}', name, o.id)" value="on" />
<Inline>
{{ o.name }}
</Inline>
</Inline>
<Inline class="text-muted-foreground">
{{ tpl("{0} · {1}", o.note, fmtMoney(o.price, o.currency)) }}
</Inline>
</Label>
</Fieldset>
</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 side-checks// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Extras to tick: a fieldset named by its legend, one checkbox per option with its note and price. Static
* markup.
*/
import { For, type JSX } from "solid-js";
import { Checkbox, Fieldset, Inline, Label, Legend } from "../compose";
import { fmtMoney, tpl } from "../utils";
import type { DishOption } from "./option-chips.types";
export type SideChecksProps = {
name: string;
legend: string;
options: DishOption[];
};
export function SideChecks({ name, legend, options }: SideChecksProps) {
return (
<Fieldset class="flex flex-col gap-2" data-slot="sides">
<Legend size="sm" class="mb-2">
{legend}
</Legend>
<For each={options ?? []}>{(o) => (
<Label
class={"flex items-center justify-between gap-4 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted"}
data-slot="dish-option"
>
<Inline class="flex items-center gap-2">
<Checkbox name={tpl("{0}-{1}", name, o.id)} value="on" />
<Inline>
{o.name}
</Inline>
</Inline>
<Inline class="text-muted-foreground">
{tpl("{0} · {1}", o.note, fmtMoney(o.price, o.currency))}
</Inline>
</Label>
)}</For>
</Fieldset>
);
}
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 side-checks// 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/side-checks.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/ui/checkbox"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/ui/label"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// SideChecksProps are the props of SideChecks; the values are the JSON shapes of the TypeScript props.
type SideChecksProps struct {
Name any `json:"name"`
Legend any `json:"legend"`
Options any `json:"options"`
}
// Extras to tick: a fieldset named by its legend, one checkbox per option with its note and price. Static markup.
templ SideChecks(p SideChecksProps) {
{{ 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("data-slot", "sides")}}) {
@compose.Legend(compose.LegendProps{Size: "sm", TextProps: text.TextProps{Class: "mb-2"}}) {
{ uiutils.Text(vLegend) }
}
for _, vO := range uiutils.L(vOptions) {
@compose.Label(compose.LabelProps{LabelProps: label.LabelProps{Class: "flex items-center justify-between gap-4 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted", Attrs: uiutils.Attrs("data-slot", "dish-option")}}) {
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "flex items-center gap-2"}}) {
@compose.Checkbox(compose.CheckboxProps{CheckboxProps: checkbox.CheckboxProps{Name: uiutils.S(uiutils.Tpl("{0}-{1}", vName, uiutils.Get(vO, "id"))), Value: uiutils.SP("on")}})
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vO, "name")) }
}
}
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Tpl("{0} · {1}", uiutils.Get(vO, "note"), uiutils.Money(uiutils.Get(vO, "price"), uiutils.Get(vO, "currency")))) }
}
}
}
}
}
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 side-checks{#- 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/side-checks.json
Extras to tick: a fieldset named by its legend, one checkbox per option with its note and price. Static markup.
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_6 -%}
{%- set c_1 -%}
{{ og_text(v_legend) }}
{%- endset -%}
{{ include('compose/Legend.html.twig', {'size': 'sm', 'class': 'mb-2', 'children': c_1}, with_context = false) }}
{%- for v_o in og_l(v_options) %}
{%- set c_5 -%}
{%- set c_3 -%}
{{ include('compose/Checkbox.html.twig', {'name': og_s(og_tpl('{0}-{1}', [v_name, og_get(v_o, ['id'])])), 'value': 'on'}, 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/Inline.html.twig', {'class': 'flex items-center gap-2', 'children': c_3}, with_context = false) }}
{%- set c_4 -%}
{{ og_text(og_tpl('{0} · {1}', [og_get(v_o, ['note']), og_money(og_get(v_o, ['price']), og_get(v_o, ['currency']))])) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': 'text-muted-foreground', 'children': c_4}, with_context = false) }}
{%- endset -%}
{{ include('compose/Label.html.twig', {'class': 'flex items-center justify-between gap-4 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted', 'attrs': og_attrs(['data-slot', 'dish-option']), 'children': c_5}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Fieldset.html.twig', {'class': 'flex flex-col gap-2', 'attrs': og_attrs(['data-slot', 'sides']), 'children': c_6}, 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 side-checks{* 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/side-checks.json
Extras to tick: a fieldset named by its legend, one checkbox per option with its note and price. Static markup.
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_6}
{capture $c_1}
{=og_text($v_legend)}
{/capture}
{=og_include('compose/Legend.latte', ['size' => 'sm', 'class' => 'mb-2', 'children' => (string) $c_1])|noescape}
{foreach og_l($v_options) as $v_o}
{capture $c_5}
{capture $c_3}
{=og_include('compose/Checkbox.latte', ['name' => og_s(og_tpl('{0}-{1}', [$v_name, og_get($v_o, ['id'])])), 'value' => 'on'])|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/Inline.latte', ['class' => 'flex items-center gap-2', 'children' => (string) $c_3])|noescape}
{capture $c_4}
{=og_text(og_tpl('{0} · {1}', [og_get($v_o, ['note']), og_money(og_get($v_o, ['price']), og_get($v_o, ['currency']))]))}
{/capture}
{=og_include('compose/Inline.latte', ['class' => 'text-muted-foreground', 'children' => (string) $c_4])|noescape}
{/capture}
{=og_include('compose/Label.latte', ['class' => 'flex items-center justify-between gap-4 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted', 'attrs' => og_attrs(['data-slot', 'dish-option']), 'children' => (string) $c_5])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Fieldset.latte', ['class' => 'flex flex-col gap-2', 'attrs' => og_attrs(['data-slot', 'sides']), 'children' => (string) $c_6])|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 side-checks{#- 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/side-checks.json
Extras to tick: a fieldset named by its legend, one checkbox per option with its note and price. Static markup.
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_6 -%}
{%- set c_1 -%}
{{ og_text(v_legend) }}
{%- endset -%}
{{ og_include('compose/legend.html.j2', {'p': {'Size': 'sm', 'Class': 'mb-2'}, 'children': c_1}) }}
{%- for v_o in og_l(v_options) %}
{%- set c_5 -%}
{%- set c_3 -%}
{{ og_include('compose/checkbox.html.j2', {'p': {'Name': og_s(og_tpl('{0}-{1}', [v_name, og_get(v_o, ['id'])])), 'Value': 'on'}}) }}
{%- 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/inline.html.j2', {'p': {'Class': 'flex items-center gap-2'}, 'children': c_3}) }}
{%- set c_4 -%}
{{ og_text(og_tpl('{0} · {1}', [og_get(v_o, ['note']), og_money(og_get(v_o, ['price']), og_get(v_o, ['currency']))])) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'text-muted-foreground'}, 'children': c_4}) }}
{%- endset -%}
{{ og_include('compose/label.html.j2', {'p': {'Class': 'flex items-center justify-between gap-4 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted', 'Attrs': og_attrs(['data-slot', 'dish-option'])}, 'children': c_5}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/fieldset.html.j2', {'p': {'Class': 'flex flex-col gap-2', 'Attrs': og_attrs(['data-slot', 'sides'])}, 'children': c_6}) }}
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.
Extras to tick: a fieldset named by its legend, one checkbox per option with its note and price. Static markup.
| Prop | Type | Default | Description |
|---|---|---|---|
| name (required) | string | - | prefix of the checkbox names (one per option: <name>-<option id>) |
| legend (required) | string | - | |
| options (required) | DishOption[] | - |