Skip to content
ui8kit

block / marketing

Site Header

Skip link, brand, navigation, theme button and an optional call to action.

Install

npx ui8kit add site-header

Pulls in: block, button, compose, container, group, kit-box, kit-button, kit-link, link-plain, menu-entry, nav-block, utils

Preview

Skip to main content
Northwind

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 site-header
blocks/site-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 page header: a skip link to the main content, the brand, the two navigation links (the current one carries
  aria-current) and the theme button. `current` is the route area. Axes: layout (inline, stacked), position
  (static, sticky), actions (none, cta).
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { SiteHeaderLabels, SiteRoutes } from "./site-header.types";

  export type SiteHeaderProps = {
    labels: SiteHeaderLabels;
    routes?: SiteRoutes;
    current: string;
    layout?: "inline" | "stacked";
    position?: "static" | "sticky";
    actions?: "none" | "cta";
    cta?: string;
    ctaHref?: string;
    landmarkLabel?: string;
    ontheme?: () => void;
  };
</script>

<script lang="ts">
  import Block from "../compose/Block.svelte";
  import Button from "../compose/Button.svelte";
  import Container from "../compose/Container.svelte";
  import Group from "../compose/Group.svelte";
  import LinkPlain from "../compose/LinkPlain.svelte";
  import MenuEntry from "../components/menu-entry.svelte";
  import NavBlock from "../components/nav-block.svelte";
  import { cn, tpl, uniqLabel, urlOf } from "../utils";

  let {
    labels,
    routes,
    current,
    layout = "inline",
    position = "static",
    actions = "none",
    cta,
    ctaHref,
    landmarkLabel,
    ontheme,
  }: SiteHeaderProps = $props();
</script>

<Block
  tag="header"
  class={cn(
    "border-b border-border bg-background",
    (((position as string) === "sticky") ? "sticky top-0 z-40" : "")
  )}
  data-layout={layout}
  aria-label={landmarkLabel}
  data-slot="site-header"
