Skip to content
ui8kit

component / components

Payment Options

Payment Options component

Install

npx ui8kit add payment-options

Pulls in: compose, grid, inline, kit-box, kit-label, kit-radio, kit-text, label, lucide-icon, radio, 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-cdn
npx ui8kit add payment-options
components/payment-options.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. -->
<!-- Ways to pay as radio cards: icon, name and a line of text; `checked` is the chosen one. Static markup. -->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { Payment } from "./payment-options.types";

  export type PaymentOptionsProps = {
    payments: Payment[];
    name: string;
    checked?: string;
  };
</script>

<script lang="ts">
  import Grid from "../compose/Grid.svelte";
  import Inline from "../compose/Inline.svelte";
  import Label from "../compose/Label.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";
  import Radio from "../compose/Radio.svelte";

  let { payments, name, checked = "" }: PaymentOptionsProps = $props();
</script>

<Grid cols="1-2" class="gap-4" data-slot="payments">
  {#each payments as p (p.id)}
    <Label
      class={"flex items-center gap-4 rounded p-4 inset-ring inset-ring-border has-checked:inset-ring-foreground"}
      data-slot="payment"
    >
      <Radio name={name} value={p.id} checked={(p.id === checked)} />
      <LucideIcon name={p.icon} size={20} class="shrink-0" />
      <Inline class="flex flex-col items-start justify-start gap-0">
        <Inline class="text-sm font-semibold">
          {p.title}
        </Inline>
        <Inline class="text-xs text-muted-foreground">
          {p.text}
        </Inline>
      </Inline>
    </Label>
  {/each}
</Grid>
components/payment-options.types.ts
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.

export type Payment = {
  id: string;
  title: string;
  text: string;
  icon: string;
};

Svelte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdn
npx ui8kit add payment-options
components/payment-options.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.
/** Ways to pay as radio cards: icon, name and a line of text; `checked` is the chosen one. Static markup. */
import { type ReactNode } from "react";
import { Grid, Inline, Label, Radio } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import type { Payment } from "./payment-options.types";

export type PaymentOptionsProps = {
  payments: Payment[];
  name: string;
  checked?: string;
};

export function PaymentOptions({ payments, name, checked = "" }: PaymentOptionsProps) {
  return (
    <Grid cols="1-2" className="gap-4" data-slot="payments">
      {(payments ?? []).map((p) => (
        <Label key={p.id}
          className={"flex items-center gap-4 rounded p-4 inset-ring inset-ring-border has-checked:inset-ring-foreground"}
          data-slot="payment"
        >
          <Radio name={name} value={p.id} checked={(p.id === checked)} />
          <LucideIcon name={p.icon} size={20} className="shrink-0" />
          <Inline className="flex flex-col items-start justify-start gap-0">
            <Inline className="text-sm font-semibold">
              {p.title}
            </Inline>
            <Inline className="text-xs text-muted-foreground">
              {p.text}
            </Inline>
          </Inline>
        </Label>
      ))}
    </Grid>
  );
}
components/payment-options.types.ts
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.

export type Payment = {
  id: string;
  title: string;
  text: string;
  icon: string;
};

React registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdn
npx ui8kit add payment-options
components/payment-options.types.ts
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.

export type Payment = {
  id: string;
  title: string;
  text: string;
  icon: string;
};
components/payment-options.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. -->
<!-- Ways to pay as radio cards: icon, name and a line of text; `checked` is the chosen one. Static markup. -->
<script lang="ts">
import type { Payment } from "./payment-options.types";

export type PaymentOptionsProps = {
  payments: Payment[];
  name: string;
  checked?: string;
};
</script>

<script setup lang="ts">
import Grid from "../compose/Grid.vue";
import Inline from "../compose/Inline.vue";
import Label from "../compose/Label.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Radio from "../compose/Radio.vue";

const { payments, name, checked = "" } = defineProps<PaymentOptionsProps>();
</script>

<template>
  <Grid cols="1-2" class="gap-4" data-slot="payments">
    <Label v-for="p in payments" :key="p.id"
      :class="'flex items-center gap-4 rounded p-4 inset-ring inset-ring-border has-checked:inset-ring-foreground'"
      data-slot="payment"
    >
      <Radio :name="name" :value="p.id" :checked="(p.id === checked)" />
      <LucideIcon :name="p.icon" :size="20" class="shrink-0" />
      <Inline class="flex flex-col items-start justify-start gap-0">
        <Inline class="text-sm font-semibold">
          {{ p.title }}
        </Inline>
        <Inline class="text-xs text-muted-foreground">
          {{ p.text }}
        </Inline>
      </Inline>
    </Label>
  </Grid>
</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 payment-options
components/payment-options.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.
/** Ways to pay as radio cards: icon, name and a line of text; `checked` is the chosen one. Static markup. */
import { For, type JSX } from "solid-js";
import { Grid, Inline, Label, Radio } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import type { Payment } from "./payment-options.types";

export type PaymentOptionsProps = {
  payments: Payment[];
  name: string;
  checked?: string;
};

export function PaymentOptions({ payments, name, checked = "" }: PaymentOptionsProps) {
  return (
    <Grid cols="1-2" class="gap-4" data-slot="payments">
      <For each={payments ?? []}>{(p) => (
        <Label
          class={"flex items-center gap-4 rounded p-4 inset-ring inset-ring-border has-checked:inset-ring-foreground"}
          data-slot="payment"
        >
          <Radio name={name} value={p.id} checked={(p.id === checked)} />
          <LucideIcon name={p.icon} size={20} class="shrink-0" />
          <Inline class="flex flex-col items-start justify-start gap-0">
            <Inline class="text-sm font-semibold">
              {p.title}
            </Inline>
            <Inline class="text-xs text-muted-foreground">
              {p.text}
            </Inline>
          </Inline>
        </Label>
      )}</For>
    </Grid>
  );
}
components/payment-options.types.ts
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.

export type Payment = {
  id: string;
  title: string;
  text: string;
  icon: string;
};

Solid registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdn
npx ui8kit add payment-options
blocks/payment-options.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/payment-options.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/ui/box"
	"github.com/ui8kit/codegen/generated/templ/compose"
	"github.com/ui8kit/codegen/generated/templ/icons"
	"github.com/ui8kit/codegen/generated/templ/ui/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"
)

