Skip to content
ui8kit

component / components

Section Header

Section Header component

Install

npx ui8kit add section-header

Pulls in: badge, compose, group, kit-box, kit-link, kit-text, link, presets, section-frame, text, title, utils

Preview

Available for projects

Hi, I design calm software

Nine years of product design for teams that ship every week. I like systems, plain words and short feedback loops.

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 section-header
components/section-header.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 head of a section: an optional badge, the heading (h1 or h2) with an optional link opposite it, and an
  optional lead. No wrapper: its parts are children of the section stack.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { SectionHeading, HeadLink } from "./section-frame.types";

  export type SectionHeaderProps = {
    titleId: string;
    title?: string;
    heading?: SectionHeading;
    action?: HeadLink;
    lead?: string;
    center?: boolean;
  };
</script>

<script lang="ts">
  import Badge from "../compose/Badge.svelte";
  import Group from "../compose/Group.svelte";
  import Link from "../compose/Link.svelte";
  import Text from "../compose/Text.svelte";
  import Title from "../compose/Title.svelte";
  import { defaults } from "../presets/defaults";
  import { cn, urlOf } from "../utils";

  let { titleId, title = "", heading, action, lead, center = false }: SectionHeaderProps = $props();
  const level = $derived(heading?.level ?? 2);
  const scale = $derived(heading?.scale ?? "default");
  const hasAction = $derived(action?.label && action?.href);
</script>

