Skip to content
ui8kit

block / promo

Newsletter Form

An email field and a button, inline, stacked or beside a picture.

Install

npx ui8kit add newsletter-form

Pulls in: button, compose, form, group, input, kit-box, kit-button, kit-form, kit-input, kit-label, kit-text, label, media-frame, section-frame, text, utils

Preview

Get the monthly digest

One short email a month with new blocks, guides and releases.

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 newsletter-form
blocks/newsletter-form.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. -->
<!--
  An email sign-up: heading, one sentence, an email field and a button, with an optional consent line and
  picture. Axes: layout (inline, stacked, split), terms (show, hide), tone (default, muted), align (start,
  center).
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type NewsletterFormProps = {
    id: string;
    title: string;
    text: string;
    label: string;
    submit: string;
    consent?: string;
    layout?: "inline" | "stacked" | "split";
    terms?: "show" | "hide";
    tone?: "default" | "muted";
    align?: "start" | "center";
    image?: string;
    imageAlt?: string;
    landmarkLabel?: string;
  };
</script>

<script lang="ts">
  import Button from "../compose/Button.svelte";
  import Form from "../compose/Form.svelte";
  import Group from "../compose/Group.svelte";
  import Input from "../compose/Input.svelte";
  import Label from "../compose/Label.svelte";
  import Text from "../compose/Text.svelte";
  import MediaFrame from "../components/media-frame.svelte";
  import SectionFrame from "../components/section-frame.svelte";
  import { cn, tpl } from "../utils";

  let {
    id,
    title,
    text,
    label,
    submit,
    consent,
    layout = "inline",
    terms = "hide",
    tone = "default",
    align = "center",
    image,
    imageAlt,
    landmarkLabel,
  }: NewsletterFormProps = $props();
</script>

<SectionFrame
  id={id}
  title={title}
  lead={text}
  tone={tone}
  align={align}
  layout={(((layout as string) === "split") ? "split" : "stack")}
  media={{ show: ((layout as string) === "split") }}
  landmarkLabel={landmarkLabel}