// PaymentOptionsProps are the props of PaymentOptions; the values are the JSON shapes of the TypeScript props.
type PaymentOptionsProps struct {
	Payments any `json:"payments"`
	Name any `json:"name"`
	Checked any `json:"checked"`
}

// Ways to pay as radio cards: icon, name and a line of text; `checked` is the chosen one. Static markup.
templ PaymentOptions(p PaymentOptionsProps) {
	{{ vPayments := p.Payments }}
	{{ vName := p.Name }}
	{{ vChecked := uiutils.Def(p.Checked, "") }}
	@compose.Grid(compose.GridProps{Cols: "1-2", BoxProps: box.BoxProps{Class: "gap-4", Attrs: uiutils.Attrs("data-slot", "payments")}}) {
		for _, vP := range uiutils.L(vPayments) {
			@compose.Label(compose.LabelProps{LabelProps: label.LabelProps{Class: "flex items-center gap-4 rounded p-4 inset-ring inset-ring-border has-checked:inset-ring-foreground", Attrs: uiutils.Attrs("data-slot", "payment")}}) {
				@compose.Radio(compose.RadioProps{RadioProps: radio.RadioProps{Name: uiutils.S(vName), Value: uiutils.SP(uiutils.Get(vP, "id")), Checked: uiutils.T(uiutils.Eq(uiutils.Get(vP, "id"), vChecked))}})
				@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(uiutils.Get(vP, "icon")), Size: 20, Class: "shrink-0"})
				@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "flex flex-col items-start justify-start gap-0"}}) {
					@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-sm font-semibold"}}) {
						{ uiutils.Text(uiutils.Get(vP, "title")) }
					}
					@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-xs text-muted-foreground"}}) {
						{ uiutils.Text(uiutils.Get(vP, "text")) }
					}
				}
			}
		}
	}
}

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 payment-options
blocks/payment-options.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/payment-options.json
    Ways to pay as radio cards: icon, name and a line of text; `checked` is the chosen one. Static markup.
    Props (p): payments, name, checked. -#}
{%- set v_payments = (p.payments ?? null) -%}
{%- set v_name = (p.name ?? null) -%}
{%- set v_checked = (p.checked ?? '') -%}
{%- set c_5 -%}
  {%- for v_p in og_l(v_payments) %}
    {%- set c_4 -%}
      {{ include('compose/Radio.html.twig', {'name': og_s(v_name), 'value': og_s(og_get(v_p, ['id'])), 'checked': og_t(og_eq(og_get(v_p, ['id']), v_checked))}, with_context = false) }}
      {{ include('icons/LucideIcon.html.twig', {'name': og_s(og_get(v_p, ['icon'])), 'size': 20, 'class': 'shrink-0'}, with_context = false) }}
      {%- set c_3 -%}
        {%- set c_1 -%}
          {{ og_text(og_get(v_p, ['title'])) }}
        {%- endset -%}
        {{ include('compose/Inline.html.twig', {'class': 'text-sm font-semibold', 'children': c_1}, with_context = false) }}
        {%- set c_2 -%}
          {{ og_text(og_get(v_p, ['text'])) }}
        {%- endset -%}
        {{ include('compose/Inline.html.twig', {'class': 'text-xs text-muted-foreground', 'children': c_2}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Inline.html.twig', {'class': 'flex flex-col items-start justify-start gap-0', 'children': c_3}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Label.html.twig', {'class': 'flex items-center gap-4 rounded p-4 inset-ring inset-ring-border has-checked:inset-ring-foreground', 'attrs': og_attrs(['data-slot', 'payment']), 'children': c_4}, with_context = false) }}
  {%- endfor %}
{%- endset -%}
{{ include('compose/Grid.html.twig', {'cols': '1-2', 'class': 'gap-4', 'attrs': og_attrs(['data-slot', 'payments']), 'children': c_5}, 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 payment-options
blocks/payment-options.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/payment-options.json
    Ways to pay as radio cards: icon, name and a line of text; `checked` is the chosen one. Static markup.
    Props (p): payments, name, checked. *}
{var $v_payments = ($p['payments'] ?? null)}
{var $v_name = ($p['name'] ?? null)}
{var $v_checked = ($p['checked'] ?? '')}
{capture $c_5}
  {foreach og_l($v_payments) as $v_p}
    {capture $c_4}
      {=og_include('compose/Radio.latte', ['name' => og_s($v_name), 'value' => og_s(og_get($v_p, ['id'])), 'checked' => og_t(og_eq(og_get($v_p, ['id']), $v_checked))])|noescape}
      {=og_include('icons/LucideIcon.latte', ['name' => og_s(og_get($v_p, ['icon'])), 'size' => 20, 'class' => 'shrink-0'])|noescape}
      {capture $c_3}
        {capture $c_1}
          {=og_text(og_get($v_p, ['title']))}
        {/capture}
        {=og_include('compose/Inline.latte', ['class' => 'text-sm font-semibold', 'children' => (string) $c_1])|noescape}
        {capture $c_2}
          {=og_text(og_get($v_p, ['text']))}
        {/capture}
        {=og_include('compose/Inline.latte', ['class' => 'text-xs text-muted-foreground', 'children' => (string) $c_2])|noescape}
      {/capture}
      {=og_include('compose/Inline.latte', ['class' => 'flex flex-col items-start justify-start gap-0', 'children' => (string) $c_3])|noescape}
    {/capture}
    {=og_include('compose/Label.latte', ['class' => 'flex items-center gap-4 rounded p-4 inset-ring inset-ring-border has-checked:inset-ring-foreground', 'attrs' => og_attrs(['data-slot', 'payment']), 'children' => (string) $c_4])|noescape}
  {/foreach}
{/capture}
{=og_include('compose/Grid.latte', ['cols' => '1-2', 'class' => 'gap-4', 'attrs' => og_attrs(['data-slot', 'payments']), 'children' => (string) $c_5])|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 payment-options
blocks/payment-options.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/payment-options.json
    Ways to pay as radio cards: icon, name and a line of text; `checked` is the chosen one. Static markup.
    Props (p): payments, name, checked. -#}
{%- set v_payments = og_def(p['payments'], none) -%}
{%- set v_name = og_def(p['name'], none) -%}
{%- set v_checked = og_def(p['checked'], '') -%}
{%- set c_5 -%}
  {%- for v_p in og_l(v_payments) %}
    {%- set c_4 -%}
      {{ og_include('compose/radio.html.j2', {'p': {'Name': og_s(v_name), 'Value': og_s(og_get(v_p, ['id'])), 'Checked': og_t(og_eq(og_get(v_p, ['id']), v_checked))}}) }}
      {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(og_get(v_p, ['icon'])), 'Size': 20, 'Class': 'shrink-0'}}) }}
      {%- set c_3 -%}
        {%- set c_1 -%}
          {{ og_text(og_get(v_p, ['title'])) }}
        {%- endset -%}
        {{ og_include('compose/inline.html.j2', {'p': {'Class': 'text-sm font-semibold'}, 'children': c_1}) }}
        {%- set c_2 -%}
          {{ og_text(og_get(v_p, ['text'])) }}
        {%- endset -%}
        {{ og_include('compose/inline.html.j2', {'p': {'Class': 'text-xs text-muted-foreground'}, 'children': c_2}) }}
      {%- endset -%}
      {{ og_include('compose/inline.html.j2', {'p': {'Class': 'flex flex-col items-start justify-start gap-0'}, 'children': c_3}) }}
    {%- endset -%}
    {{ og_include('compose/label.html.j2', {'p': {'Class': 'flex items-center gap-4 rounded p-4 inset-ring inset-ring-border has-checked:inset-ring-foreground', 'Attrs': og_attrs(['data-slot', 'payment'])}, 'children': c_4}) }}
  {%- endfor %}
{%- endset -%}
{{ og_include('compose/grid.html.j2', {'p': {'Cols': '1-2', 'Class': 'gap-4', 'Attrs': og_attrs(['data-slot', 'payments'])}, 'children': c_5}) }}

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.

Ways to pay as radio cards: icon, name and a line of text; `checked` is the chosen one. Static markup.

Props of PaymentOptions
PropTypeDefault Description
payments (required)Payment[]-
name (required)string-name of the radio group
checked string""id of the chosen payment

Used in