{#if heading?.badge}
  <Badge variant="outline" size="lg" class={(center ? "mx-auto w-fit" : "w-fit")}>
    {heading?.badge}
  </Badge>
{/if}
{#if (((title as string) !== "") && hasAction)}
  <Group gap="4" align="center" justify="between" class="w-full flex-wrap" data-slot="section-header">
    <Title
      as={level}
      size={((level === 1) ? "5xl" : "xl")}
      weight="semibold"
      class={
        (scale as string) === "display" ? "text-6xl tracking-tight md:text-8xl"
        : level === 1 ? "leading-tight"
        : "leading-7"
      }
      id={titleId}
    >
      {title}
    </Title>
    <Link
      href={urlOf(action?.href)}
      variant="default"
      class={cn(defaults.text.tiny, "shrink-0 font-medium leading-5")}
      data-slot="section-action"
    >
      {action?.label}
    </Link>
  </Group>
{/if}
{#if (((title as string) !== "") && !hasAction)}
  <Title
    as={level}
    size={((level === 1) ? "5xl" : "xl")}
    weight="semibold"
    class={
      (scale as string) === "display" ? "text-6xl tracking-tight md:text-8xl"
      : level === 1 ? "leading-tight"
      : "leading-7"
    }
    id={titleId}
    data-slot="section-header"
  >
    {title}
  </Title>
{/if}
{#if (((title as string) === "") && hasAction)}
  <Group gap="4" align="center" justify="end" class="w-full" data-slot="section-header">
    <Link
      href={urlOf(action?.href)}
      variant="default"
      class={cn(defaults.text.tiny, "shrink-0 font-medium leading-5")}
      data-slot="section-action"
    >
      {action?.label}
    </Link>
  </Group>
{/if}
{#if lead}
  <Text
    size="base"
    class={cn("max-w-2xl text-muted-foreground", (center ? "mx-auto" : ""))}
    data-slot="section-header"
  >
    {lead}
  </Text>
{/if}

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 section-header
components/section-header.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 head of a section: an optional badge, the heading (h1 or h2) with an optional link opposite it, and an
 * optional lead. No wrapper: its parts are children of the section stack.
 */
import { type ReactNode } from "react";
import { Badge, Group, Link, Text, Title } from "../compose";
import { defaults } from "../presets/defaults";
import { cn, urlOf } from "../utils";
import type { SectionHeading, HeadLink } from "./section-frame.types";

export type SectionHeaderProps = {
  titleId: string;
  title?: string;
  heading?: SectionHeading;
  action?: HeadLink;
  lead?: string;
  center?: boolean;
};

export function SectionHeader({
  titleId,
  title = "",
  heading,
  action,
  lead,
  center = false,
}: SectionHeaderProps) {
  const level = heading?.level ?? 2;
  const scale = heading?.scale ?? "default";
  const hasAction = action?.label && action?.href;
  return (
    <>
      {heading?.badge ? (
        <Badge variant="outline" size="lg" className={(center ? "mx-auto w-fit" : "w-fit")}>
          {heading?.badge}
        </Badge>
      ) : null}
      {(((title as string) !== "") && hasAction) ? (
        <Group gap="4" align="center" justify="between" className="w-full flex-wrap" data-slot="section-header">
          <Title
            as={level}
            size={((level === 1) ? "5xl" : "xl")}
            weight="semibold"
            className={
              (scale as string) === "display" ? "text-6xl tracking-tight md:text-8xl"
              : level === 1 ? "leading-tight"
              : "leading-7"
            }
            id={titleId}
          >
            {title}
          </Title>
          <Link
            href={urlOf(action?.href)}
            variant="default"
            className={cn(defaults.text.tiny, "shrink-0 font-medium leading-5")}
            data-slot="section-action"
          >
            {action?.label}
          </Link>
        </Group>
      ) : null}
      {(((title as string) !== "") && !hasAction) ? (
        <Title
          as={level}
          size={((level === 1) ? "5xl" : "xl")}
          weight="semibold"
          className={
            (scale as string) === "display" ? "text-6xl tracking-tight md:text-8xl"
            : level === 1 ? "leading-tight"
            : "leading-7"
          }
          id={titleId}
          data-slot="section-header"
        >
          {title}
        </Title>
      ) : null}
      {(((title as string) === "") && hasAction) ? (
        <Group gap="4" align="center" justify="end" className="w-full" data-slot="section-header">
          <Link
            href={urlOf(action?.href)}
            variant="default"
            className={cn(defaults.text.tiny, "shrink-0 font-medium leading-5")}
            data-slot="section-action"
          >
            {action?.label}
          </Link>
        </Group>
      ) : null}
      {lead ? (
        <Text
          size="base"
          className={cn("max-w-2xl text-muted-foreground", (center ? "mx-auto" : ""))}
          data-slot="section-header"
        >
          {lead}
        </Text>
      ) : null}
    </>
  );
}

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 section-header
components/section-header.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 head of a section: an optional badge, the heading (h1 or h2) with an optional link opposite it, and an
  optional lead. No wrapper: its parts are children of the section stack.
-->
<script lang="ts">
import type { SectionHeading, HeadLink } from "./section-frame.types";

export type SectionHeaderProps = {
  titleId: string;
  title?: string;
  heading?: SectionHeading;
  action?: HeadLink;
  lead?: string;
  center?: boolean;
};
</script>

<script setup lang="ts">
import { computed } from "vue";
import Badge from "../compose/Badge.vue";
import Group from "../compose/Group.vue";
import Link from "../compose/Link.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
import { defaults } from "../presets/defaults";
import { cn, urlOf } from "../utils";

const { titleId, title = "", heading, action, lead, center = false } = defineProps<SectionHeaderProps>();
const level = computed(() => heading?.level ?? 2);
const scale = computed(() => heading?.scale ?? "default");
const hasAction = computed(() => action?.label && action?.href);
</script>

<template>
  <Badge v-if="heading?.badge" variant="outline" size="lg" :class="(center ? 'mx-auto w-fit' : 'w-fit')">
    {{ heading?.badge }}
  </Badge>
  <Group
    v-if="(((title as string) !== '') && hasAction)"
    gap="4"
    align="center"
    justify="between"
    class="w-full flex-wrap"
    data-slot="section-header"
  >
    <Title
      :as="level"
      :size="((level === 1) ? '5xl' : 'xl')"
      weight="semibold"
      :class="
        (scale as string) === 'display' ? 'text-6xl tracking-tight md:text-8xl'
        : level === 1 ? 'leading-tight'
        : 'leading-7'
      "
      :id="titleId"
    >
      {{ title }}
    </Title>
    <Link
      :href="urlOf(action?.href)"
      variant="default"
      :class="cn(defaults.text.tiny, 'shrink-0 font-medium leading-5')"
      data-slot="section-action"
    >
      {{ action?.label }}
    </Link>
  </Group>
  <Title v-if="(((title as string) !== '') && !hasAction)"
    :as="level"
    :size="((level === 1) ? '5xl' : 'xl')"
    weight="semibold"
    :class="
      (scale as string) === 'display' ? 'text-6xl tracking-tight md:text-8xl'
      : level === 1 ? 'leading-tight'
      : 'leading-7'
    "
    :id="titleId"
    data-slot="section-header"
  >
    {{ title }}
  </Title>
  <Group
    v-if="(((title as string) === '') && hasAction)"
    gap="4"
    align="center"
    justify="end"
    class="w-full"
    data-slot="section-header"
  >
    <Link
      :href="urlOf(action?.href)"
      variant="default"
      :class="cn(defaults.text.tiny, 'shrink-0 font-medium leading-5')"
      data-slot="section-action"
    >
      {{ action?.label }}
    </Link>
  </Group>
  <Text v-if="lead"
    size="base"
    :class="cn('max-w-2xl text-muted-foreground', (center ? 'mx-auto' : ''))"
    data-slot="section-header"
  >
    {{ lead }}
  </Text>
</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 section-header
components/section-header.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 head of a section: an optional badge, the heading (h1 or h2) with an optional link opposite it, and an
 * optional lead. No wrapper: its parts are children of the section stack.
 */
import { type JSX } from "solid-js";
import { Badge, Group, Link, Text, Title } from "../compose";
import { defaults } from "../presets/defaults";
import { cn, urlOf } from "../utils";
import type { SectionHeading, HeadLink } from "./section-frame.types";

export type SectionHeaderProps = {
  titleId: string;
  title?: string;
  heading?: SectionHeading;
  action?: HeadLink;
  lead?: string;
  center?: boolean;
};

export function SectionHeader({
  titleId,
  title = "",
  heading,
  action,
  lead,
  center = false,
}: SectionHeaderProps) {
  const level = heading?.level ?? 2;
  const scale = heading?.scale ?? "default";
  const hasAction = action?.label && action?.href;
  return (
    <>
      {heading?.badge ? (
        <Badge variant="outline" size="lg" class={(center ? "mx-auto w-fit" : "w-fit")}>
          {heading?.badge}
        </Badge>
      ) : null}
      {(((title as string) !== "") && hasAction) ? (
        <Group gap="4" align="center" justify="between" class="w-full flex-wrap" data-slot="section-header">
          <Title
            as={level}
            size={((level === 1) ? "5xl" : "xl")}
            weight="semibold"
            class={
              (scale as string) === "display" ? "text-6xl tracking-tight md:text-8xl"
              : level === 1 ? "leading-tight"
              : "leading-7"
            }
            id={titleId}
          >
            {title}
          </Title>
          <Link
            href={urlOf(action?.href)}
            variant="default"
            class={cn(defaults.text.tiny, "shrink-0 font-medium leading-5")}
            data-slot="section-action"
          >
            {action?.label}
          </Link>
        </Group>
      ) : null}
      {(((title as string) !== "") && !hasAction) ? (
        <Title
          as={level}
          size={((level === 1) ? "5xl" : "xl")}
          weight="semibold"
          class={
            (scale as string) === "display" ? "text-6xl tracking-tight md:text-8xl"
            : level === 1 ? "leading-tight"
            : "leading-7"
          }
          id={titleId}
          data-slot="section-header"
        >
          {title}
        </Title>
      ) : null}
      {(((title as string) === "") && hasAction) ? (
        <Group gap="4" align="center" justify="end" class="w-full" data-slot="section-header">
          <Link
            href={urlOf(action?.href)}
            variant="default"
            class={cn(defaults.text.tiny, "shrink-0 font-medium leading-5")}
            data-slot="section-action"
          >
            {action?.label}
          </Link>
        </Group>
      ) : null}
      {lead ? (
        <Text
          size="base"
          class={cn("max-w-2xl text-muted-foreground", (center ? "mx-auto" : ""))}
          data-slot="section-header"
        >
          {lead}
        </Text>
      ) : null}
    </>
  );
}

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 section-header
blocks/section-header.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/patterns/section-header.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/link"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// SectionHeaderProps are the props of SectionHeader; the values are the JSON shapes of the TypeScript props.
type SectionHeaderProps struct {
	TitleId any `json:"titleId"`
	Title any `json:"title"`
	Heading any `json:"heading"`
	Action any `json:"action"`
	Lead any `json:"lead"`
	Center any `json:"center"`
}

// The head of a section: an optional badge, the heading (h1 or h2) with an optional link opposite it, and an optional lead. No wrapper: its parts are children of the section stack.
templ SectionHeader(p SectionHeaderProps) {
	{{ vTitleId := p.TitleId }}
	{{ vTitle := uiutils.Def(p.Title, "") }}
	{{ vHeading := p.Heading }}
	{{ vAction := p.Action }}
	{{ vLead := p.Lead }}
	{{ vCenter := uiutils.Def(p.Center, false) }}
	{{ vLevel := any(uiutils.Coalesce(uiutils.Get(vHeading, "level"), float64(2))) }}
	{{ vScale := any(uiutils.Coalesce(uiutils.Get(vHeading, "scale"), "default")) }}
	{{ vHasAction := any(uiutils.And(uiutils.Get(vAction, "label"), uiutils.Get(vAction, "href"))) }}
	if uiutils.T(uiutils.Get(vHeading, "badge")) {
		@compose.Badge(compose.BadgeProps{Variant: "outline", Size: "lg", TextProps: text.TextProps{Class: uiutils.S(uiutils.Cond(uiutils.T(vCenter), "mx-auto w-fit", "w-fit"))}}) {
			{ uiutils.Text(uiutils.Get(vHeading, "badge")) }
		}
	}
	if uiutils.T(uiutils.And(!uiutils.Eq(vTitle, ""), vHasAction)) {
		@compose.Group(compose.GroupProps{Gap: "4", Align: "center", Justify: "between", BoxProps: box.BoxProps{Class: "w-full flex-wrap", Attrs: uiutils.Attrs("data-slot", "section-header")}}) {
			@compose.Title(compose.TitleProps{As: uiutils.S(vLevel), Size: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vLevel, float64(1))), "5xl", "xl")), Weight: "semibold", TextProps: text.TextProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vScale, "display")), "text-6xl tracking-tight md:text-8xl", uiutils.Cond(uiutils.T(uiutils.Eq(vLevel, float64(1))), "leading-tight", "leading-7"))), Attrs: uiutils.Attrs("id", vTitleId)}}) {
				{ uiutils.Text(vTitle) }
			}
			@compose.Link(compose.LinkProps{Variant: "default", LinkProps: link.LinkProps{Href: uiutils.URL(uiutils.Get(vAction, "href"), false), Class: uiutils.S(uiutils.Cnv(uiutils.Get(presetDefaults, "text", "tiny"), "shrink-0 font-medium leading-5")), Attrs: uiutils.Attrs("data-slot", "section-action")}}) {
				{ uiutils.Text(uiutils.Get(vAction, "label")) }
			}
		}
	}
	if uiutils.T(uiutils.And(!uiutils.Eq(vTitle, ""), !uiutils.T(vHasAction))) {
		@compose.Title(compose.TitleProps{As: uiutils.S(vLevel), Size: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vLevel, float64(1))), "5xl", "xl")), Weight: "semibold", TextProps: text.TextProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vScale, "display")), "text-6xl tracking-tight md:text-8xl", uiutils.Cond(uiutils.T(uiutils.Eq(vLevel, float64(1))), "leading-tight", "leading-7"))), Attrs: uiutils.Attrs("id", vTitleId, "data-slot", "section-header")}}) {
			{ uiutils.Text(vTitle) }
		}
	}
	if uiutils.T(uiutils.And(uiutils.Eq(vTitle, ""), vHasAction)) {
		@compose.Group(compose.GroupProps{Gap: "4", Align: "center", Justify: "end", BoxProps: box.BoxProps{Class: "w-full", Attrs: uiutils.Attrs("data-slot", "section-header")}}) {
			@compose.Link(compose.LinkProps{Variant: "default", LinkProps: link.LinkProps{Href: uiutils.URL(uiutils.Get(vAction, "href"), false), Class: uiutils.S(uiutils.Cnv(uiutils.Get(presetDefaults, "text", "tiny"), "shrink-0 font-medium leading-5")), Attrs: uiutils.Attrs("data-slot", "section-action")}}) {
				{ uiutils.Text(uiutils.Get(vAction, "label")) }
			}
		}
	}
	if uiutils.T(vLead) {
		@compose.Text(compose.TextProps{Size: "base", TextProps: text.TextProps{Class: uiutils.S(uiutils.Cnv("max-w-2xl text-muted-foreground", uiutils.Cond(uiutils.T(vCenter), "mx-auto", ""))), Attrs: uiutils.Attrs("data-slot", "section-header")}}) {
			{ uiutils.Text(vLead) }
		}
	}
}

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 section-header
blocks/section-header.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/patterns/section-header.json
    The head of a section: an optional badge, the heading (h1 or h2) with an optional link opposite it, and an optional lead. No wrapper: its parts are children of the section stack.
    Props (p): titleId, title, heading, action, lead, center. -#}
{%- set v_titleId = (p.titleId ?? null) -%}
{%- set v_title = (p.title ?? '') -%}
{%- set v_heading = (p.heading ?? null) -%}
{%- set v_action = (p.action ?? null) -%}
{%- set v_lead = (p.lead ?? null) -%}
{%- set v_center = (p.center ?? false) -%}
{%- set v_level = og_coalesce([og_get(v_heading, ['level']), 2]) -%}
{%- set v_scale = og_coalesce([og_get(v_heading, ['scale']), 'default']) -%}
{%- set v_hasAction = og_and([og_get(v_action, ['label']), og_get(v_action, ['href'])]) -%}
{%- if og_t(og_get(v_heading, ['badge'])) %}
  {%- set c_1 -%}
    {{ og_text(og_get(v_heading, ['badge'])) }}
  {%- endset -%}
  {{ include('compose/Badge.html.twig', {'variant': 'outline', 'size': 'lg', 'class': og_s((og_t(v_center) ? 'mx-auto w-fit' : 'w-fit')), 'children': c_1}, with_context = false) }}
{%- endif %}
{%- if og_t(og_and([not (og_eq(v_title, '')), v_hasAction])) %}
  {%- set c_4 -%}
    {%- set c_2 -%}
      {{ og_text(v_title) }}
    {%- endset -%}
    {{ include('compose/Title.html.twig', {'as': og_i(v_level), 'size': og_s((og_t(og_eq(v_level, 1)) ? '5xl' : 'xl')), 'weight': 'semibold', 'class': og_s((og_t(og_eq(v_scale, 'display')) ? 'text-6xl tracking-tight md:text-8xl' : (og_t(og_eq(v_level, 1)) ? 'leading-tight' : 'leading-7'))), 'attrs': og_attrs(['id', v_titleId]), 'children': c_2}, with_context = false) }}
    {%- set c_3 -%}
      {{ og_text(og_get(v_action, ['label'])) }}
    {%- endset -%}
    {{ include('compose/Link.html.twig', {'href': og_url(og_s(og_get(v_action, ['href']))), 'variant': 'default', 'class': og_s(og_cnv([og_preset('blocks/presets/defaults.json', ['text', 'tiny']), 'shrink-0 font-medium leading-5'])), 'attrs': og_attrs(['data-slot', 'section-action']), 'children': c_3}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'justify': 'between', 'class': 'w-full flex-wrap', 'attrs': og_attrs(['data-slot', 'section-header']), 'children': c_4}, with_context = false) }}
{%- endif %}
{%- if og_t(og_and([not (og_eq(v_title, '')), not (og_t(v_hasAction))])) %}
  {%- set c_5 -%}
    {{ og_text(v_title) }}
  {%- endset -%}
  {{ include('compose/Title.html.twig', {'as': og_i(v_level), 'size': og_s((og_t(og_eq(v_level, 1)) ? '5xl' : 'xl')), 'weight': 'semibold', 'class': og_s((og_t(og_eq(v_scale, 'display')) ? 'text-6xl tracking-tight md:text-8xl' : (og_t(og_eq(v_level, 1)) ? 'leading-tight' : 'leading-7'))), 'attrs': og_attrs(['id', v_titleId, 'data-slot', 'section-header']), 'children': c_5}, with_context = false) }}
{%- endif %}
{%- if og_t(og_and([og_eq(v_title, ''), v_hasAction])) %}
  {%- set c_7 -%}
    {%- set c_6 -%}
      {{ og_text(og_get(v_action, ['label'])) }}
    {%- endset -%}
    {{ include('compose/Link.html.twig', {'href': og_url(og_s(og_get(v_action, ['href']))), 'variant': 'default', 'class': og_s(og_cnv([og_preset('blocks/presets/defaults.json', ['text', 'tiny']), 'shrink-0 font-medium leading-5'])), 'attrs': og_attrs(['data-slot', 'section-action']), 'children': c_6}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'justify': 'end', 'class': 'w-full', 'attrs': og_attrs(['data-slot', 'section-header']), 'children': c_7}, with_context = false) }}
{%- endif %}
{%- if og_t(v_lead) %}
  {%- set c_8 -%}
    {{ og_text(v_lead) }}
  {%- endset -%}
  {{ include('compose/Text.html.twig', {'size': 'base', 'class': og_s(og_cnv(['max-w-2xl text-muted-foreground', (og_t(v_center) ? 'mx-auto' : '')])), 'attrs': og_attrs(['data-slot', 'section-header']), 'children': c_8}, with_context = false) }}
{%- endif %}

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 section-header
blocks/section-header.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/patterns/section-header.json
    The head of a section: an optional badge, the heading (h1 or h2) with an optional link opposite it, and an optional lead. No wrapper: its parts are children of the section stack.
    Props (p): titleId, title, heading, action, lead, center. *}
{var $v_titleId = ($p['titleId'] ?? null)}
{var $v_title = ($p['title'] ?? '')}
{var $v_heading = ($p['heading'] ?? null)}
{var $v_action = ($p['action'] ?? null)}
{var $v_lead = ($p['lead'] ?? null)}
{var $v_center = ($p['center'] ?? false)}
{var $v_level = og_coalesce([og_get($v_heading, ['level']), 2])}
{var $v_scale = og_coalesce([og_get($v_heading, ['scale']), 'default'])}
{var $v_hasAction = og_and([og_get($v_action, ['label']), og_get($v_action, ['href'])])}
{if og_t(og_get($v_heading, ['badge']))}
  {capture $c_1}
    {=og_text(og_get($v_heading, ['badge']))}
  {/capture}
  {=og_include('compose/Badge.latte', ['variant' => 'outline', 'size' => 'lg', 'class' => og_s((og_t($v_center) ? 'mx-auto w-fit' : 'w-fit')), 'children' => (string) $c_1])|noescape}
{/if}
{if og_t(og_and([!(og_eq($v_title, '')), $v_hasAction]))}
  {capture $c_4}
    {capture $c_2}
      {=og_text($v_title)}
    {/capture}
    {=og_include('compose/Title.latte', ['as' => og_i($v_level), 'size' => og_s((og_t(og_eq($v_level, 1)) ? '5xl' : 'xl')), 'weight' => 'semibold', 'class' => og_s((og_t(og_eq($v_scale, 'display')) ? 'text-6xl tracking-tight md:text-8xl' : (og_t(og_eq($v_level, 1)) ? 'leading-tight' : 'leading-7'))), 'attrs' => og_attrs(['id', $v_titleId]), 'children' => (string) $c_2])|noescape}
    {capture $c_3}
      {=og_text(og_get($v_action, ['label']))}
    {/capture}
    {=og_include('compose/Link.latte', ['href' => og_url(og_s(og_get($v_action, ['href']))), 'variant' => 'default', 'class' => og_s(og_cnv([og_preset('blocks/presets/defaults.json', ['text', 'tiny']), 'shrink-0 font-medium leading-5'])), 'attrs' => og_attrs(['data-slot', 'section-action']), 'children' => (string) $c_3])|noescape}
  {/capture}
  {=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'justify' => 'between', 'class' => 'w-full flex-wrap', 'attrs' => og_attrs(['data-slot', 'section-header']), 'children' => (string) $c_4])|noescape}
{/if}
{if og_t(og_and([!(og_eq($v_title, '')), !(og_t($v_hasAction))]))}
  {capture $c_5}
    {=og_text($v_title)}
  {/capture}
  {=og_include('compose/Title.latte', ['as' => og_i($v_level), 'size' => og_s((og_t(og_eq($v_level, 1)) ? '5xl' : 'xl')), 'weight' => 'semibold', 'class' => og_s((og_t(og_eq($v_scale, 'display')) ? 'text-6xl tracking-tight md:text-8xl' : (og_t(og_eq($v_level, 1)) ? 'leading-tight' : 'leading-7'))), 'attrs' => og_attrs(['id', $v_titleId, 'data-slot', 'section-header']), 'children' => (string) $c_5])|noescape}
{/if}
{if og_t(og_and([og_eq($v_title, ''), $v_hasAction]))}
  {capture $c_7}
    {capture $c_6}
      {=og_text(og_get($v_action, ['label']))}
    {/capture}
    {=og_include('compose/Link.latte', ['href' => og_url(og_s(og_get($v_action, ['href']))), 'variant' => 'default', 'class' => og_s(og_cnv([og_preset('blocks/presets/defaults.json', ['text', 'tiny']), 'shrink-0 font-medium leading-5'])), 'attrs' => og_attrs(['data-slot', 'section-action']), 'children' => (string) $c_6])|noescape}
  {/capture}
  {=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'justify' => 'end', 'class' => 'w-full', 'attrs' => og_attrs(['data-slot', 'section-header']), 'children' => (string) $c_7])|noescape}
{/if}
{if og_t($v_lead)}
  {capture $c_8}
    {=og_text($v_lead)}
  {/capture}
  {=og_include('compose/Text.latte', ['size' => 'base', 'class' => og_s(og_cnv(['max-w-2xl text-muted-foreground', (og_t($v_center) ? 'mx-auto' : '')])), 'attrs' => og_attrs(['data-slot', 'section-header']), 'children' => (string) $c_8])|noescape}
{/if}

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 section-header
blocks/section-header.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/patterns/section-header.json
    The head of a section: an optional badge, the heading (h1 or h2) with an optional link opposite it, and an optional lead. No wrapper: its parts are children of the section stack.
    Props (p): titleId, title, heading, action, lead, center. -#}
{%- set v_titleId = og_def(p['titleId'], none) -%}
{%- set v_title = og_def(p['title'], '') -%}
{%- set v_heading = og_def(p['heading'], none) -%}
{%- set v_action = og_def(p['action'], none) -%}
{%- set v_lead = og_def(p['lead'], none) -%}
{%- set v_center = og_def(p['center'], false) -%}
{%- set v_level = og_coalesce([og_get(v_heading, ['level']), 2]) -%}
{%- set v_scale = og_coalesce([og_get(v_heading, ['scale']), 'default']) -%}
{%- set v_hasAction = og_and([og_get(v_action, ['label']), og_get(v_action, ['href'])]) -%}
{%- if og_t(og_get(v_heading, ['badge'])) %}
  {%- set c_1 -%}
    {{ og_text(og_get(v_heading, ['badge'])) }}
  {%- endset -%}
  {{ og_include('compose/badge.html.j2', {'p': {'Variant': 'outline', 'Size': 'lg', 'Class': og_s(('mx-auto w-fit' if og_t(v_center) else 'w-fit'))}, 'children': c_1}) }}
{%- endif %}
{%- if og_t(og_and([not (og_eq(v_title, '')), v_hasAction])) %}
  {%- set c_4 -%}
    {%- set c_2 -%}
      {{ og_text(v_title) }}
    {%- endset -%}
    {{ og_include('compose/title.html.j2', {'p': {'As': og_i(v_level), 'Size': og_s(('5xl' if og_t(og_eq(v_level, 1)) else 'xl')), 'Weight': 'semibold', 'Class': og_s(('text-6xl tracking-tight md:text-8xl' if og_t(og_eq(v_scale, 'display')) else ('leading-tight' if og_t(og_eq(v_level, 1)) else 'leading-7'))), 'Attrs': og_attrs(['id', v_titleId])}, 'children': c_2}) }}
    {%- set c_3 -%}
      {{ og_text(og_get(v_action, ['label'])) }}
    {%- endset -%}
    {{ og_include('compose/link.html.j2', {'p': {'Href': og_url(og_s(og_get(v_action, ['href']))), 'Variant': 'default', 'Class': og_s(og_cnv([og_preset('blocks/presets/defaults.json', ['text', 'tiny']), 'shrink-0 font-medium leading-5'])), 'Attrs': og_attrs(['data-slot', 'section-action'])}, 'children': c_3}) }}
  {%- endset -%}
  {{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Justify': 'between', 'Class': 'w-full flex-wrap', 'Attrs': og_attrs(['data-slot', 'section-header'])}, 'children': c_4}) }}
{%- endif %}
{%- if og_t(og_and([not (og_eq(v_title, '')), not (og_t(v_hasAction))])) %}
  {%- set c_5 -%}
    {{ og_text(v_title) }}
  {%- endset -%}
  {{ og_include('compose/title.html.j2', {'p': {'As': og_i(v_level), 'Size': og_s(('5xl' if og_t(og_eq(v_level, 1)) else 'xl')), 'Weight': 'semibold', 'Class': og_s(('text-6xl tracking-tight md:text-8xl' if og_t(og_eq(v_scale, 'display')) else ('leading-tight' if og_t(og_eq(v_level, 1)) else 'leading-7'))), 'Attrs': og_attrs(['id', v_titleId, 'data-slot', 'section-header'])}, 'children': c_5}) }}
{%- endif %}
{%- if og_t(og_and([og_eq(v_title, ''), v_hasAction])) %}
  {%- set c_7 -%}
    {%- set c_6 -%}
      {{ og_text(og_get(v_action, ['label'])) }}
    {%- endset -%}
    {{ og_include('compose/link.html.j2', {'p': {'Href': og_url(og_s(og_get(v_action, ['href']))), 'Variant': 'default', 'Class': og_s(og_cnv([og_preset('blocks/presets/defaults.json', ['text', 'tiny']), 'shrink-0 font-medium leading-5'])), 'Attrs': og_attrs(['data-slot', 'section-action'])}, 'children': c_6}) }}
  {%- endset -%}
  {{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Justify': 'end', 'Class': 'w-full', 'Attrs': og_attrs(['data-slot', 'section-header'])}, 'children': c_7}) }}
{%- endif %}
{%- if og_t(v_lead) %}
  {%- set c_8 -%}
    {{ og_text(v_lead) }}
  {%- endset -%}
  {{ og_include('compose/text.html.j2', {'p': {'Size': 'base', 'Class': og_s(og_cnv(['max-w-2xl text-muted-foreground', ('mx-auto' if og_t(v_center) else '')])), 'Attrs': og_attrs(['data-slot', 'section-header'])}, 'children': c_8}) }}
{%- endif %}

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 head of a section: an optional badge, the heading (h1 or h2) with an optional link opposite it, and an optional lead. No wrapper: its parts are children of the section stack.

Props of SectionHeader
PropTypeDefault Description
titleId (required)string-id of the heading (the section is labelled by it)
title string""heading; empty string: no heading
heading SectionHeading-how the heading is drawn: its level (2), its scale, a badge above it
action HeadLink-optional link opposite the heading (View all)
lead string-text under the heading
center booleanfalsecentered text

Used in