Skip to content
ui8kit

component / components

Hero Head

Hero Head component

Install

npx ui8kit add hero-head

Pulls in: block, button, compose, group, inline, kit-box, kit-button, kit-link, kit-text, link, link-plain, menu-entry, nav-bar, nav-block, presets, utils

Preview

No static preview for this item: it needs content or a parent that this page cannot supply. The code is below.

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 hero-head
components/hero-head.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 row of a hero band: skip link, brand, menu links (the current one carries aria-current), login and a
  call to action.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { NavLink } from "../blocks/nav-bar.types";

  export type HeroHeadProps = {
    brand?: string;
    brandHref?: string;
    links?: NavLink[];
    current?: string;
    login?: string;
    loginHref?: string;
    cta?: string;
    href?: string;
    skip?: string;
    navLabel?: string;
    landmarkLabel?: string;
  };
</script>

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

  let {
    brand,
    brandHref,
    links,
    current = "",
    login,
    loginHref,
    cta,
    href,
    skip,
    navLabel,
    landmarkLabel,
  }: HeroHeadProps = $props();
</script>

<Block
  tag="header"
  class={cn("flex w-full flex-wrap items-center justify-between pr-4", defaults.hero.head)}
  aria-label={landmarkLabel}
  data-slot="hero-head"