>
  <LinkPlain
    href="#main-content"
    class={"sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-50 focus:rounded focus:bg-background " +
      "focus:px-4 focus:py-2 focus:text-sm focus:inset-ring focus:inset-ring-border"}
    data-slot="skip-link"
  >
    {labels.skip}
  </LinkPlain>
  <Container
    class={cn(
      "mx-auto w-full max-w-6xl px-4",
      "flex flex-wrap gap-4 py-4",
      (((layout as string) === "stacked") ? "flex-col items-center" : "items-center justify-between")
    )}
    data-slot="container"
  >
    <MenuEntry href={routes?.home} class="text-lg font-medium" testid="brand">
      {labels.brand}
    </MenuEntry>
    <NavBlock
      label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", labels.nav, landmarkLabel)) : labels.nav)}
      testid="site-nav"
    >
      <Group gap="4" align="center">
        <MenuEntry
          href={routes?.home}
          class="font-semibold"
          current={((current as string) === "home")}
          testid="nav-link"
        >
          {labels.home}
        </MenuEntry>
        <MenuEntry
          href={routes?.pricing}
          class="font-semibold"
          current={((current as string) === "pricing")}
          testid="nav-link"
        >
          {labels.pricing}
        </MenuEntry>
      </Group>
    </NavBlock>
    <Group gap="4" align="center">
      <Button variant="outline" size="sm" onclick={() => ontheme?.()}>
        {labels.theme}
      </Button>
      {#if (((actions as string) === "cta") && cta)}
        <Button variant="default" size="sm" href={urlOf(ctaHref)}>
          {cta}
        </Button>
      {/if}
    </Group>
  </Container>
</Block>
blocks/site-header.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 SiteHeaderLabels = {
  skip: string;
  brand: string;
  nav: string;
  home: string;
  pricing: string;
  theme: string;
};

export type SiteRoutes = {
  home?: string;
  pricing?: 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 site-header
blocks/site-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 page header: a skip link to the main content, the brand, the two navigation links (the current one carries
 * aria-current) and the theme button. `current` is the route area. Axes: layout (inline, stacked), position
 * (static, sticky), actions (none, cta).
 */
import { type ReactNode } from "react";
import { Block, Button, Container, Group, LinkPlain } from "../compose";
import { MenuEntry } from "../components/menu-entry";
import { NavBlock } from "../components/nav-block";
import { cn, tpl, uniqLabel, urlOf } from "../utils";
import type { SiteHeaderLabels, SiteRoutes } from "./site-header.types";

export type SiteHeaderProps = {
  labels: SiteHeaderLabels;
  routes?: SiteRoutes;
  current: string;
  layout?: "inline" | "stacked";
  position?: "static" | "sticky";
  actions?: "none" | "cta";
  cta?: string;
  ctaHref?: string;
  landmarkLabel?: string;
  onTheme?: () => void;
};

export function SiteHeader({
  labels,
  routes,
  current,
  layout = "inline",
  position = "static",
  actions = "none",
  cta,
  ctaHref,
  landmarkLabel,
  onTheme,
}: SiteHeaderProps) {
  return (
    <Block
      tag="header"
      className={cn(
        "border-b border-border bg-background",
        (((position as string) === "sticky") ? "sticky top-0 z-40" : "")
      )}
      data-layout={layout}
      aria-label={landmarkLabel}
      data-slot="site-header"
    >
      <LinkPlain
        href="#main-content"
        className={"sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-50 focus:rounded focus:bg-background " +
          "focus:px-4 focus:py-2 focus:text-sm focus:inset-ring focus:inset-ring-border"}
        data-slot="skip-link"
      >
        {labels.skip}
      </LinkPlain>
      <Container
        className={cn(
          "mx-auto w-full max-w-6xl px-4",
          "flex flex-wrap gap-4 py-4",
          (((layout as string) === "stacked") ? "flex-col items-center" : "items-center justify-between")
        )}
        data-slot="container"
      >
        <MenuEntry href={routes?.home} className="text-lg font-medium" testid="brand">
          {labels.brand}
        </MenuEntry>
        <NavBlock
          label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", labels.nav, landmarkLabel)) : labels.nav)}
          testid="site-nav"
        >
          <Group gap="4" align="center">
            <MenuEntry
              href={routes?.home}
              className="font-semibold"
              current={((current as string) === "home")}
              testid="nav-link"
            >
              {labels.home}
            </MenuEntry>
            <MenuEntry
              href={routes?.pricing}
              className="font-semibold"
              current={((current as string) === "pricing")}
              testid="nav-link"
            >
              {labels.pricing}
            </MenuEntry>
          </Group>
        </NavBlock>
        <Group gap="4" align="center">
          <Button variant="outline" size="sm" onClick={() => onTheme?.()}>
            {labels.theme}
          </Button>
          {(((actions as string) === "cta") && cta) ? (
            <Button variant="default" size="sm" href={urlOf(ctaHref)}>
              {cta}
            </Button>
          ) : null}
        </Group>
      </Container>
    </Block>
  );
}
blocks/site-header.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 SiteHeaderLabels = {
  skip: string;
  brand: string;
  nav: string;
  home: string;
  pricing: string;
  theme: string;
};

export type SiteRoutes = {
  home?: string;
  pricing?: 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 site-header
blocks/site-header.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 SiteHeaderLabels = {
  skip: string;
  brand: string;
  nav: string;
  home: string;
  pricing: string;
  theme: string;
};

export type SiteRoutes = {
  home?: string;
  pricing?: string;
};
blocks/site-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 page header: a skip link to the main content, the brand, the two navigation links (the current one carries
  aria-current) and the theme button. `current` is the route area. Axes: layout (inline, stacked), position
  (static, sticky), actions (none, cta).
-->
<script lang="ts">
import type { SiteHeaderLabels, SiteRoutes } from "./site-header.types";

export type SiteHeaderProps = {
  labels: SiteHeaderLabels;
  routes?: SiteRoutes;
  current: string;
  layout?: "inline" | "stacked";
  position?: "static" | "sticky";
  actions?: "none" | "cta";
  cta?: string;
  ctaHref?: string;
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Block from "../compose/Block.vue";
import Button from "../compose/Button.vue";
import Container from "../compose/Container.vue";
import Group from "../compose/Group.vue";
import LinkPlain from "../compose/LinkPlain.vue";
import MenuEntry from "../components/menu-entry.vue";
import NavBlock from "../components/nav-block.vue";
import { cn, tpl, uniqLabel, urlOf } from "../utils";

const {
  labels,
  routes,
  current,
  layout = "inline",
  position = "static",
  actions = "none",
  cta,
  ctaHref,
  landmarkLabel,
} = defineProps<SiteHeaderProps>();
const emit = defineEmits<{ theme: [] }>();
</script>

<template>
  <Block
    tag="header"
    :class="cn(
      'border-b border-border bg-background',
      (((position as string) === 'sticky') ? 'sticky top-0 z-40' : '')
    )"
    :data-layout="layout"
    :aria-label="landmarkLabel"
    data-slot="site-header"
  >
    <LinkPlain
      href="#main-content"
      :class="'sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-50 focus:rounded focus:bg-background ' +
        'focus:px-4 focus:py-2 focus:text-sm focus:inset-ring focus:inset-ring-border'"
      data-slot="skip-link"
    >
      {{ labels.skip }}
    </LinkPlain>
    <Container
      :class="cn(
        'mx-auto w-full max-w-6xl px-4',
        'flex flex-wrap gap-4 py-4',
        (((layout as string) === 'stacked') ? 'flex-col items-center' : 'items-center justify-between')
      )"
      data-slot="container"
    >
      <MenuEntry :href="routes?.home" class="text-lg font-medium" testid="brand">
        {{ labels.brand }}
      </MenuEntry>
      <NavBlock
        :label="(landmarkLabel ? uniqLabel(tpl('{0}, {1}', labels.nav, landmarkLabel)) : labels.nav)"
        testid="site-nav"
      >
        <Group gap="4" align="center">
          <MenuEntry
            :href="routes?.home"
            class="font-semibold"
            :current="((current as string) === 'home')"
            testid="nav-link"
          >
            {{ labels.home }}
          </MenuEntry>
          <MenuEntry
            :href="routes?.pricing"
            class="font-semibold"
            :current="((current as string) === 'pricing')"
            testid="nav-link"
          >
            {{ labels.pricing }}
          </MenuEntry>
        </Group>
      </NavBlock>
      <Group gap="4" align="center">
        <Button variant="outline" size="sm" @click="() => emit('theme')">
          {{ labels.theme }}
        </Button>
        <Button v-if="(((actions as string) === 'cta') && cta)" variant="default" size="sm" :href="urlOf(ctaHref)">
          {{ cta }}
        </Button>
      </Group>
    </Container>
  </Block>
</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 site-header
blocks/site-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 page header: a skip link to the main content, the brand, the two navigation links (the current one carries
 * aria-current) and the theme button. `current` is the route area. Axes: layout (inline, stacked), position
 * (static, sticky), actions (none, cta).
 */
import { type JSX } from "solid-js";
import { Block, Button, Container, Group, LinkPlain } from "../compose";
import { MenuEntry } from "../components/menu-entry";
import { NavBlock } from "../components/nav-block";
import { cn, tpl, uniqLabel, urlOf } from "../utils";
import type { SiteHeaderLabels, SiteRoutes } from "./site-header.types";

export type SiteHeaderProps = {
  labels: SiteHeaderLabels;
  routes?: SiteRoutes;
  current: string;
  layout?: "inline" | "stacked";
  position?: "static" | "sticky";
  actions?: "none" | "cta";
  cta?: string;
  ctaHref?: string;
  landmarkLabel?: string;
  onTheme?: () => void;
};

export function SiteHeader({
  labels,
  routes,
  current,
  layout = "inline",
  position = "static",
  actions = "none",
  cta,
  ctaHref,
  landmarkLabel,
  onTheme,
}: SiteHeaderProps) {
  return (
    <Block
      tag="header"
      class={cn(
        "border-b border-border bg-background",
        (((position as string) === "sticky") ? "sticky top-0 z-40" : "")
      )}
      data-layout={layout}
      aria-label={landmarkLabel}
      data-slot="site-header"
    >
      <LinkPlain
        href="#main-content"
        class={"sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-50 focus:rounded focus:bg-background " +
          "focus:px-4 focus:py-2 focus:text-sm focus:inset-ring focus:inset-ring-border"}
        data-slot="skip-link"
      >
        {labels.skip}
      </LinkPlain>
      <Container
        class={cn(
          "mx-auto w-full max-w-6xl px-4",
          "flex flex-wrap gap-4 py-4",
          (((layout as string) === "stacked") ? "flex-col items-center" : "items-center justify-between")
        )}
        data-slot="container"
      >
        <MenuEntry href={routes?.home} class="text-lg font-medium" testid="brand">
          {labels.brand}
        </MenuEntry>
        <NavBlock
          label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", labels.nav, landmarkLabel)) : labels.nav)}
          testid="site-nav"
        >
          <Group gap="4" align="center">
            <MenuEntry
              href={routes?.home}
              class="font-semibold"
              current={((current as string) === "home")}
              testid="nav-link"
            >
              {labels.home}
            </MenuEntry>
            <MenuEntry
              href={routes?.pricing}
              class="font-semibold"
              current={((current as string) === "pricing")}
              testid="nav-link"
            >
              {labels.pricing}
            </MenuEntry>
          </Group>
        </NavBlock>
        <Group gap="4" align="center">
          <Button variant="outline" size="sm" onClick={() => onTheme?.()}>
            {labels.theme}
          </Button>
          {(((actions as string) === "cta") && cta) ? (
            <Button variant="default" size="sm" href={urlOf(ctaHref)}>
              {cta}
            </Button>
          ) : null}
        </Group>
      </Container>
    </Block>
  );
}
blocks/site-header.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 SiteHeaderLabels = {
  skip: string;
  brand: string;
  nav: string;
  home: string;
  pricing: string;
  theme: string;
};

export type SiteRoutes = {
  home?: string;
  pricing?: 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 site-header
blocks/site-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/organisms/site-header.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/link"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// SiteHeaderProps are the props of SiteHeader; the values are the JSON shapes of the TypeScript props.
type SiteHeaderProps struct {
	Labels any `json:"labels"`
	Routes any `json:"routes"`
	Current any `json:"current"`
	Layout any `json:"layout"`
	Position any `json:"position"`
	Actions any `json:"actions"`
	Cta any `json:"cta"`
	CtaHref any `json:"ctaHref"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// The page header: a skip link to the main content, the brand, the two navigation links (the current one carries aria-current) and the theme button. `current` is the route area. Axes: layout (inline, stacked), position (static, sticky), actions (none, cta).
templ SiteHeader(p SiteHeaderProps) {
	{{ vLabels := p.Labels }}
	{{ vRoutes := p.Routes }}
	{{ vCurrent := p.Current }}
	{{ vLayout := uiutils.Def(p.Layout, "inline") }}
	{{ vPosition := uiutils.Def(p.Position, "static") }}
	{{ vActions := uiutils.Def(p.Actions, "none") }}
	{{ vCta := p.Cta }}
	{{ vCtaHref := p.CtaHref }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "header", Class: uiutils.S(uiutils.Cnv("border-b border-border bg-background", uiutils.Cond(uiutils.T(uiutils.Eq(vPosition, "sticky")), "sticky top-0 z-40", ""))), Attrs: uiutils.Attrs("data-layout", vLayout, "aria-label", vLandmarkLabel, "data-slot", "site-header")}}) {
		@compose.LinkPlain(compose.LinkPlainProps{LinkProps: link.LinkProps{Href: "#main-content", Class: "sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-50 focus:rounded focus:bg-background focus:px-4 focus:py-2 focus:text-sm focus:inset-ring focus:inset-ring-border", Attrs: uiutils.Attrs("data-slot", "skip-link")}}) {
			{ uiutils.Text(uiutils.Get(vLabels, "skip")) }
		}
		@compose.Container(compose.ContainerProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("mx-auto w-full max-w-6xl px-4", "flex flex-wrap gap-4 py-4", uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "stacked")), "flex-col items-center", "items-center justify-between"))), Attrs: uiutils.Attrs("data-slot", "container")}}) {
			@MenuEntry(MenuEntryProps{Href: uiutils.Get(vRoutes, "home"), Class: uiutils.Cnv("text-lg font-medium"), Testid: "brand"}) {
				{ uiutils.Text(uiutils.Get(vLabels, "brand")) }
			}
			@NavBlock(NavBlockProps{Label: uiutils.Cond(uiutils.T(vLandmarkLabel), uiutils.Uniq(uiutils.Tpl("{0}, {1}", uiutils.Get(vLabels, "nav"), vLandmarkLabel)), uiutils.Get(vLabels, "nav")), Testid: "site-nav"}) {
				@compose.Group(compose.GroupProps{Gap: "4", Align: "center", BoxProps: box.BoxProps{}}) {
					@MenuEntry(MenuEntryProps{Href: uiutils.Get(vRoutes, "home"), Class: uiutils.Cnv("font-semibold"), Current: uiutils.Eq(vCurrent, "home"), Testid: "nav-link"}) {
						{ uiutils.Text(uiutils.Get(vLabels, "home")) }
					}
					@MenuEntry(MenuEntryProps{Href: uiutils.Get(vRoutes, "pricing"), Class: uiutils.Cnv("font-semibold"), Current: uiutils.Eq(vCurrent, "pricing"), Testid: "nav-link"}) {
						{ uiutils.Text(uiutils.Get(vLabels, "pricing")) }
					}
				}
			}
			@compose.Group(compose.GroupProps{Gap: "4", Align: "center", BoxProps: box.BoxProps{}}) {
				@compose.Button(compose.ButtonProps{Variant: "outline", Size: "sm", ButtonProps: button.ButtonProps{}}) {
					{ uiutils.Text(uiutils.Get(vLabels, "theme")) }
				}
				if uiutils.T(uiutils.And(uiutils.Eq(vActions, "cta"), vCta)) {
					@compose.Button(compose.ButtonProps{Variant: "default", Size: "sm", ButtonProps: button.ButtonProps{Href: uiutils.URL(vCtaHref, false)}}) {
						{ uiutils.Text(vCta) }
					}
				}
			}
		}
	}
}

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 site-header
blocks/site-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/organisms/site-header.json
    The page header: a skip link to the main content, the brand, the two navigation links (the current one carries aria-current) and the theme button. `current` is the route area. Axes: layout (inline, stacked), position (static, sticky), actions (none, cta).
    Props (p): labels, routes, current, layout, position, actions, cta, ctaHref, landmarkLabel. -#}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_routes = (p.routes ?? null) -%}
{%- set v_current = (p.current ?? null) -%}
{%- set v_layout = (p.layout ?? 'inline') -%}
{%- set v_position = (p.position ?? 'static') -%}
{%- set v_actions = (p.actions ?? 'none') -%}
{%- set v_cta = (p.cta ?? null) -%}
{%- set v_ctaHref = (p.ctaHref ?? null) -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_11 -%}
  {%- set c_1 -%}
    {{ og_text(og_get(v_labels, ['skip'])) }}
  {%- endset -%}
  {{ include('compose/LinkPlain.html.twig', {'href': '#main-content', 'class': 'sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-50 focus:rounded focus:bg-background focus:px-4 focus:py-2 focus:text-sm focus:inset-ring focus:inset-ring-border', 'attrs': og_attrs(['data-slot', 'skip-link']), 'children': c_1}, with_context = false) }}
  {%- set c_10 -%}
    {%- set c_2 -%}
      {{ og_text(og_get(v_labels, ['brand'])) }}
    {%- endset -%}
    {{ include('blocks/menu-entry.html.twig', {'p': {'href': og_get(v_routes, ['home']), 'className': og_cnv(['text-lg font-medium']), 'testid': 'brand'}, 'children': og_markup(c_2)}, with_context = false) }}
    {%- set c_6 -%}
      {%- set c_5 -%}
        {%- set c_3 -%}
          {{ og_text(og_get(v_labels, ['home'])) }}
        {%- endset -%}
        {{ include('blocks/menu-entry.html.twig', {'p': {'href': og_get(v_routes, ['home']), 'className': og_cnv(['font-semibold']), 'current': og_eq(v_current, 'home'), 'testid': 'nav-link'}, 'children': og_markup(c_3)}, with_context = false) }}
        {%- set c_4 -%}
          {{ og_text(og_get(v_labels, ['pricing'])) }}
        {%- endset -%}
        {{ include('blocks/menu-entry.html.twig', {'p': {'href': og_get(v_routes, ['pricing']), 'className': og_cnv(['font-semibold']), 'current': og_eq(v_current, 'pricing'), 'testid': 'nav-link'}, 'children': og_markup(c_4)}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'children': c_5}, with_context = false) }}
    {%- endset -%}
    {{ include('blocks/nav-block.html.twig', {'p': {'label': (og_t(v_landmarkLabel) ? og_uniq(og_tpl('{0}, {1}', [og_get(v_labels, ['nav']), v_landmarkLabel])) : og_get(v_labels, ['nav'])), 'testid': 'site-nav'}, 'children': og_markup(c_6)}, with_context = false) }}
    {%- set c_9 -%}
      {%- set c_7 -%}
        {{ og_text(og_get(v_labels, ['theme'])) }}
      {%- endset -%}
      {{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'sm', 'children': c_7}, with_context = false) }}
      {%- if og_t(og_and([og_eq(v_actions, 'cta'), v_cta])) %}
        {%- set c_8 -%}
          {{ og_text(v_cta) }}
        {%- endset -%}
        {{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'sm', 'href': og_url(og_s(v_ctaHref)), 'children': c_8}, with_context = false) }}
      {%- endif %}
    {%- endset -%}
    {{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'children': c_9}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Container.html.twig', {'class': og_s(og_cnv(['mx-auto w-full max-w-6xl px-4', 'flex flex-wrap gap-4 py-4', (og_t(og_eq(v_layout, 'stacked')) ? 'flex-col items-center' : 'items-center justify-between')])), 'attrs': og_attrs(['data-slot', 'container']), 'children': c_10}, with_context = false) }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'header', 'class': og_s(og_cnv(['border-b border-border bg-background', (og_t(og_eq(v_position, 'sticky')) ? 'sticky top-0 z-40' : '')])), 'attrs': og_attrs(['data-layout', v_layout, 'aria-label', v_landmarkLabel, 'data-slot', 'site-header']), 'children': c_11}, 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 site-header
blocks/site-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/organisms/site-header.json
    The page header: a skip link to the main content, the brand, the two navigation links (the current one carries aria-current) and the theme button. `current` is the route area. Axes: layout (inline, stacked), position (static, sticky), actions (none, cta).
    Props (p): labels, routes, current, layout, position, actions, cta, ctaHref, landmarkLabel. *}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_routes = ($p['routes'] ?? null)}
{var $v_current = ($p['current'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'inline')}
{var $v_position = ($p['position'] ?? 'static')}
{var $v_actions = ($p['actions'] ?? 'none')}
{var $v_cta = ($p['cta'] ?? null)}
{var $v_ctaHref = ($p['ctaHref'] ?? null)}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_11}
  {capture $c_1}
    {=og_text(og_get($v_labels, ['skip']))}
  {/capture}
  {=og_include('compose/LinkPlain.latte', ['href' => '#main-content', 'class' => 'sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-50 focus:rounded focus:bg-background focus:px-4 focus:py-2 focus:text-sm focus:inset-ring focus:inset-ring-border', 'attrs' => og_attrs(['data-slot', 'skip-link']), 'children' => (string) $c_1])|noescape}
  {capture $c_10}
    {capture $c_2}
      {=og_text(og_get($v_labels, ['brand']))}
    {/capture}
    {=og_include('blocks/menu-entry.latte', ['p' => ['href' => og_get($v_routes, ['home']), 'className' => og_cnv(['text-lg font-medium']), 'testid' => 'brand'], 'children' => og_markup($c_2)])|noescape}
    {capture $c_6}
      {capture $c_5}
        {capture $c_3}
          {=og_text(og_get($v_labels, ['home']))}
        {/capture}
        {=og_include('blocks/menu-entry.latte', ['p' => ['href' => og_get($v_routes, ['home']), 'className' => og_cnv(['font-semibold']), 'current' => og_eq($v_current, 'home'), 'testid' => 'nav-link'], 'children' => og_markup($c_3)])|noescape}
        {capture $c_4}
          {=og_text(og_get($v_labels, ['pricing']))}
        {/capture}
        {=og_include('blocks/menu-entry.latte', ['p' => ['href' => og_get($v_routes, ['pricing']), 'className' => og_cnv(['font-semibold']), 'current' => og_eq($v_current, 'pricing'), 'testid' => 'nav-link'], 'children' => og_markup($c_4)])|noescape}
      {/capture}
      {=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'children' => (string) $c_5])|noescape}
    {/capture}
    {=og_include('blocks/nav-block.latte', ['p' => ['label' => (og_t($v_landmarkLabel) ? og_uniq(og_tpl('{0}, {1}', [og_get($v_labels, ['nav']), $v_landmarkLabel])) : og_get($v_labels, ['nav'])), 'testid' => 'site-nav'], 'children' => og_markup($c_6)])|noescape}
    {capture $c_9}
      {capture $c_7}
        {=og_text(og_get($v_labels, ['theme']))}
      {/capture}
      {=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'sm', 'children' => (string) $c_7])|noescape}
      {if og_t(og_and([og_eq($v_actions, 'cta'), $v_cta]))}
        {capture $c_8}
          {=og_text($v_cta)}
        {/capture}
        {=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'sm', 'href' => og_url(og_s($v_ctaHref)), 'children' => (string) $c_8])|noescape}
      {/if}
    {/capture}
    {=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'children' => (string) $c_9])|noescape}
  {/capture}
  {=og_include('compose/Container.latte', ['class' => og_s(og_cnv(['mx-auto w-full max-w-6xl px-4', 'flex flex-wrap gap-4 py-4', (og_t(og_eq($v_layout, 'stacked')) ? 'flex-col items-center' : 'items-center justify-between')])), 'attrs' => og_attrs(['data-slot', 'container']), 'children' => (string) $c_10])|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'header', 'class' => og_s(og_cnv(['border-b border-border bg-background', (og_t(og_eq($v_position, 'sticky')) ? 'sticky top-0 z-40' : '')])), 'attrs' => og_attrs(['data-layout', $v_layout, 'aria-label', $v_landmarkLabel, 'data-slot', 'site-header']), 'children' => (string) $c_11])|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 site-header
blocks/site-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/organisms/site-header.json
    The page header: a skip link to the main content, the brand, the two navigation links (the current one carries aria-current) and the theme button. `current` is the route area. Axes: layout (inline, stacked), position (static, sticky), actions (none, cta).
    Props (p): labels, routes, current, layout, position, actions, cta, ctaHref, landmarkLabel. -#}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_routes = og_def(p['routes'], none) -%}
{%- set v_current = og_def(p['current'], none) -%}
{%- set v_layout = og_def(p['layout'], 'inline') -%}
{%- set v_position = og_def(p['position'], 'static') -%}
{%- set v_actions = og_def(p['actions'], 'none') -%}
{%- set v_cta = og_def(p['cta'], none) -%}
{%- set v_ctaHref = og_def(p['ctaHref'], none) -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_11 -%}
  {%- set c_1 -%}
    {{ og_text(og_get(v_labels, ['skip'])) }}
  {%- endset -%}
  {{ og_include('compose/link-plain.html.j2', {'p': {'Href': '#main-content', 'Class': 'sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-50 focus:rounded focus:bg-background focus:px-4 focus:py-2 focus:text-sm focus:inset-ring focus:inset-ring-border', 'Attrs': og_attrs(['data-slot', 'skip-link'])}, 'children': c_1}) }}
  {%- set c_10 -%}
    {%- set c_2 -%}
      {{ og_text(og_get(v_labels, ['brand'])) }}
    {%- endset -%}
    {{ og_include('blocks/menu-entry.html.j2', {'p': {'href': og_get(v_routes, ['home']), 'className': og_cnv(['text-lg font-medium']), 'testid': 'brand'}, 'children': og_markup(c_2)}) }}
    {%- set c_6 -%}
      {%- set c_5 -%}
        {%- set c_3 -%}
          {{ og_text(og_get(v_labels, ['home'])) }}
        {%- endset -%}
        {{ og_include('blocks/menu-entry.html.j2', {'p': {'href': og_get(v_routes, ['home']), 'className': og_cnv(['font-semibold']), 'current': og_eq(v_current, 'home'), 'testid': 'nav-link'}, 'children': og_markup(c_3)}) }}
        {%- set c_4 -%}
          {{ og_text(og_get(v_labels, ['pricing'])) }}
        {%- endset -%}
        {{ og_include('blocks/menu-entry.html.j2', {'p': {'href': og_get(v_routes, ['pricing']), 'className': og_cnv(['font-semibold']), 'current': og_eq(v_current, 'pricing'), 'testid': 'nav-link'}, 'children': og_markup(c_4)}) }}
      {%- endset -%}
      {{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center'}, 'children': c_5}) }}
    {%- endset -%}
    {{ og_include('blocks/nav-block.html.j2', {'p': {'label': (og_uniq(og_tpl('{0}, {1}', [og_get(v_labels, ['nav']), v_landmarkLabel])) if og_t(v_landmarkLabel) else og_get(v_labels, ['nav'])), 'testid': 'site-nav'}, 'children': og_markup(c_6)}) }}
    {%- set c_9 -%}
      {%- set c_7 -%}
        {{ og_text(og_get(v_labels, ['theme'])) }}
      {%- endset -%}
      {{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'sm'}, 'children': c_7}) }}
      {%- if og_t(og_and([og_eq(v_actions, 'cta'), v_cta])) %}
        {%- set c_8 -%}
          {{ og_text(v_cta) }}
        {%- endset -%}
        {{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'sm', 'Href': og_url(og_s(v_ctaHref))}, 'children': c_8}) }}
      {%- endif %}
    {%- endset -%}
    {{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center'}, 'children': c_9}) }}
  {%- endset -%}
  {{ og_include('compose/container.html.j2', {'p': {'Class': og_s(og_cnv(['mx-auto w-full max-w-6xl px-4', 'flex flex-wrap gap-4 py-4', ('flex-col items-center' if og_t(og_eq(v_layout, 'stacked')) else 'items-center justify-between')])), 'Attrs': og_attrs(['data-slot', 'container'])}, 'children': c_10}) }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'header', 'Class': og_s(og_cnv(['border-b border-border bg-background', ('sticky top-0 z-40' if og_t(og_eq(v_position, 'sticky')) else '')])), 'Attrs': og_attrs(['data-layout', v_layout, 'aria-label', v_landmarkLabel, 'data-slot', 'site-header'])}, 'children': c_11}) }}

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 page header: a skip link to the main content, the brand, the two navigation links (the current one carries aria-current) and the theme button. `current` is the route area. Axes: layout (inline, stacked), position (static, sticky), actions (none, cta).

Props of SiteHeader
PropTypeDefault Description
labels (required)SiteHeaderLabels-
routes SiteRoutes-the addresses of the two pages, from the app; none: the brand and the menu are text, not links
current (required)string-the area of the current route: home or pricing
layout "inline" | "stacked""inline"inline: brand left, links and button right; stacked: all centered in rows
position "static" | "sticky""static"sticky: stays at the top while the page scrolls
actions "none" | "cta""none"cta: a call-to-action button after the navigation
cta string-text of the call to action
ctaHref string-
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

Used in