>
  <Form
    method="dialog"
    class={cn("w-full max-w-md", (((align as string) === "center") ? "mx-auto" : ""))}
    data-slot="newsletter-form"
  >
    <Label for={tpl("{0}-email", id)} class="sr-only">
      {label}
    </Label>
    <Group
      gap="2"
      align="start"
      class={cn("w-full", (((layout as string) === "stacked") ? "flex-col items-stretch" : "flex-wrap"))}
    >
      <Input type="email" name="email" class="min-w-0 flex-1" id={tpl("{0}-email", id)} data-slot="field" />
      <Button variant="default" size="default" type="submit">
        {submit}
      </Button>
    </Group>
    {#if (((terms as string) === "show") && consent)}
      <Text size="xs" class="text-muted-foreground" data-slot="consent">
        {consent}
      </Text>
    {/if}
  </Form>
  {#snippet aside()}
    <MediaFrame alt={(imageAlt ? imageAlt : title)} src={image} ratio="4/3" />
  {/snippet}
</SectionFrame>

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 newsletter-form
blocks/newsletter-form.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.
/**
 * An email sign-up: heading, one sentence, an email field and a button, with an optional consent line and
 * picture. Axes: layout (inline, stacked, split), terms (show, hide), tone (default, muted), align (start,
 * center).
 */
import { type ReactNode } from "react";
import { Button, Form, Group, Input, Label, Text } from "../compose";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { cn, tpl } from "../utils";

export type NewsletterFormProps = {
  id: string;
  title: string;
  text: string;
  label: string;
  submit: string;
  consent?: string;
  layout?: "inline" | "stacked" | "split";
  terms?: "show" | "hide";
  tone?: "default" | "muted";
  align?: "start" | "center";
  image?: string;
  imageAlt?: string;
  landmarkLabel?: string;
};

export function NewsletterForm({
  id,
  title,
  text,
  label,
  submit,
  consent,
  layout = "inline",
  terms = "hide",
  tone = "default",
  align = "center",
  image,
  imageAlt,
  landmarkLabel,
}: NewsletterFormProps) {
  return (
    <SectionFrame
      id={id}
      title={title}
      lead={text}
      tone={tone}
      align={align}
      layout={(((layout as string) === "split") ? "split" : "stack")}
      media={{ show: ((layout as string) === "split") }}
      landmarkLabel={landmarkLabel}
      aside={(
        <MediaFrame alt={(imageAlt ? imageAlt : title)} src={image} ratio="4/3" />
      )}
    >
      <Form
        method="dialog"
        className={cn("w-full max-w-md", (((align as string) === "center") ? "mx-auto" : ""))}
        data-slot="newsletter-form"
      >
        <Label htmlFor={tpl("{0}-email", id)} className="sr-only">
          {label}
        </Label>
        <Group
          gap="2"
          align="start"
          className={cn(
            "w-full",
            (((layout as string) === "stacked") ? "flex-col items-stretch" : "flex-wrap")
          )}
        >
          <Input type="email" name="email" className="min-w-0 flex-1" id={tpl("{0}-email", id)} data-slot="field" />
          <Button variant="default" size="default" type="submit">
            {submit}
          </Button>
        </Group>
        {(((terms as string) === "show") && consent) ? (
          <Text size="xs" className="text-muted-foreground" data-slot="consent">
            {consent}
          </Text>
        ) : null}
      </Form>
    </SectionFrame>
  );
}

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 newsletter-form
blocks/newsletter-form.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. -->
<!--
  An email sign-up: heading, one sentence, an email field and a button, with an optional consent line and
  picture. Axes: layout (inline, stacked, split), terms (show, hide), tone (default, muted), align (start,
  center).
-->
<script lang="ts">
export type NewsletterFormProps = {
  id: string;
  title: string;
  text: string;
  label: string;
  submit: string;
  consent?: string;
  layout?: "inline" | "stacked" | "split";
  terms?: "show" | "hide";
  tone?: "default" | "muted";
  align?: "start" | "center";
  image?: string;
  imageAlt?: string;
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Button from "../compose/Button.vue";
import Form from "../compose/Form.vue";
import Group from "../compose/Group.vue";
import Input from "../compose/Input.vue";
import Label from "../compose/Label.vue";
import Text from "../compose/Text.vue";
import MediaFrame from "../components/media-frame.vue";
import SectionFrame from "../components/section-frame.vue";
import { cn, tpl } from "../utils";

const {
  id,
  title,
  text,
  label,
  submit,
  consent,
  layout = "inline",
  terms = "hide",
  tone = "default",
  align = "center",
  image,
  imageAlt,
  landmarkLabel,
} = defineProps<NewsletterFormProps>();
</script>

<template>
  <SectionFrame
    :id="id"
    :title="title"
    :lead="text"
    :tone="tone"
    :align="align"
    :layout="(((layout as string) === 'split') ? 'split' : 'stack')"
    :media="{ show: ((layout as string) === 'split') }"
    :landmarkLabel="landmarkLabel"
  >
    <Form
      method="dialog"
      :class="cn('w-full max-w-md', (((align as string) === 'center') ? 'mx-auto' : ''))"
      data-slot="newsletter-form"
    >
      <Label :for="tpl('{0}-email', id)" class="sr-only">
        {{ label }}
      </Label>
      <Group
        gap="2"
        align="start"
        :class="cn('w-full', (((layout as string) === 'stacked') ? 'flex-col items-stretch' : 'flex-wrap'))"
      >
        <Input type="email" name="email" class="min-w-0 flex-1" :id="tpl('{0}-email', id)" data-slot="field" />
        <Button variant="default" size="default" type="submit">
          {{ submit }}
        </Button>
      </Group>
      <Text
        v-if="(((terms as string) === 'show') && consent)"
        size="xs"
        class="text-muted-foreground"
        data-slot="consent"
      >
        {{ consent }}
      </Text>
    </Form>
    <template #aside>
      <MediaFrame :alt="(imageAlt ? imageAlt : title)" :src="image" ratio="4/3" />
    </template>
  </SectionFrame>
</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 newsletter-form
blocks/newsletter-form.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.
/**
 * An email sign-up: heading, one sentence, an email field and a button, with an optional consent line and
 * picture. Axes: layout (inline, stacked, split), terms (show, hide), tone (default, muted), align (start,
 * center).
 */
import { For, type JSX } from "solid-js";
import { Button, Form, Group, Input, Label, Text } from "../compose";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { cn, tpl } from "../utils";

export type NewsletterFormProps = {
  id: string;
  title: string;
  text: string;
  label: string;
  submit: string;
  consent?: string;
  layout?: "inline" | "stacked" | "split";
  terms?: "show" | "hide";
  tone?: "default" | "muted";
  align?: "start" | "center";
  image?: string;
  imageAlt?: string;
  landmarkLabel?: string;
};

export function NewsletterForm({
  id,
  title,
  text,
  label,
  submit,
  consent,
  layout = "inline",
  terms = "hide",
  tone = "default",
  align = "center",
  image,
  imageAlt,
  landmarkLabel,
}: NewsletterFormProps) {
  return (
    <SectionFrame
      id={id}
      title={title}
      lead={text}
      tone={tone}
      align={align}
      layout={(((layout as string) === "split") ? "split" : "stack")}
      media={{ show: ((layout as string) === "split") }}
      landmarkLabel={landmarkLabel}
      aside={(
        <MediaFrame alt={(imageAlt ? imageAlt : title)} src={image} ratio="4/3" />
      )}
    >
      <Form
        method="dialog"
        class={cn("w-full max-w-md", (((align as string) === "center") ? "mx-auto" : ""))}
        data-slot="newsletter-form"
      >
        <Label for={tpl("{0}-email", id)} class="sr-only">
          {label}
        </Label>
        <Group
          gap="2"
          align="start"
          class={cn("w-full", (((layout as string) === "stacked") ? "flex-col items-stretch" : "flex-wrap"))}
        >
          <Input type="email" name="email" class="min-w-0 flex-1" id={tpl("{0}-email", id)} data-slot="field" />
          <Button variant="default" size="default" type="submit">
            {submit}
          </Button>
        </Group>
        {(((terms as string) === "show") && consent) ? (
          <Text size="xs" class="text-muted-foreground" data-slot="consent">
            {consent}
          </Text>
        ) : null}
      </Form>
    </SectionFrame>
  );
}

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

// NewsletterFormProps are the props of NewsletterForm; the values are the JSON shapes of the TypeScript props.
type NewsletterFormProps struct {
	Id any `json:"id"`
	Title any `json:"title"`
	Text any `json:"text"`
	Label any `json:"label"`
	Submit any `json:"submit"`
	Consent any `json:"consent"`
	Layout any `json:"layout"`
	Terms any `json:"terms"`
	Tone any `json:"tone"`
	Align any `json:"align"`
	Image any `json:"image"`
	ImageAlt any `json:"imageAlt"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// An email sign-up: heading, one sentence, an email field and a button, with an optional consent line and picture. Axes: layout (inline, stacked, split), terms (show, hide), tone (default, muted), align (start, center).
templ NewsletterForm(p NewsletterFormProps) {
	{{ vId := p.Id }}
	{{ vTitle := p.Title }}
	{{ vText := p.Text }}
	{{ vLabel := p.Label }}
	{{ vSubmit := p.Submit }}
	{{ vConsent := p.Consent }}
	{{ vLayout := uiutils.Def(p.Layout, "inline") }}
	{{ vTerms := uiutils.Def(p.Terms, "hide") }}
	{{ vTone := uiutils.Def(p.Tone, "default") }}
	{{ vAlign := uiutils.Def(p.Align, "center") }}
	{{ vImage := p.Image }}
	{{ vImageAlt := p.ImageAlt }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Lead: vText, Tone: vTone, Align: vAlign, Layout: uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "split")), "split", "stack"), Media: map[string]any{"show": uiutils.Eq(vLayout, "split")}, LandmarkLabel: vLandmarkLabel, Aside: newsletterFormFill1(p, vTitle, vImage, vImageAlt)}) {
		@compose.Form(compose.FormProps{FormProps: form.FormProps{Method: "dialog", Class: uiutils.S(uiutils.Cnv("w-full max-w-md", uiutils.Cond(uiutils.T(uiutils.Eq(vAlign, "center")), "mx-auto", ""))), Attrs: uiutils.Attrs("data-slot", "newsletter-form")}}) {
			@compose.Label(compose.LabelProps{LabelProps: label.LabelProps{For: uiutils.S(uiutils.Tpl("{0}-email", vId)), Class: "sr-only"}}) {
				{ uiutils.Text(vLabel) }
			}
			@compose.Group(compose.GroupProps{Gap: "2", Align: "start", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("w-full", uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "stacked")), "flex-col items-stretch", "flex-wrap")))}}) {
				@compose.Input(compose.InputProps{InputProps: input.InputProps{Type: "email", Name: "email", Class: "min-w-0 flex-1", Attrs: uiutils.Attrs("id", uiutils.Tpl("{0}-email", vId), "data-slot", "field")}})
				@compose.Button(compose.ButtonProps{Variant: "default", Size: "default", ButtonProps: button.ButtonProps{Type: "submit"}}) {
					{ uiutils.Text(vSubmit) }
				}
			}
			if uiutils.T(uiutils.And(uiutils.Eq(vTerms, "show"), vConsent)) {
				@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground", Attrs: uiutils.Attrs("data-slot", "consent")}}) {
					{ uiutils.Text(vConsent) }
				}
			}
		}
	}
}

templ newsletterFormFill1(p NewsletterFormProps, vTitle any, vImage any, vImageAlt any) {
	@MediaFrame(MediaFrameProps{Alt: uiutils.Cond(uiutils.T(vImageAlt), vImageAlt, vTitle), Src: vImage, Ratio: "4/3"})
}

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 newsletter-form
blocks/newsletter-form.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/newsletter-form.json
    An email sign-up: heading, one sentence, an email field and a button, with an optional consent line and picture. Axes: layout (inline, stacked, split), terms (show, hide), tone (default, muted), align (start, center).
    Props (p): id, title, text, label, submit, consent, layout, terms, tone, align, image, imageAlt, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_text = (p.text ?? null) -%}
{%- set v_label = (p.label ?? null) -%}
{%- set v_submit = (p.submit ?? null) -%}
{%- set v_consent = (p.consent ?? null) -%}
{%- set v_layout = (p.layout ?? 'inline') -%}
{%- set v_terms = (p.terms ?? 'hide') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_align = (p.align ?? 'center') -%}
{%- set v_image = (p.image ?? null) -%}
{%- set v_imageAlt = (p.imageAlt ?? null) -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set f_6 -%}
  {{ include('blocks/media-frame.html.twig', {'p': {'alt': (og_t(v_imageAlt) ? v_imageAlt : v_title), 'src': v_image, 'ratio': '4/3'}}, with_context = false) }}
{%- endset -%}
{%- set c_7 -%}
  {%- set c_5 -%}
    {%- set c_1 -%}
      {{ og_text(v_label) }}
    {%- endset -%}
    {{ include('compose/Label.html.twig', {'htmlFor': og_s(og_tpl('{0}-email', [v_id])), 'class': 'sr-only', 'children': c_1}, with_context = false) }}
    {%- set c_3 -%}
      {{ include('compose/Input.html.twig', {'type': 'email', 'name': 'email', 'class': 'min-w-0 flex-1', 'attrs': og_attrs(['id', og_tpl('{0}-email', [v_id]), 'data-slot', 'field'])}, with_context = false) }}
      {%- set c_2 -%}
        {{ og_text(v_submit) }}
      {%- endset -%}
      {{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'default', 'type': 'submit', 'children': c_2}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Group.html.twig', {'gap': '2', 'align': 'start', 'class': og_s(og_cnv(['w-full', (og_t(og_eq(v_layout, 'stacked')) ? 'flex-col items-stretch' : 'flex-wrap')])), 'children': c_3}, with_context = false) }}
    {%- if og_t(og_and([og_eq(v_terms, 'show'), v_consent])) %}
      {%- set c_4 -%}
        {{ og_text(v_consent) }}
      {%- endset -%}
      {{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'attrs': og_attrs(['data-slot', 'consent']), 'children': c_4}, with_context = false) }}
    {%- endif %}
  {%- endset -%}
  {{ include('compose/Form.html.twig', {'method': 'dialog', 'class': og_s(og_cnv(['w-full max-w-md', (og_t(og_eq(v_align, 'center')) ? 'mx-auto' : '')])), 'attrs': og_attrs(['data-slot', 'newsletter-form']), 'children': c_5}, with_context = false) }}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'lead': v_text, 'tone': v_tone, 'align': v_align, 'layout': (og_t(og_eq(v_layout, 'split')) ? 'split' : 'stack'), 'media': {'show': og_eq(v_layout, 'split')}, 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_6)}, 'children': og_markup(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 newsletter-form
blocks/newsletter-form.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/newsletter-form.json
    An email sign-up: heading, one sentence, an email field and a button, with an optional consent line and picture. Axes: layout (inline, stacked, split), terms (show, hide), tone (default, muted), align (start, center).
    Props (p): id, title, text, label, submit, consent, layout, terms, tone, align, image, imageAlt, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_text = ($p['text'] ?? null)}
{var $v_label = ($p['label'] ?? null)}
{var $v_submit = ($p['submit'] ?? null)}
{var $v_consent = ($p['consent'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'inline')}
{var $v_terms = ($p['terms'] ?? 'hide')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_align = ($p['align'] ?? 'center')}
{var $v_image = ($p['image'] ?? null)}
{var $v_imageAlt = ($p['imageAlt'] ?? null)}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $f_6}
  {=og_include('blocks/media-frame.latte', ['p' => ['alt' => (og_t($v_imageAlt) ? $v_imageAlt : $v_title), 'src' => $v_image, 'ratio' => '4/3']])|noescape}
{/capture}
{capture $c_7}
  {capture $c_5}
    {capture $c_1}
      {=og_text($v_label)}
    {/capture}
    {=og_include('compose/Label.latte', ['htmlFor' => og_s(og_tpl('{0}-email', [$v_id])), 'class' => 'sr-only', 'children' => (string) $c_1])|noescape}
    {capture $c_3}
      {=og_include('compose/Input.latte', ['type' => 'email', 'name' => 'email', 'class' => 'min-w-0 flex-1', 'attrs' => og_attrs(['id', og_tpl('{0}-email', [$v_id]), 'data-slot', 'field'])])|noescape}
      {capture $c_2}
        {=og_text($v_submit)}
      {/capture}
      {=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'default', 'type' => 'submit', 'children' => (string) $c_2])|noescape}
    {/capture}
    {=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'start', 'class' => og_s(og_cnv(['w-full', (og_t(og_eq($v_layout, 'stacked')) ? 'flex-col items-stretch' : 'flex-wrap')])), 'children' => (string) $c_3])|noescape}
    {if og_t(og_and([og_eq($v_terms, 'show'), $v_consent]))}
      {capture $c_4}
        {=og_text($v_consent)}
      {/capture}
      {=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'attrs' => og_attrs(['data-slot', 'consent']), 'children' => (string) $c_4])|noescape}
    {/if}
  {/capture}
  {=og_include('compose/Form.latte', ['method' => 'dialog', 'class' => og_s(og_cnv(['w-full max-w-md', (og_t(og_eq($v_align, 'center')) ? 'mx-auto' : '')])), 'attrs' => og_attrs(['data-slot', 'newsletter-form']), 'children' => (string) $c_5])|noescape}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'lead' => $v_text, 'tone' => $v_tone, 'align' => $v_align, 'layout' => (og_t(og_eq($v_layout, 'split')) ? 'split' : 'stack'), 'media' => ['show' => og_eq($v_layout, 'split')], 'landmarkLabel' => $v_landmarkLabel, 'aside' => og_markup($f_6)], 'children' => og_markup($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 newsletter-form
blocks/newsletter-form.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/newsletter-form.json
    An email sign-up: heading, one sentence, an email field and a button, with an optional consent line and picture. Axes: layout (inline, stacked, split), terms (show, hide), tone (default, muted), align (start, center).
    Props (p): id, title, text, label, submit, consent, layout, terms, tone, align, image, imageAlt, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_text = og_def(p['text'], none) -%}
{%- set v_label = og_def(p['label'], none) -%}
{%- set v_submit = og_def(p['submit'], none) -%}
{%- set v_consent = og_def(p['consent'], none) -%}
{%- set v_layout = og_def(p['layout'], 'inline') -%}
{%- set v_terms = og_def(p['terms'], 'hide') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_align = og_def(p['align'], 'center') -%}
{%- set v_image = og_def(p['image'], none) -%}
{%- set v_imageAlt = og_def(p['imageAlt'], none) -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set f_6 -%}
  {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': (v_imageAlt if og_t(v_imageAlt) else v_title), 'src': v_image, 'ratio': '4/3'}}) }}
{%- endset -%}
{%- set c_7 -%}
  {%- set c_5 -%}
    {%- set c_1 -%}
      {{ og_text(v_label) }}
    {%- endset -%}
    {{ og_include('compose/label.html.j2', {'p': {'For': og_s(og_tpl('{0}-email', [v_id])), 'Class': 'sr-only'}, 'children': c_1}) }}
    {%- set c_3 -%}
      {{ og_include('compose/input.html.j2', {'p': {'Type': 'email', 'Name': 'email', 'Class': 'min-w-0 flex-1', 'Attrs': og_attrs(['id', og_tpl('{0}-email', [v_id]), 'data-slot', 'field'])}}) }}
      {%- set c_2 -%}
        {{ og_text(v_submit) }}
      {%- endset -%}
      {{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'default', 'Type': 'submit'}, 'children': c_2}) }}
    {%- endset -%}
    {{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'start', 'Class': og_s(og_cnv(['w-full', ('flex-col items-stretch' if og_t(og_eq(v_layout, 'stacked')) else 'flex-wrap')]))}, 'children': c_3}) }}
    {%- if og_t(og_and([og_eq(v_terms, 'show'), v_consent])) %}
      {%- set c_4 -%}
        {{ og_text(v_consent) }}
      {%- endset -%}
      {{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground', 'Attrs': og_attrs(['data-slot', 'consent'])}, 'children': c_4}) }}
    {%- endif %}
  {%- endset -%}
  {{ og_include('compose/form.html.j2', {'p': {'Method': 'dialog', 'Class': og_s(og_cnv(['w-full max-w-md', ('mx-auto' if og_t(og_eq(v_align, 'center')) else '')])), 'Attrs': og_attrs(['data-slot', 'newsletter-form'])}, 'children': c_5}) }}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'lead': v_text, 'tone': v_tone, 'align': v_align, 'layout': ('split' if og_t(og_eq(v_layout, 'split')) else 'stack'), 'media': {'show': og_eq(v_layout, 'split')}, 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_6)}, 'children': og_markup(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.

An email sign-up: heading, one sentence, an email field and a button, with an optional consent line and picture. Axes: layout (inline, stacked, split), terms (show, hide), tone (default, muted), align (start, center).

Props of NewsletterForm
PropTypeDefault Description
id (required)string-
title (required)string-
text (required)string-
label (required)string-accessible name of the email field
submit (required)string-
consent string-the consent line, shown when `terms` is show
layout "inline" | "stacked" | "split""inline"
terms "show" | "hide""hide"
tone "default" | "muted""default"
align "start" | "center""center"
image string-address of the picture (an https URL or a path); none: the placeholder
imageAlt string-alt text of the picture; none: the title
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