>
  {#if skip}
    <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:text-foreground focus:inset-ring focus:inset-ring-border"}
      data-slot="skip-link"
    >
      {skip}
    </LinkPlain>
  {/if}
  <MenuEntry
    href={brandHref}
    class={cn(defaults.text.small, "font-medium leading-6 text-background")}
    testid="brand"
  >
    {brand}
  </MenuEntry>
  {#if (links && ((links?.length ?? 0) > 0))}
    <NavBlock
      label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", navLabel, landmarkLabel)) : navLabel)}
      testid="site-nav"
    >
      <Group gap="8" align="center" class="flex-wrap">
        {#each links as l (l.id)}
          {#if l.href}
            <Link
              href={urlOf(l.href)}
              variant="default"
              aria-current={((l.id === current) ? "page" : undefined)}
              class="text-xs font-medium leading-5 text-background"
              data-slot="nav-link"
            >
              {l.name}
            </Link>
          {:else}
            <Inline class="text-xs font-medium leading-5 text-background" data-slot="nav-link">
              {l.name}
            </Inline>
          {/if}
        {/each}
      </Group>
    </NavBlock>
  {/if}
  <Group gap="2" align="center">
    {#if login}
      <Button href={urlOf(loginHref)} variant="ghost" size="sm" class="text-background hover:bg-background/10">
        {login}
      </Button>
    {/if}
    {#if cta}
      <Button href={urlOf(href)} variant="secondary" size="sm">
        {cta}
      </Button>
    {/if}
  </Group>
</Block>

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 hero-head
components/hero-head.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 row of a hero band: skip link, brand, menu links (the current one carries aria-current), login and a
 * call to action.
 */
import { Fragment, type ReactNode } from "react";
import { Block, Button, Group, Inline, Link, LinkPlain } from "../compose";
import { MenuEntry } from "../components/menu-entry";
import { NavBlock } from "../components/nav-block";
import { defaults } from "../presets/defaults";
import { cn, tpl, uniqLabel, urlOf } from "../utils";
import type { NavLink } from "../blocks/nav-bar.types";

export type HeroHeadProps = {
  brand?: string;
  brandHref?: string;
  links?: NavLink[];
  current?: string;
  login?: string;
  loginHref?: string;
  cta?: string;
  href?: string;
  skip?: string;
  navLabel?: string;
  landmarkLabel?: string;
};

export function HeroHead({
  brand,
  brandHref,
  links,
  current = "",
  login,
  loginHref,
  cta,
  href,
  skip,
  navLabel,
  landmarkLabel,
}: HeroHeadProps) {
  return (
    <Block
      tag="header"
      className={cn("flex w-full flex-wrap items-center justify-between pr-4", defaults.hero.head)}
      aria-label={landmarkLabel}
      data-slot="hero-head"
    >
      {skip ? (
        <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:text-foreground focus:inset-ring focus:inset-ring-border"}
          data-slot="skip-link"
        >
          {skip}
        </LinkPlain>
      ) : null}
      <MenuEntry
        href={brandHref}
        className={cn(defaults.text.small, "font-medium leading-6 text-background")}
        testid="brand"
      >
        {brand}
      </MenuEntry>
      {(links && ((links?.length ?? 0) > 0)) ? (
        <NavBlock
          label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", navLabel, landmarkLabel)) : navLabel)}
          testid="site-nav"
        >
          <Group gap="8" align="center" className="flex-wrap">
            {(links ?? []).map((l) => (
              <Fragment key={l.id}>
                {l.href ? (
                  <Link
                    href={urlOf(l.href)}
                    variant="default"
                    aria-current={((l.id === current) ? "page" : undefined)}
                    className="text-xs font-medium leading-5 text-background"
                    data-slot="nav-link"
                  >
                    {l.name}
                  </Link>
                ) : (
                  <Inline className="text-xs font-medium leading-5 text-background" data-slot="nav-link">
                    {l.name}
                  </Inline>
                )}
              </Fragment>
            ))}
          </Group>
        </NavBlock>
      ) : null}
      <Group gap="2" align="center">
        {login ? (
          <Button href={urlOf(loginHref)} variant="ghost" size="sm" className="text-background hover:bg-background/10">
            {login}
          </Button>
        ) : null}
        {cta ? (
          <Button href={urlOf(href)} variant="secondary" size="sm">
            {cta}
          </Button>
        ) : null}
      </Group>
    </Block>
  );
}

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 hero-head
components/hero-head.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 row of a hero band: skip link, brand, menu links (the current one carries aria-current), login and a
  call to action.
-->
<script lang="ts">
import type { NavLink } from "../blocks/nav-bar.types";

export type HeroHeadProps = {
  brand?: string;
  brandHref?: string;
  links?: NavLink[];
  current?: string;
  login?: string;
  loginHref?: string;
  cta?: string;
  href?: string;
  skip?: string;
  navLabel?: string;
  landmarkLabel?: string;
};
</script>

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

const {
  brand,
  brandHref,
  links,
  current = "",
  login,
  loginHref,
  cta,
  href,
  skip,
  navLabel,
  landmarkLabel,
} = defineProps<HeroHeadProps>();
</script>

<template>
  <Block
    tag="header"
    :class="cn('flex w-full flex-wrap items-center justify-between pr-4', defaults.hero.head)"
    :aria-label="landmarkLabel"
    data-slot="hero-head"
  >
    <LinkPlain v-if="skip"
      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:text-foreground focus:inset-ring focus:inset-ring-border'"
      data-slot="skip-link"
    >
      {{ skip }}
    </LinkPlain>
    <MenuEntry
      :href="brandHref"
      :class="cn(defaults.text.small, 'font-medium leading-6 text-background')"
      testid="brand"
    >
      {{ brand }}
    </MenuEntry>
    <NavBlock v-if="(links && ((links?.length ?? 0) > 0))"
      :label="(landmarkLabel ? uniqLabel(tpl('{0}, {1}', navLabel, landmarkLabel)) : navLabel)"
      testid="site-nav"
    >
      <Group gap="8" align="center" class="flex-wrap">
        <template v-for="l in links" :key="l.id">
          <Link v-if="l.href"
            :href="urlOf(l.href)"
            variant="default"
            :aria-current="((l.id === current) ? 'page' : undefined)"
            class="text-xs font-medium leading-5 text-background"
            data-slot="nav-link"
          >
            {{ l.name }}
          </Link>
          <Inline v-else class="text-xs font-medium leading-5 text-background" data-slot="nav-link">
            {{ l.name }}
          </Inline>
        </template>
      </Group>
    </NavBlock>
    <Group gap="2" align="center">
      <Button
        v-if="login"
        :href="urlOf(loginHref)"
        variant="ghost"
        size="sm"
        class="text-background hover:bg-background/10"
      >
        {{ login }}
      </Button>
      <Button v-if="cta" :href="urlOf(href)" variant="secondary" size="sm">
        {{ cta }}
      </Button>
    </Group>
  </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 hero-head
components/hero-head.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 row of a hero band: skip link, brand, menu links (the current one carries aria-current), login and a
 * call to action.
 */
import { For, type JSX } from "solid-js";
import { Block, Button, Group, Inline, Link, LinkPlain } from "../compose";
import { MenuEntry } from "../components/menu-entry";
import { NavBlock } from "../components/nav-block";
import { defaults } from "../presets/defaults";
import { cn, tpl, uniqLabel, urlOf } from "../utils";
import type { NavLink } from "../blocks/nav-bar.types";

export type HeroHeadProps = {
  brand?: string;
  brandHref?: string;
  links?: NavLink[];
  current?: string;
  login?: string;
  loginHref?: string;
  cta?: string;
  href?: string;
  skip?: string;
  navLabel?: string;
  landmarkLabel?: string;
};

export function HeroHead({
  brand,
  brandHref,
  links,
  current = "",
  login,
  loginHref,
  cta,
  href,
  skip,
  navLabel,
  landmarkLabel,
}: HeroHeadProps) {
  return (
    <Block
      tag="header"
      class={cn("flex w-full flex-wrap items-center justify-between pr-4", defaults.hero.head)}
      aria-label={landmarkLabel}
      data-slot="hero-head"
    >
      {skip ? (
        <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:text-foreground focus:inset-ring focus:inset-ring-border"}
          data-slot="skip-link"
        >
          {skip}
        </LinkPlain>
      ) : null}
      <MenuEntry
        href={brandHref}
        class={cn(defaults.text.small, "font-medium leading-6 text-background")}
        testid="brand"
      >
        {brand}
      </MenuEntry>
      {(links && ((links?.length ?? 0) > 0)) ? (
        <NavBlock
          label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", navLabel, landmarkLabel)) : navLabel)}
          testid="site-nav"
        >
          <Group gap="8" align="center" class="flex-wrap">
            <For each={links ?? []}>{(l) => (
              <>
                {l.href ? (
                  <Link
                    href={urlOf(l.href)}
                    variant="default"
                    aria-current={((l.id === current) ? "page" : undefined)}
                    class="text-xs font-medium leading-5 text-background"
                    data-slot="nav-link"
                  >
                    {l.name}
                  </Link>
                ) : (
                  <Inline class="text-xs font-medium leading-5 text-background" data-slot="nav-link">
                    {l.name}
                  </Inline>
                )}
              </>
            )}</For>
          </Group>
        </NavBlock>
      ) : null}
      <Group gap="2" align="center">
        {login ? (
          <Button href={urlOf(loginHref)} variant="ghost" size="sm" class="text-background hover:bg-background/10">
            {login}
          </Button>
        ) : null}
        {cta ? (
          <Button href={urlOf(href)} variant="secondary" size="sm">
            {cta}
          </Button>
        ) : null}
      </Group>
    </Block>
  );
}

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 hero-head
blocks/hero-head.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/hero-head.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"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// HeroHeadProps are the props of HeroHead; the values are the JSON shapes of the TypeScript props.
type HeroHeadProps struct {
	Brand any `json:"brand"`
	BrandHref any `json:"brandHref"`
	Links any `json:"links"`
	Current any `json:"current"`
	Login any `json:"login"`
	LoginHref any `json:"loginHref"`
	Cta any `json:"cta"`
	Href any `json:"href"`
	Skip any `json:"skip"`
	NavLabel any `json:"navLabel"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// The head row of a hero band: skip link, brand, menu links (the current one carries aria-current), login and a call to action.
templ HeroHead(p HeroHeadProps) {
	{{ vBrand := p.Brand }}
	{{ vBrandHref := p.BrandHref }}
	{{ vLinks := p.Links }}
	{{ vCurrent := uiutils.Def(p.Current, "") }}
	{{ vLogin := p.Login }}
	{{ vLoginHref := p.LoginHref }}
	{{ vCta := p.Cta }}
	{{ vHref := p.Href }}
	{{ vSkip := p.Skip }}
	{{ vNavLabel := p.NavLabel }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "header", Class: uiutils.S(uiutils.Cnv("flex w-full flex-wrap items-center justify-between pr-4", uiutils.Get(presetDefaults, "hero", "head"))), Attrs: uiutils.Attrs("aria-label", vLandmarkLabel, "data-slot", "hero-head")}}) {
		if uiutils.T(vSkip) {
			@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:text-foreground focus:inset-ring focus:inset-ring-border", Attrs: uiutils.Attrs("data-slot", "skip-link")}}) {
				{ uiutils.Text(vSkip) }
			}
		}
		@MenuEntry(MenuEntryProps{Href: vBrandHref, Class: uiutils.Cnv(uiutils.Cnv(uiutils.Get(presetDefaults, "text", "small"), "font-medium leading-6 text-background")), Testid: "brand"}) {
			{ uiutils.Text(vBrand) }
		}
		if uiutils.T(uiutils.And(vLinks, uiutils.Gt(uiutils.Len(vLinks), float64(0)))) {
			@NavBlock(NavBlockProps{Label: uiutils.Cond(uiutils.T(vLandmarkLabel), uiutils.Uniq(uiutils.Tpl("{0}, {1}", vNavLabel, vLandmarkLabel)), vNavLabel), Testid: "site-nav"}) {
				@compose.Group(compose.GroupProps{Gap: "8", Align: "center", BoxProps: box.BoxProps{Class: "flex-wrap"}}) {
					for _, vL := range uiutils.L(vLinks) {
						if uiutils.T(uiutils.Get(vL, "href")) {
							@compose.Link(compose.LinkProps{Variant: "default", LinkProps: link.LinkProps{Href: uiutils.URL(uiutils.Get(vL, "href"), false), AriaCurrent: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(uiutils.Get(vL, "id"), vCurrent)), "page", nil)), Class: "text-xs font-medium leading-5 text-background", Attrs: uiutils.Attrs("data-slot", "nav-link")}}) {
								{ uiutils.Text(uiutils.Get(vL, "name")) }
							}
						} else {
							@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-xs font-medium leading-5 text-background", Attrs: uiutils.Attrs("data-slot", "nav-link")}}) {
								{ uiutils.Text(uiutils.Get(vL, "name")) }
							}
						}
					}
				}
			}
		}
		@compose.Group(compose.GroupProps{Gap: "2", Align: "center", BoxProps: box.BoxProps{}}) {
			if uiutils.T(vLogin) {
				@compose.Button(compose.ButtonProps{Variant: "ghost", Size: "sm", ButtonProps: button.ButtonProps{Href: uiutils.URL(vLoginHref, false), Class: "text-background hover:bg-background/10"}}) {
					{ uiutils.Text(vLogin) }
				}
			}
			if uiutils.T(vCta) {
				@compose.Button(compose.ButtonProps{Variant: "secondary", Size: "sm", ButtonProps: button.ButtonProps{Href: uiutils.URL(vHref, 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 hero-head
blocks/hero-head.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/hero-head.json
    The head row of a hero band: skip link, brand, menu links (the current one carries aria-current), login and a call to action.
    Props (p): brand, brandHref, links, current, login, loginHref, cta, href, skip, navLabel, landmarkLabel. -#}
{%- set v_brand = (p.brand ?? null) -%}
{%- set v_brandHref = (p.brandHref ?? null) -%}
{%- set v_links = (p.links ?? null) -%}
{%- set v_current = (p.current ?? '') -%}
{%- set v_login = (p.login ?? null) -%}
{%- set v_loginHref = (p.loginHref ?? null) -%}
{%- set v_cta = (p.cta ?? null) -%}
{%- set v_href = (p.href ?? null) -%}
{%- set v_skip = (p.skip ?? null) -%}
{%- set v_navLabel = (p.navLabel ?? null) -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_10 -%}
  {%- if og_t(v_skip) %}
    {%- set c_1 -%}
      {{ og_text(v_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:text-foreground focus:inset-ring focus:inset-ring-border', 'attrs': og_attrs(['data-slot', 'skip-link']), 'children': c_1}, with_context = false) }}
  {%- endif %}
  {%- set c_2 -%}
    {{ og_text(v_brand) }}
  {%- endset -%}
  {{ include('blocks/menu-entry.html.twig', {'p': {'href': v_brandHref, 'className': og_cnv([og_cnv([og_preset('blocks/presets/defaults.json', ['text', 'small']), 'font-medium leading-6 text-background'])]), 'testid': 'brand'}, 'children': og_markup(c_2)}, with_context = false) }}
  {%- if og_t(og_and([v_links, og_gt(og_len(v_links), 0)])) %}
    {%- set c_6 -%}
      {%- set c_5 -%}
        {%- for v_l in og_l(v_links) %}
          {%- if og_t(og_get(v_l, ['href'])) %}
            {%- set c_3 -%}
              {{ og_text(og_get(v_l, ['name'])) }}
            {%- endset -%}
            {{ include('compose/Link.html.twig', {'href': og_url(og_s(og_get(v_l, ['href']))), 'variant': 'default', 'ariaCurrent': og_s((og_t(og_eq(og_get(v_l, ['id']), v_current)) ? 'page' : null)), 'class': 'text-xs font-medium leading-5 text-background', 'attrs': og_attrs(['data-slot', 'nav-link']), 'children': c_3}, with_context = false) }}
          {%- else %}
            {%- set c_4 -%}
              {{ og_text(og_get(v_l, ['name'])) }}
            {%- endset -%}
            {{ include('compose/Inline.html.twig', {'class': 'text-xs font-medium leading-5 text-background', 'attrs': og_attrs(['data-slot', 'nav-link']), 'children': c_4}, with_context = false) }}
          {%- endif %}
        {%- endfor %}
      {%- endset -%}
      {{ include('compose/Group.html.twig', {'gap': '8', 'align': 'center', 'class': 'flex-wrap', '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}', [v_navLabel, v_landmarkLabel])) : v_navLabel), 'testid': 'site-nav'}, 'children': og_markup(c_6)}, with_context = false) }}
  {%- endif %}
  {%- set c_9 -%}
    {%- if og_t(v_login) %}
      {%- set c_7 -%}
        {{ og_text(v_login) }}
      {%- endset -%}
      {{ include('compose/Button.html.twig', {'href': og_url(og_s(v_loginHref)), 'variant': 'ghost', 'size': 'sm', 'class': 'text-background hover:bg-background/10', 'children': c_7}, with_context = false) }}
    {%- endif %}
    {%- if og_t(v_cta) %}
      {%- set c_8 -%}
        {{ og_text(v_cta) }}
      {%- endset -%}
      {{ include('compose/Button.html.twig', {'href': og_url(og_s(v_href)), 'variant': 'secondary', 'size': 'sm', 'children': c_8}, with_context = false) }}
    {%- endif %}
  {%- endset -%}
  {{ include('compose/Group.html.twig', {'gap': '2', 'align': 'center', 'children': c_9}, with_context = false) }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'header', 'class': og_s(og_cnv(['flex w-full flex-wrap items-center justify-between pr-4', og_preset('blocks/presets/defaults.json', ['hero', 'head'])])), 'attrs': og_attrs(['aria-label', v_landmarkLabel, 'data-slot', 'hero-head']), 'children': c_10}, 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 hero-head
blocks/hero-head.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/hero-head.json
    The head row of a hero band: skip link, brand, menu links (the current one carries aria-current), login and a call to action.
    Props (p): brand, brandHref, links, current, login, loginHref, cta, href, skip, navLabel, landmarkLabel. *}
{var $v_brand = ($p['brand'] ?? null)}
{var $v_brandHref = ($p['brandHref'] ?? null)}
{var $v_links = ($p['links'] ?? null)}
{var $v_current = ($p['current'] ?? '')}
{var $v_login = ($p['login'] ?? null)}
{var $v_loginHref = ($p['loginHref'] ?? null)}
{var $v_cta = ($p['cta'] ?? null)}
{var $v_href = ($p['href'] ?? null)}
{var $v_skip = ($p['skip'] ?? null)}
{var $v_navLabel = ($p['navLabel'] ?? null)}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_10}
  {if og_t($v_skip)}
    {capture $c_1}
      {=og_text($v_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:text-foreground focus:inset-ring focus:inset-ring-border', 'attrs' => og_attrs(['data-slot', 'skip-link']), 'children' => (string) $c_1])|noescape}
  {/if}
  {capture $c_2}
    {=og_text($v_brand)}
  {/capture}
  {=og_include('blocks/menu-entry.latte', ['p' => ['href' => $v_brandHref, 'className' => og_cnv([og_cnv([og_preset('blocks/presets/defaults.json', ['text', 'small']), 'font-medium leading-6 text-background'])]), 'testid' => 'brand'], 'children' => og_markup($c_2)])|noescape}
  {if og_t(og_and([$v_links, og_gt(og_len($v_links), 0)]))}
    {capture $c_6}
      {capture $c_5}
        {foreach og_l($v_links) as $v_l}
          {if og_t(og_get($v_l, ['href']))}
            {capture $c_3}
              {=og_text(og_get($v_l, ['name']))}
            {/capture}
            {=og_include('compose/Link.latte', ['href' => og_url(og_s(og_get($v_l, ['href']))), 'variant' => 'default', 'ariaCurrent' => og_s((og_t(og_eq(og_get($v_l, ['id']), $v_current)) ? 'page' : null)), 'class' => 'text-xs font-medium leading-5 text-background', 'attrs' => og_attrs(['data-slot', 'nav-link']), 'children' => (string) $c_3])|noescape}
          {else}
            {capture $c_4}
              {=og_text(og_get($v_l, ['name']))}
            {/capture}
            {=og_include('compose/Inline.latte', ['class' => 'text-xs font-medium leading-5 text-background', 'attrs' => og_attrs(['data-slot', 'nav-link']), 'children' => (string) $c_4])|noescape}
          {/if}
        {/foreach}
      {/capture}
      {=og_include('compose/Group.latte', ['gap' => '8', 'align' => 'center', 'class' => 'flex-wrap', 'children' => (string) $c_5])|noescape}
    {/capture}
    {=og_include('blocks/nav-block.latte', ['p' => ['label' => (og_t($v_landmarkLabel) ? og_uniq(og_tpl('{0}, {1}', [$v_navLabel, $v_landmarkLabel])) : $v_navLabel), 'testid' => 'site-nav'], 'children' => og_markup($c_6)])|noescape}
  {/if}
  {capture $c_9}
    {if og_t($v_login)}
      {capture $c_7}
        {=og_text($v_login)}
      {/capture}
      {=og_include('compose/Button.latte', ['href' => og_url(og_s($v_loginHref)), 'variant' => 'ghost', 'size' => 'sm', 'class' => 'text-background hover:bg-background/10', 'children' => (string) $c_7])|noescape}
    {/if}
    {if og_t($v_cta)}
      {capture $c_8}
        {=og_text($v_cta)}
      {/capture}
      {=og_include('compose/Button.latte', ['href' => og_url(og_s($v_href)), 'variant' => 'secondary', 'size' => 'sm', 'children' => (string) $c_8])|noescape}
    {/if}
  {/capture}
  {=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'center', 'children' => (string) $c_9])|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'header', 'class' => og_s(og_cnv(['flex w-full flex-wrap items-center justify-between pr-4', og_preset('blocks/presets/defaults.json', ['hero', 'head'])])), 'attrs' => og_attrs(['aria-label', $v_landmarkLabel, 'data-slot', 'hero-head']), 'children' => (string) $c_10])|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 hero-head
blocks/hero-head.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/hero-head.json
    The head row of a hero band: skip link, brand, menu links (the current one carries aria-current), login and a call to action.
    Props (p): brand, brandHref, links, current, login, loginHref, cta, href, skip, navLabel, landmarkLabel. -#}
{%- set v_brand = og_def(p['brand'], none) -%}
{%- set v_brandHref = og_def(p['brandHref'], none) -%}
{%- set v_links = og_def(p['links'], none) -%}
{%- set v_current = og_def(p['current'], '') -%}
{%- set v_login = og_def(p['login'], none) -%}
{%- set v_loginHref = og_def(p['loginHref'], none) -%}
{%- set v_cta = og_def(p['cta'], none) -%}
{%- set v_href = og_def(p['href'], none) -%}
{%- set v_skip = og_def(p['skip'], none) -%}
{%- set v_navLabel = og_def(p['navLabel'], none) -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_10 -%}
  {%- if og_t(v_skip) %}
    {%- set c_1 -%}
      {{ og_text(v_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:text-foreground focus:inset-ring focus:inset-ring-border', 'Attrs': og_attrs(['data-slot', 'skip-link'])}, 'children': c_1}) }}
  {%- endif %}
  {%- set c_2 -%}
    {{ og_text(v_brand) }}
  {%- endset -%}
  {{ og_include('blocks/menu-entry.html.j2', {'p': {'href': v_brandHref, 'className': og_cnv([og_cnv([og_preset('blocks/presets/defaults.json', ['text', 'small']), 'font-medium leading-6 text-background'])]), 'testid': 'brand'}, 'children': og_markup(c_2)}) }}
  {%- if og_t(og_and([v_links, og_gt(og_len(v_links), 0)])) %}
    {%- set c_6 -%}
      {%- set c_5 -%}
        {%- for v_l in og_l(v_links) %}
          {%- if og_t(og_get(v_l, ['href'])) %}
            {%- set c_3 -%}
              {{ og_text(og_get(v_l, ['name'])) }}
            {%- endset -%}
            {{ og_include('compose/link.html.j2', {'p': {'Href': og_url(og_s(og_get(v_l, ['href']))), 'Variant': 'default', 'AriaCurrent': og_s(('page' if og_t(og_eq(og_get(v_l, ['id']), v_current)) else none)), 'Class': 'text-xs font-medium leading-5 text-background', 'Attrs': og_attrs(['data-slot', 'nav-link'])}, 'children': c_3}) }}
          {%- else %}
            {%- set c_4 -%}
              {{ og_text(og_get(v_l, ['name'])) }}
            {%- endset -%}
            {{ og_include('compose/inline.html.j2', {'p': {'Class': 'text-xs font-medium leading-5 text-background', 'Attrs': og_attrs(['data-slot', 'nav-link'])}, 'children': c_4}) }}
          {%- endif %}
        {%- endfor %}
      {%- endset -%}
      {{ og_include('compose/group.html.j2', {'p': {'Gap': '8', 'Align': 'center', 'Class': 'flex-wrap'}, 'children': c_5}) }}
    {%- endset -%}
    {{ og_include('blocks/nav-block.html.j2', {'p': {'label': (og_uniq(og_tpl('{0}, {1}', [v_navLabel, v_landmarkLabel])) if og_t(v_landmarkLabel) else v_navLabel), 'testid': 'site-nav'}, 'children': og_markup(c_6)}) }}
  {%- endif %}
  {%- set c_9 -%}
    {%- if og_t(v_login) %}
      {%- set c_7 -%}
        {{ og_text(v_login) }}
      {%- endset -%}
      {{ og_include('compose/button.html.j2', {'p': {'Href': og_url(og_s(v_loginHref)), 'Variant': 'ghost', 'Size': 'sm', 'Class': 'text-background hover:bg-background/10'}, 'children': c_7}) }}
    {%- endif %}
    {%- if og_t(v_cta) %}
      {%- set c_8 -%}
        {{ og_text(v_cta) }}
      {%- endset -%}
      {{ og_include('compose/button.html.j2', {'p': {'Href': og_url(og_s(v_href)), 'Variant': 'secondary', 'Size': 'sm'}, 'children': c_8}) }}
    {%- endif %}
  {%- endset -%}
  {{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'center'}, 'children': c_9}) }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'header', 'Class': og_s(og_cnv(['flex w-full flex-wrap items-center justify-between pr-4', og_preset('blocks/presets/defaults.json', ['hero', 'head'])])), 'Attrs': og_attrs(['aria-label', v_landmarkLabel, 'data-slot', 'hero-head'])}, 'children': c_10}) }}

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 row of a hero band: skip link, brand, menu links (the current one carries aria-current), login and a call to action.

Props of HeroHead
PropTypeDefault Description
brand string-brand word
brandHref string-the address of the home page; none: the brand is text
links NavLink[]-menu links
current string""
login string-
loginHref string-the address of the login page; none: a button
cta string-call to action label
href string-
skip string-skip link text
navLabel string-accessible name of the menu
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