Skip to content
ui8kit

block / marketing

Nav Bar

A top bar in four shapes: inline, split around the brand, with a search field, and transparent over a picture.

Install

npx ui8kit add nav-bar

Pulls in: block, box, compose, container, grid, group, kit-box, kit-link, link-plain, menu-entry, nav-actions, nav-bar-menu, nav-block, nav-links, over-media, search-palette, utils

Preview

NorthwindLog InGet Started

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 nav-bar
blocks/nav-bar.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. -->
<!--
  A top bar in four shapes. Axes: layout (inline: brand left, links, button right; split: the brand in the
  middle with the links on both sides; search: a search field with its shortcut in the middle), over (none,
  media: the bar sits over a picture, transparent), actions mode (none, cta), tone (default, inverse: on a dark
  hero band). Turning solid on scroll is a port contract.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { NavLink, NavBarActions, NavSearch } from "./nav-bar.types";

  export type NavBarProps = {
    label: string;
    brand: string;
    brandHref?: string;
    links: NavLink[];
    current?: string;
    actions?: NavBarActions;
    search: NavSearch;
    tone?: "default" | "inverse";
    layout?: "inline" | "split" | "search";
    over?: "none" | "media";
    skip?: string;
    landmarkLabel?: string;
    ontheme?: () => void;
  };
</script>

<script lang="ts">
  import Block from "../compose/Block.svelte";
  import Box from "../compose/Box.svelte";
  import Container from "../compose/Container.svelte";
  import Grid from "../compose/Grid.svelte";
  import Group from "../compose/Group.svelte";
  import LinkPlain from "../compose/LinkPlain.svelte";
  import MenuEntry from "../components/menu-entry.svelte";
  import NavActions from "../components/nav-actions.svelte";
  import NavBarMenu from "../components/nav-bar-menu.svelte";
  import NavBlock from "../components/nav-block.svelte";
  import NavLinks from "../components/nav-links.svelte";
  import OverMedia from "../components/over-media.svelte";
  import SearchPalette from "../components/search-palette.svelte";
  import { cn, tpl, uniqLabel } from "../utils";

  let {
    label,
    brand,
    brandHref,
    links,
    current = "",
    actions,
    search,
    tone = "default",
    layout = "inline",
    over = "none",
    skip,
    landmarkLabel,
    ontheme,
  }: NavBarProps = $props();
</script>

<Block
  tag="header"
  class={cn(
    "relative",
    (
      (tone as string) === "inverse" ? "border-b border-transparent bg-foreground text-background [&_a]:text-background [&_button]:text-background"
      : "border-b border-border bg-background"
    ),
    (((over as string) === "media") ? "isolate overflow-hidden border-0 bg-transparent" : "")
  )}
  data-layout={layout}
  data-tone={tone}
  aria-label={landmarkLabel}
  data-slot="nav-bar"
>
  <OverMedia on={((over as string) === "media")} alt={brand} />
  {#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:inset-ring focus:inset-ring-border"}
      data-slot="skip-link"
    >
      {skip}
    </LinkPlain>
  {/if}
  <Container class="mx-auto w-full max-w-6xl px-4" data-slot="container">
    <Box class={cn("flex flex-wrap items-center justify-between gap-4", "py-4")}>
      {#if ((layout as string) === "split")}
        <NavBlock
          label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", label, landmarkLabel)) : label)}
          class="w-full"
          testid="site-nav"
        >
          <Grid cols="1-3" class="w-full items-center gap-4">
            <Box class="md:justify-self-start">
              <NavLinks links={links} current={current} side="left" />
            </Box>
            <Box class="text-center">
              <MenuEntry href={brandHref} class="text-lg font-medium" testid="brand">
                {brand}
              </MenuEntry>
            </Box>
            <Group gap="4" align="center" justify="end" class="flex-wrap md:justify-self-end">
              <Box>
                <NavLinks links={links} current={current} side="right" />
              </Box>
              <NavActions
                login={actions?.login}
                loginHref={actions?.loginHref}
                cta={actions?.cta}
                ctaHref={actions?.href}
                actions={actions?.mode}
                tone={tone}
                themeLabel={actions?.themeLabel}
                ontheme={() => ontheme?.()}
              />
            </Group>
          </Grid>
        </NavBlock>
      {:else}
        <MenuEntry href={brandHref} class="text-lg font-medium" testid="brand">
          {brand}
        </MenuEntry>
        {#if ((layout as string) === "search")}
          <SearchPalette label={search.label} shortcut={search.shortcut} />
        {/if}
        <NavBarMenu label={label} links={links} current={current} landmarkLabel={landmarkLabel} />
        <NavActions
          login={actions?.login}
          loginHref={actions?.loginHref}
          cta={actions?.cta}
          ctaHref={actions?.href}
          actions={actions?.mode}
          tone={tone}
          themeLabel={actions?.themeLabel}
          ontheme={() => ontheme?.()}
        />
      {/if}
    </Box>
  </Container>
</Block>
blocks/nav-bar.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 NavLink = {
  id: string;
  name: string;
  icon: string;
  href?: string;
};

export type NavBarActions = {
  /** cta: show the call to action */
  mode?: "none" | "cta";
  /** text of the call to action */
  cta?: string;
  /** href of the call to action */
  href?: string;
  /** text of the login link; none: no login */
  login?: string;
  /** href of the login link; none: a button with no address */
  loginHref?: string;
  /** text of the theme button; none: no button */
  themeLabel?: string;
};

export type NavSearch = {
  /** name and placeholder of the search field (layout search) */
  label: string;
  /** the keys that open the search, shown in the field */
  shortcut: 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 nav-bar
blocks/nav-bar.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.
/**
 * A top bar in four shapes. Axes: layout (inline: brand left, links, button right; split: the brand in the
 * middle with the links on both sides; search: a search field with its shortcut in the middle), over (none,
 * media: the bar sits over a picture, transparent), actions mode (none, cta), tone (default, inverse: on a dark
 * hero band). Turning solid on scroll is a port contract.
 */
import { type ReactNode } from "react";
import { Block, Box, Container, Grid, Group, LinkPlain } from "../compose";
import { MenuEntry } from "../components/menu-entry";
import { NavActions } from "../components/nav-actions";
import { NavBarMenu } from "../components/nav-bar-menu";
import { NavBlock } from "../components/nav-block";
import { NavLinks } from "../components/nav-links";
import { OverMedia } from "../components/over-media";
import { SearchPalette } from "../components/search-palette";
import { cn, tpl, uniqLabel } from "../utils";
import type { NavLink, NavBarActions, NavSearch } from "./nav-bar.types";

export type NavBarProps = {
  label: string;
  brand: string;
  brandHref?: string;
  links: NavLink[];
  current?: string;
  actions?: NavBarActions;
  search: NavSearch;
  tone?: "default" | "inverse";
  layout?: "inline" | "split" | "search";
  over?: "none" | "media";
  skip?: string;
  landmarkLabel?: string;
  onTheme?: () => void;
};

export function NavBar({
  label,
  brand,
  brandHref,
  links,
  current = "",
  actions,
  search,
  tone = "default",
  layout = "inline",
  over = "none",
  skip,
  landmarkLabel,
  onTheme,
}: NavBarProps) {
  return (
    <Block
      tag="header"
      className={cn(
        "relative",
        (
          (tone as string) === "inverse" ? "border-b border-transparent bg-foreground text-background [&_a]:text-background [&_button]:text-background"
          : "border-b border-border bg-background"
        ),
        (((over as string) === "media") ? "isolate overflow-hidden border-0 bg-transparent" : "")
      )}
      data-layout={layout}
      data-tone={tone}
      aria-label={landmarkLabel}
      data-slot="nav-bar"
    >
      <OverMedia on={((over as string) === "media")} alt={brand} />
      {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:inset-ring focus:inset-ring-border"}
          data-slot="skip-link"
        >
          {skip}
        </LinkPlain>
      ) : null}
      <Container className="mx-auto w-full max-w-6xl px-4" data-slot="container">
        <Box className={cn("flex flex-wrap items-center justify-between gap-4", "py-4")}>
          {((layout as string) === "split") ? (
            <NavBlock
              label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", label, landmarkLabel)) : label)}
              className="w-full"
              testid="site-nav"
            >
              <Grid cols="1-3" className="w-full items-center gap-4">
                <Box className="md:justify-self-start">
                  <NavLinks links={links} current={current} side="left" />
                </Box>
                <Box className="text-center">
                  <MenuEntry href={brandHref} className="text-lg font-medium" testid="brand">
                    {brand}
                  </MenuEntry>
                </Box>
                <Group gap="4" align="center" justify="end" className="flex-wrap md:justify-self-end">
                  <Box>
                    <NavLinks links={links} current={current} side="right" />
                  </Box>
                  <NavActions
                    login={actions?.login}
                    loginHref={actions?.loginHref}
                    cta={actions?.cta}
                    ctaHref={actions?.href}
                    actions={actions?.mode}
                    tone={tone}
                    themeLabel={actions?.themeLabel}
                    onTheme={() => onTheme?.()}
                  />
                </Group>
              </Grid>
            </NavBlock>
          ) : (
            <>
              <MenuEntry href={brandHref} className="text-lg font-medium" testid="brand">
                {brand}
              </MenuEntry>
              {((layout as string) === "search") ? (
                <SearchPalette label={search.label} shortcut={search.shortcut} />
              ) : null}
              <NavBarMenu label={label} links={links} current={current} landmarkLabel={landmarkLabel} />
              <NavActions
                login={actions?.login}
                loginHref={actions?.loginHref}
                cta={actions?.cta}
                ctaHref={actions?.href}
                actions={actions?.mode}
                tone={tone}
                themeLabel={actions?.themeLabel}
                onTheme={() => onTheme?.()}
              />
            </>
          )}
        </Box>
      </Container>
    </Block>
  );
}
blocks/nav-bar.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 NavLink = {
  id: string;
  name: string;
  icon: string;
  href?: string;
};

export type NavBarActions = {
  /** cta: show the call to action */
  mode?: "none" | "cta";
  /** text of the call to action */
  cta?: string;
  /** href of the call to action */
  href?: string;
  /** text of the login link; none: no login */
  login?: string;
  /** href of the login link; none: a button with no address */
  loginHref?: string;
  /** text of the theme button; none: no button */
  themeLabel?: string;
};

export type NavSearch = {
  /** name and placeholder of the search field (layout search) */
  label: string;
  /** the keys that open the search, shown in the field */
  shortcut: 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 nav-bar
blocks/nav-bar.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 NavLink = {
  id: string;
  name: string;
  icon: string;
  href?: string;
};

export type NavBarActions = {
  /** cta: show the call to action */
  mode?: "none" | "cta";
  /** text of the call to action */
  cta?: string;
  /** href of the call to action */
  href?: string;
  /** text of the login link; none: no login */
  login?: string;
  /** href of the login link; none: a button with no address */
  loginHref?: string;
  /** text of the theme button; none: no button */
  themeLabel?: string;
};

export type NavSearch = {
  /** name and placeholder of the search field (layout search) */
  label: string;
  /** the keys that open the search, shown in the field */
  shortcut: string;
};
blocks/nav-bar.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. -->
<!--
  A top bar in four shapes. Axes: layout (inline: brand left, links, button right; split: the brand in the
  middle with the links on both sides; search: a search field with its shortcut in the middle), over (none,
  media: the bar sits over a picture, transparent), actions mode (none, cta), tone (default, inverse: on a dark
  hero band). Turning solid on scroll is a port contract.
-->
<script lang="ts">
import type { NavLink, NavBarActions, NavSearch } from "./nav-bar.types";

export type NavBarProps = {
  label: string;
  brand: string;
  brandHref?: string;
  links: NavLink[];
  current?: string;
  actions?: NavBarActions;
  search: NavSearch;
  tone?: "default" | "inverse";
  layout?: "inline" | "split" | "search";
  over?: "none" | "media";
  skip?: string;
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Block from "../compose/Block.vue";
import Box from "../compose/Box.vue";
import Container from "../compose/Container.vue";
import Grid from "../compose/Grid.vue";
import Group from "../compose/Group.vue";
import LinkPlain from "../compose/LinkPlain.vue";
import MenuEntry from "../components/menu-entry.vue";
import NavActions from "../components/nav-actions.vue";
import NavBarMenu from "../components/nav-bar-menu.vue";
import NavBlock from "../components/nav-block.vue";
import NavLinks from "../components/nav-links.vue";
import OverMedia from "../components/over-media.vue";
import SearchPalette from "../components/search-palette.vue";
import { cn, tpl, uniqLabel } from "../utils";

const {
  label,
  brand,
  brandHref,
  links,
  current = "",
  actions,
  search,
  tone = "default",
  layout = "inline",
  over = "none",
  skip,
  landmarkLabel,
} = defineProps<NavBarProps>();
const emit = defineEmits<{ theme: [] }>();
</script>

<template>
  <Block
    tag="header"
    :class="cn(
      'relative',
      (
        (tone as string) === 'inverse' ? 'border-b border-transparent bg-foreground text-background [&_a]:text-background [&_button]:text-background'
        : 'border-b border-border bg-background'
      ),
      (((over as string) === 'media') ? 'isolate overflow-hidden border-0 bg-transparent' : '')
    )"
    :data-layout="layout"
    :data-tone="tone"
    :aria-label="landmarkLabel"
    data-slot="nav-bar"
  >
    <OverMedia :on="((over as string) === 'media')" :alt="brand" />
    <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:inset-ring focus:inset-ring-border'"
      data-slot="skip-link"
    >
      {{ skip }}
    </LinkPlain>
    <Container class="mx-auto w-full max-w-6xl px-4" data-slot="container">
      <Box :class="cn('flex flex-wrap items-center justify-between gap-4', 'py-4')">
        <NavBlock v-if="((layout as string) === 'split')"
          :label="(landmarkLabel ? uniqLabel(tpl('{0}, {1}', label, landmarkLabel)) : label)"
          class="w-full"
          testid="site-nav"
        >
          <Grid cols="1-3" class="w-full items-center gap-4">
            <Box class="md:justify-self-start">
              <NavLinks :links="links" :current="current" side="left" />
            </Box>
            <Box class="text-center">
              <MenuEntry :href="brandHref" class="text-lg font-medium" testid="brand">
                {{ brand }}
              </MenuEntry>
            </Box>
            <Group gap="4" align="center" justify="end" class="flex-wrap md:justify-self-end">
              <Box>
                <NavLinks :links="links" :current="current" side="right" />
              </Box>
              <NavActions
                :login="actions?.login"
                :loginHref="actions?.loginHref"
                :cta="actions?.cta"
                :ctaHref="actions?.href"
                :actions="actions?.mode"
                :tone="tone"
                :themeLabel="actions?.themeLabel"
                @theme="() => emit('theme')"
              />
            </Group>
          </Grid>
        </NavBlock>
        <template v-else>
          <MenuEntry :href="brandHref" class="text-lg font-medium" testid="brand">
            {{ brand }}
          </MenuEntry>
          <SearchPalette v-if="((layout as string) === 'search')" :label="search.label" :shortcut="search.shortcut" />
          <NavBarMenu :label="label" :links="links" :current="current" :landmarkLabel="landmarkLabel" />
          <NavActions
            :login="actions?.login"
            :loginHref="actions?.loginHref"
            :cta="actions?.cta"
            :ctaHref="actions?.href"
            :actions="actions?.mode"
            :tone="tone"
            :themeLabel="actions?.themeLabel"
            @theme="() => emit('theme')"
          />
        </template>
      </Box>
    </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 nav-bar
blocks/nav-bar.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.
/**
 * A top bar in four shapes. Axes: layout (inline: brand left, links, button right; split: the brand in the
 * middle with the links on both sides; search: a search field with its shortcut in the middle), over (none,
 * media: the bar sits over a picture, transparent), actions mode (none, cta), tone (default, inverse: on a dark
 * hero band). Turning solid on scroll is a port contract.
 */
import { type JSX } from "solid-js";
import { Block, Box, Container, Grid, Group, LinkPlain } from "../compose";
import { MenuEntry } from "../components/menu-entry";
import { NavActions } from "../components/nav-actions";
import { NavBarMenu } from "../components/nav-bar-menu";
import { NavBlock } from "../components/nav-block";
import { NavLinks } from "../components/nav-links";
import { OverMedia } from "../components/over-media";
import { SearchPalette } from "../components/search-palette";
import { cn, tpl, uniqLabel } from "../utils";
import type { NavLink, NavBarActions, NavSearch } from "./nav-bar.types";

export type NavBarProps = {
  label: string;
  brand: string;
  brandHref?: string;
  links: NavLink[];
  current?: string;
  actions?: NavBarActions;
  search: NavSearch;
  tone?: "default" | "inverse";
  layout?: "inline" | "split" | "search";
  over?: "none" | "media";
  skip?: string;
  landmarkLabel?: string;
  onTheme?: () => void;
};

export function NavBar({
  label,
  brand,
  brandHref,
  links,
  current = "",
  actions,
  search,
  tone = "default",
  layout = "inline",
  over = "none",
  skip,
  landmarkLabel,
  onTheme,
}: NavBarProps) {
  return (
    <Block
      tag="header"
      class={cn(
        "relative",
        (
          (tone as string) === "inverse" ? "border-b border-transparent bg-foreground text-background [&_a]:text-background [&_button]:text-background"
          : "border-b border-border bg-background"
        ),
        (((over as string) === "media") ? "isolate overflow-hidden border-0 bg-transparent" : "")
      )}
      data-layout={layout}
      data-tone={tone}
      aria-label={landmarkLabel}
      data-slot="nav-bar"
    >
      <OverMedia on={((over as string) === "media")} alt={brand} />
      {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:inset-ring focus:inset-ring-border"}
          data-slot="skip-link"
        >
          {skip}
        </LinkPlain>
      ) : null}
      <Container class="mx-auto w-full max-w-6xl px-4" data-slot="container">
        <Box class={cn("flex flex-wrap items-center justify-between gap-4", "py-4")}>
          {((layout as string) === "split") ? (
            <NavBlock
              label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", label, landmarkLabel)) : label)}
              class="w-full"
              testid="site-nav"
            >
              <Grid cols="1-3" class="w-full items-center gap-4">
                <Box class="md:justify-self-start">
                  <NavLinks links={links} current={current} side="left" />
                </Box>
                <Box class="text-center">
                  <MenuEntry href={brandHref} class="text-lg font-medium" testid="brand">
                    {brand}
                  </MenuEntry>
                </Box>
                <Group gap="4" align="center" justify="end" class="flex-wrap md:justify-self-end">
                  <Box>
                    <NavLinks links={links} current={current} side="right" />
                  </Box>
                  <NavActions
                    login={actions?.login}
                    loginHref={actions?.loginHref}
                    cta={actions?.cta}
                    ctaHref={actions?.href}
                    actions={actions?.mode}
                    tone={tone}
                    themeLabel={actions?.themeLabel}
                    onTheme={() => onTheme?.()}
                  />
                </Group>
              </Grid>
            </NavBlock>
          ) : (
            <>
              <MenuEntry href={brandHref} class="text-lg font-medium" testid="brand">
                {brand}
              </MenuEntry>
              {((layout as string) === "search") ? (
                <SearchPalette label={search.label} shortcut={search.shortcut} />
              ) : null}
              <NavBarMenu label={label} links={links} current={current} landmarkLabel={landmarkLabel} />
              <NavActions
                login={actions?.login}
                loginHref={actions?.loginHref}
                cta={actions?.cta}
                ctaHref={actions?.href}
                actions={actions?.mode}
                tone={tone}
                themeLabel={actions?.themeLabel}
                onTheme={() => onTheme?.()}
              />
            </>
          )}
        </Box>
      </Container>
    </Block>
  );
}
blocks/nav-bar.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 NavLink = {
  id: string;
  name: string;
  icon: string;
  href?: string;
};

export type NavBarActions = {
  /** cta: show the call to action */
  mode?: "none" | "cta";
  /** text of the call to action */
  cta?: string;
  /** href of the call to action */
  href?: string;
  /** text of the login link; none: no login */
  login?: string;
  /** href of the login link; none: a button with no address */
  loginHref?: string;
  /** text of the theme button; none: no button */
  themeLabel?: string;
};

export type NavSearch = {
  /** name and placeholder of the search field (layout search) */
  label: string;
  /** the keys that open the search, shown in the field */
  shortcut: 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 nav-bar
blocks/nav-bar.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/nav-bar.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"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// NavBarProps are the props of NavBar; the values are the JSON shapes of the TypeScript props.
type NavBarProps struct {
	Label any `json:"label"`
	Brand any `json:"brand"`
	BrandHref any `json:"brandHref"`
	Links any `json:"links"`
	Current any `json:"current"`
	Actions any `json:"actions"`
	Search any `json:"search"`
	Tone any `json:"tone"`
	Layout any `json:"layout"`
	Over any `json:"over"`
	Skip any `json:"skip"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// A top bar in four shapes. Axes: layout (inline: brand left, links, button right; split: the brand in the middle with the links on both sides; search: a search field with its shortcut in the middle), over (none, media: the bar sits over a picture, transparent), actions mode (none, cta), tone (default, inverse: on a dark hero band). Turning solid on scroll is a port contract.
templ NavBar(p NavBarProps) {
	{{ vLabel := p.Label }}
	{{ vBrand := p.Brand }}
	{{ vBrandHref := p.BrandHref }}
	{{ vLinks := p.Links }}
	{{ vCurrent := uiutils.Def(p.Current, "") }}
	{{ vActions := p.Actions }}
	{{ vSearch := p.Search }}
	{{ vTone := uiutils.Def(p.Tone, "default") }}
	{{ vLayout := uiutils.Def(p.Layout, "inline") }}
	{{ vOver := uiutils.Def(p.Over, "none") }}
	{{ vSkip := p.Skip }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "header", Class: uiutils.S(uiutils.Cnv("relative", uiutils.Cond(uiutils.T(uiutils.Eq(vTone, "inverse")), "border-b border-transparent bg-foreground text-background [&_a]:text-background [&_button]:text-background", "border-b border-border bg-background"), uiutils.Cond(uiutils.T(uiutils.Eq(vOver, "media")), "isolate overflow-hidden border-0 bg-transparent", ""))), Attrs: uiutils.Attrs("data-layout", vLayout, "data-tone", vTone, "aria-label", vLandmarkLabel, "data-slot", "nav-bar")}}) {
		@OverMedia(OverMediaProps{On: uiutils.Eq(vOver, "media"), Alt: vBrand})
		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:inset-ring focus:inset-ring-border", Attrs: uiutils.Attrs("data-slot", "skip-link")}}) {
				{ uiutils.Text(vSkip) }
			}
		}
		@compose.Container(compose.ContainerProps{BoxProps: box.BoxProps{Class: "mx-auto w-full max-w-6xl px-4", Attrs: uiutils.Attrs("data-slot", "container")}}) {
			@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("flex flex-wrap items-center justify-between gap-4", "py-4"))}}) {
				if uiutils.Eq(vLayout, "split") {
					@NavBlock(NavBlockProps{Label: uiutils.Cond(uiutils.T(vLandmarkLabel), uiutils.Uniq(uiutils.Tpl("{0}, {1}", vLabel, vLandmarkLabel)), vLabel), Class: uiutils.Cnv("w-full"), Testid: "site-nav"}) {
						@compose.Grid(compose.GridProps{Cols: "1-3", BoxProps: box.BoxProps{Class: "w-full items-center gap-4"}}) {
							@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "md:justify-self-start"}}) {
								@NavLinks(NavLinksProps{Links: vLinks, Current: vCurrent, Side: "left"})
							}
							@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "text-center"}}) {
								@MenuEntry(MenuEntryProps{Href: vBrandHref, Class: uiutils.Cnv("text-lg font-medium"), Testid: "brand"}) {
									{ uiutils.Text(vBrand) }
								}
							}
							@compose.Group(compose.GroupProps{Gap: "4", Align: "center", Justify: "end", BoxProps: box.BoxProps{Class: "flex-wrap md:justify-self-end"}}) {
								@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{}}) {
									@NavLinks(NavLinksProps{Links: vLinks, Current: vCurrent, Side: "right"})
								}
								@NavActions(NavActionsProps{Login: uiutils.Get(vActions, "login"), LoginHref: uiutils.Get(vActions, "loginHref"), Cta: uiutils.Get(vActions, "cta"), CtaHref: uiutils.Get(vActions, "href"), Actions: uiutils.Get(vActions, "mode"), Tone: vTone, ThemeLabel: uiutils.Get(vActions, "themeLabel")})
							}
						}
					}
				} else {
					@MenuEntry(MenuEntryProps{Href: vBrandHref, Class: uiutils.Cnv("text-lg font-medium"), Testid: "brand"}) {
						{ uiutils.Text(vBrand) }
					}
					if uiutils.Eq(vLayout, "search") {
						@SearchPalette(SearchPaletteProps{Label: uiutils.Get(vSearch, "label"), Shortcut: uiutils.Get(vSearch, "shortcut")})
					}
					@NavBarMenu(NavBarMenuProps{Label: vLabel, Links: vLinks, Current: vCurrent, LandmarkLabel: vLandmarkLabel})
					@NavActions(NavActionsProps{Login: uiutils.Get(vActions, "login"), LoginHref: uiutils.Get(vActions, "loginHref"), Cta: uiutils.Get(vActions, "cta"), CtaHref: uiutils.Get(vActions, "href"), Actions: uiutils.Get(vActions, "mode"), Tone: vTone, ThemeLabel: uiutils.Get(vActions, "themeLabel")})
				}
			}
		}
	}
}

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 nav-bar
blocks/nav-bar.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/nav-bar.json
    A top bar in four shapes. Axes: layout (inline: brand left, links, button right; split: the brand in the middle with the links on both sides; search: a search field with its shortcut in the middle), over (none, media: the bar sits over a picture, transparent), actions mode (none, cta), tone (default, inverse: on a dark hero band). Turning solid on scroll is a port contract.
    Props (p): label, brand, brandHref, links, current, actions, search, tone, layout, over, skip, landmarkLabel. -#}
{%- set v_label = (p.label ?? null) -%}
{%- 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_actions = (p.actions ?? null) -%}
{%- set v_search = (p.search ?? null) -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_layout = (p.layout ?? 'inline') -%}
{%- set v_over = (p.over ?? 'none') -%}
{%- set v_skip = (p.skip ?? null) -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_12 -%}
  {{ include('blocks/over-media.html.twig', {'p': {'on': og_eq(v_over, 'media'), 'alt': v_brand}}, with_context = false) }}
  {%- 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:inset-ring focus:inset-ring-border', 'attrs': og_attrs(['data-slot', 'skip-link']), 'children': c_1}, with_context = false) }}
  {%- endif %}
  {%- set c_11 -%}
    {%- set c_10 -%}
      {%- if og_t(og_eq(v_layout, 'split')) %}
        {%- set c_8 -%}
          {%- set c_7 -%}
            {%- set c_2 -%}
              {{ include('blocks/nav-links.html.twig', {'p': {'links': v_links, 'current': v_current, 'side': 'left'}}, with_context = false) }}
            {%- endset -%}
            {{ include('compose/Box.html.twig', {'class': 'md:justify-self-start', 'children': c_2}, with_context = false) }}
            {%- set c_4 -%}
              {%- set c_3 -%}
                {{ og_text(v_brand) }}
              {%- endset -%}
              {{ include('blocks/menu-entry.html.twig', {'p': {'href': v_brandHref, 'className': og_cnv(['text-lg font-medium']), 'testid': 'brand'}, 'children': og_markup(c_3)}, with_context = false) }}
            {%- endset -%}
            {{ include('compose/Box.html.twig', {'class': 'text-center', 'children': c_4}, with_context = false) }}
            {%- set c_6 -%}
              {%- set c_5 -%}
                {{ include('blocks/nav-links.html.twig', {'p': {'links': v_links, 'current': v_current, 'side': 'right'}}, with_context = false) }}
              {%- endset -%}
              {{ include('compose/Box.html.twig', {'children': c_5}, with_context = false) }}
              {{ include('blocks/nav-actions.html.twig', {'p': {'login': og_get(v_actions, ['login']), 'loginHref': og_get(v_actions, ['loginHref']), 'cta': og_get(v_actions, ['cta']), 'ctaHref': og_get(v_actions, ['href']), 'actions': og_get(v_actions, ['mode']), 'tone': v_tone, 'themeLabel': og_get(v_actions, ['themeLabel'])}}, with_context = false) }}
            {%- endset -%}
            {{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'justify': 'end', 'class': 'flex-wrap md:justify-self-end', 'children': c_6}, with_context = false) }}
          {%- endset -%}
          {{ include('compose/Grid.html.twig', {'cols': '1-3', 'class': 'w-full items-center gap-4', 'children': c_7}, with_context = false) }}
        {%- endset -%}
        {{ include('blocks/nav-block.html.twig', {'p': {'label': (og_t(v_landmarkLabel) ? og_uniq(og_tpl('{0}, {1}', [v_label, v_landmarkLabel])) : v_label), 'className': og_cnv(['w-full']), 'testid': 'site-nav'}, 'children': og_markup(c_8)}, with_context = false) }}
      {%- else %}
        {%- set c_9 -%}
          {{ og_text(v_brand) }}
        {%- endset -%}
        {{ include('blocks/menu-entry.html.twig', {'p': {'href': v_brandHref, 'className': og_cnv(['text-lg font-medium']), 'testid': 'brand'}, 'children': og_markup(c_9)}, with_context = false) }}
        {%- if og_t(og_eq(v_layout, 'search')) %}
          {{ include('blocks/search-palette.html.twig', {'p': {'label': og_get(v_search, ['label']), 'shortcut': og_get(v_search, ['shortcut'])}}, with_context = false) }}
        {%- endif %}
        {{ include('blocks/nav-bar-menu.html.twig', {'p': {'label': v_label, 'links': v_links, 'current': v_current, 'landmarkLabel': v_landmarkLabel}}, with_context = false) }}
        {{ include('blocks/nav-actions.html.twig', {'p': {'login': og_get(v_actions, ['login']), 'loginHref': og_get(v_actions, ['loginHref']), 'cta': og_get(v_actions, ['cta']), 'ctaHref': og_get(v_actions, ['href']), 'actions': og_get(v_actions, ['mode']), 'tone': v_tone, 'themeLabel': og_get(v_actions, ['themeLabel'])}}, with_context = false) }}
      {%- endif %}
    {%- endset -%}
    {{ include('compose/Box.html.twig', {'class': og_s(og_cnv(['flex flex-wrap items-center justify-between gap-4', 'py-4'])), 'children': c_10}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Container.html.twig', {'class': 'mx-auto w-full max-w-6xl px-4', 'attrs': og_attrs(['data-slot', 'container']), 'children': c_11}, with_context = false) }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'header', 'class': og_s(og_cnv(['relative', (og_t(og_eq(v_tone, 'inverse')) ? 'border-b border-transparent bg-foreground text-background [&_a]:text-background [&_button]:text-background' : 'border-b border-border bg-background'), (og_t(og_eq(v_over, 'media')) ? 'isolate overflow-hidden border-0 bg-transparent' : '')])), 'attrs': og_attrs(['data-layout', v_layout, 'data-tone', v_tone, 'aria-label', v_landmarkLabel, 'data-slot', 'nav-bar']), 'children': c_12}, 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 nav-bar
blocks/nav-bar.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/nav-bar.json
    A top bar in four shapes. Axes: layout (inline: brand left, links, button right; split: the brand in the middle with the links on both sides; search: a search field with its shortcut in the middle), over (none, media: the bar sits over a picture, transparent), actions mode (none, cta), tone (default, inverse: on a dark hero band). Turning solid on scroll is a port contract.
    Props (p): label, brand, brandHref, links, current, actions, search, tone, layout, over, skip, landmarkLabel. *}
{var $v_label = ($p['label'] ?? null)}
{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_actions = ($p['actions'] ?? null)}
{var $v_search = ($p['search'] ?? null)}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_layout = ($p['layout'] ?? 'inline')}
{var $v_over = ($p['over'] ?? 'none')}
{var $v_skip = ($p['skip'] ?? null)}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_12}
  {=og_include('blocks/over-media.latte', ['p' => ['on' => og_eq($v_over, 'media'), 'alt' => $v_brand]])|noescape}
  {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:inset-ring focus:inset-ring-border', 'attrs' => og_attrs(['data-slot', 'skip-link']), 'children' => (string) $c_1])|noescape}
  {/if}
  {capture $c_11}
    {capture $c_10}
      {if og_t(og_eq($v_layout, 'split'))}
        {capture $c_8}
          {capture $c_7}
            {capture $c_2}
              {=og_include('blocks/nav-links.latte', ['p' => ['links' => $v_links, 'current' => $v_current, 'side' => 'left']])|noescape}
            {/capture}
            {=og_include('compose/Box.latte', ['class' => 'md:justify-self-start', 'children' => (string) $c_2])|noescape}
            {capture $c_4}
              {capture $c_3}
                {=og_text($v_brand)}
              {/capture}
              {=og_include('blocks/menu-entry.latte', ['p' => ['href' => $v_brandHref, 'className' => og_cnv(['text-lg font-medium']), 'testid' => 'brand'], 'children' => og_markup($c_3)])|noescape}
            {/capture}
            {=og_include('compose/Box.latte', ['class' => 'text-center', 'children' => (string) $c_4])|noescape}
            {capture $c_6}
              {capture $c_5}
                {=og_include('blocks/nav-links.latte', ['p' => ['links' => $v_links, 'current' => $v_current, 'side' => 'right']])|noescape}
              {/capture}
              {=og_include('compose/Box.latte', ['children' => (string) $c_5])|noescape}
              {=og_include('blocks/nav-actions.latte', ['p' => ['login' => og_get($v_actions, ['login']), 'loginHref' => og_get($v_actions, ['loginHref']), 'cta' => og_get($v_actions, ['cta']), 'ctaHref' => og_get($v_actions, ['href']), 'actions' => og_get($v_actions, ['mode']), 'tone' => $v_tone, 'themeLabel' => og_get($v_actions, ['themeLabel'])]])|noescape}
            {/capture}
            {=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'justify' => 'end', 'class' => 'flex-wrap md:justify-self-end', 'children' => (string) $c_6])|noescape}
          {/capture}
          {=og_include('compose/Grid.latte', ['cols' => '1-3', 'class' => 'w-full items-center gap-4', 'children' => (string) $c_7])|noescape}
        {/capture}
        {=og_include('blocks/nav-block.latte', ['p' => ['label' => (og_t($v_landmarkLabel) ? og_uniq(og_tpl('{0}, {1}', [$v_label, $v_landmarkLabel])) : $v_label), 'className' => og_cnv(['w-full']), 'testid' => 'site-nav'], 'children' => og_markup($c_8)])|noescape}
      {else}
        {capture $c_9}
          {=og_text($v_brand)}
        {/capture}
        {=og_include('blocks/menu-entry.latte', ['p' => ['href' => $v_brandHref, 'className' => og_cnv(['text-lg font-medium']), 'testid' => 'brand'], 'children' => og_markup($c_9)])|noescape}
        {if og_t(og_eq($v_layout, 'search'))}
          {=og_include('blocks/search-palette.latte', ['p' => ['label' => og_get($v_search, ['label']), 'shortcut' => og_get($v_search, ['shortcut'])]])|noescape}
        {/if}
        {=og_include('blocks/nav-bar-menu.latte', ['p' => ['label' => $v_label, 'links' => $v_links, 'current' => $v_current, 'landmarkLabel' => $v_landmarkLabel]])|noescape}
        {=og_include('blocks/nav-actions.latte', ['p' => ['login' => og_get($v_actions, ['login']), 'loginHref' => og_get($v_actions, ['loginHref']), 'cta' => og_get($v_actions, ['cta']), 'ctaHref' => og_get($v_actions, ['href']), 'actions' => og_get($v_actions, ['mode']), 'tone' => $v_tone, 'themeLabel' => og_get($v_actions, ['themeLabel'])]])|noescape}
      {/if}
    {/capture}
    {=og_include('compose/Box.latte', ['class' => og_s(og_cnv(['flex flex-wrap items-center justify-between gap-4', 'py-4'])), 'children' => (string) $c_10])|noescape}
  {/capture}
  {=og_include('compose/Container.latte', ['class' => 'mx-auto w-full max-w-6xl px-4', 'attrs' => og_attrs(['data-slot', 'container']), 'children' => (string) $c_11])|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'header', 'class' => og_s(og_cnv(['relative', (og_t(og_eq($v_tone, 'inverse')) ? 'border-b border-transparent bg-foreground text-background [&_a]:text-background [&_button]:text-background' : 'border-b border-border bg-background'), (og_t(og_eq($v_over, 'media')) ? 'isolate overflow-hidden border-0 bg-transparent' : '')])), 'attrs' => og_attrs(['data-layout', $v_layout, 'data-tone', $v_tone, 'aria-label', $v_landmarkLabel, 'data-slot', 'nav-bar']), 'children' => (string) $c_12])|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 nav-bar
blocks/nav-bar.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/nav-bar.json
    A top bar in four shapes. Axes: layout (inline: brand left, links, button right; split: the brand in the middle with the links on both sides; search: a search field with its shortcut in the middle), over (none, media: the bar sits over a picture, transparent), actions mode (none, cta), tone (default, inverse: on a dark hero band). Turning solid on scroll is a port contract.
    Props (p): label, brand, brandHref, links, current, actions, search, tone, layout, over, skip, landmarkLabel. -#}
{%- set v_label = og_def(p['label'], none) -%}
{%- 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_actions = og_def(p['actions'], none) -%}
{%- set v_search = og_def(p['search'], none) -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_layout = og_def(p['layout'], 'inline') -%}
{%- set v_over = og_def(p['over'], 'none') -%}
{%- set v_skip = og_def(p['skip'], none) -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_12 -%}
  {{ og_include('blocks/over-media.html.j2', {'p': {'on': og_eq(v_over, 'media'), 'alt': v_brand}}) }}
  {%- 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:inset-ring focus:inset-ring-border', 'Attrs': og_attrs(['data-slot', 'skip-link'])}, 'children': c_1}) }}
  {%- endif %}
  {%- set c_11 -%}
    {%- set c_10 -%}
      {%- if og_t(og_eq(v_layout, 'split')) %}
        {%- set c_8 -%}
          {%- set c_7 -%}
            {%- set c_2 -%}
              {{ og_include('blocks/nav-links.html.j2', {'p': {'links': v_links, 'current': v_current, 'side': 'left'}}) }}
            {%- endset -%}
            {{ og_include('compose/box.html.j2', {'p': {'Class': 'md:justify-self-start'}, 'children': c_2}) }}
            {%- set c_4 -%}
              {%- set c_3 -%}
                {{ og_text(v_brand) }}
              {%- endset -%}
              {{ og_include('blocks/menu-entry.html.j2', {'p': {'href': v_brandHref, 'className': og_cnv(['text-lg font-medium']), 'testid': 'brand'}, 'children': og_markup(c_3)}) }}
            {%- endset -%}
            {{ og_include('compose/box.html.j2', {'p': {'Class': 'text-center'}, 'children': c_4}) }}
            {%- set c_6 -%}
              {%- set c_5 -%}
                {{ og_include('blocks/nav-links.html.j2', {'p': {'links': v_links, 'current': v_current, 'side': 'right'}}) }}
              {%- endset -%}
              {{ og_include('compose/box.html.j2', {'p': {}, 'children': c_5}) }}
              {{ og_include('blocks/nav-actions.html.j2', {'p': {'login': og_get(v_actions, ['login']), 'loginHref': og_get(v_actions, ['loginHref']), 'cta': og_get(v_actions, ['cta']), 'ctaHref': og_get(v_actions, ['href']), 'actions': og_get(v_actions, ['mode']), 'tone': v_tone, 'themeLabel': og_get(v_actions, ['themeLabel'])}}) }}
            {%- endset -%}
            {{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Justify': 'end', 'Class': 'flex-wrap md:justify-self-end'}, 'children': c_6}) }}
          {%- endset -%}
          {{ og_include('compose/grid.html.j2', {'p': {'Cols': '1-3', 'Class': 'w-full items-center gap-4'}, 'children': c_7}) }}
        {%- endset -%}
        {{ og_include('blocks/nav-block.html.j2', {'p': {'label': (og_uniq(og_tpl('{0}, {1}', [v_label, v_landmarkLabel])) if og_t(v_landmarkLabel) else v_label), 'className': og_cnv(['w-full']), 'testid': 'site-nav'}, 'children': og_markup(c_8)}) }}
      {%- else %}
        {%- set c_9 -%}
          {{ og_text(v_brand) }}
        {%- endset -%}
        {{ og_include('blocks/menu-entry.html.j2', {'p': {'href': v_brandHref, 'className': og_cnv(['text-lg font-medium']), 'testid': 'brand'}, 'children': og_markup(c_9)}) }}
        {%- if og_t(og_eq(v_layout, 'search')) %}
          {{ og_include('blocks/search-palette.html.j2', {'p': {'label': og_get(v_search, ['label']), 'shortcut': og_get(v_search, ['shortcut'])}}) }}
        {%- endif %}
        {{ og_include('blocks/nav-bar-menu.html.j2', {'p': {'label': v_label, 'links': v_links, 'current': v_current, 'landmarkLabel': v_landmarkLabel}}) }}
        {{ og_include('blocks/nav-actions.html.j2', {'p': {'login': og_get(v_actions, ['login']), 'loginHref': og_get(v_actions, ['loginHref']), 'cta': og_get(v_actions, ['cta']), 'ctaHref': og_get(v_actions, ['href']), 'actions': og_get(v_actions, ['mode']), 'tone': v_tone, 'themeLabel': og_get(v_actions, ['themeLabel'])}}) }}
      {%- endif %}
    {%- endset -%}
    {{ og_include('compose/box.html.j2', {'p': {'Class': og_s(og_cnv(['flex flex-wrap items-center justify-between gap-4', 'py-4']))}, 'children': c_10}) }}
  {%- endset -%}
  {{ og_include('compose/container.html.j2', {'p': {'Class': 'mx-auto w-full max-w-6xl px-4', 'Attrs': og_attrs(['data-slot', 'container'])}, 'children': c_11}) }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'header', 'Class': og_s(og_cnv(['relative', ('border-b border-transparent bg-foreground text-background [&_a]:text-background [&_button]:text-background' if og_t(og_eq(v_tone, 'inverse')) else 'border-b border-border bg-background'), ('isolate overflow-hidden border-0 bg-transparent' if og_t(og_eq(v_over, 'media')) else '')])), 'Attrs': og_attrs(['data-layout', v_layout, 'data-tone', v_tone, 'aria-label', v_landmarkLabel, 'data-slot', 'nav-bar'])}, 'children': c_12}) }}

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.

A top bar in four shapes. Axes: layout (inline: brand left, links, button right; split: the brand in the middle with the links on both sides; search: a search field with its shortcut in the middle), over (none, media: the bar sits over a picture, transparent), actions mode (none, cta), tone (default, inverse: on a dark hero band). Turning solid on scroll is a port contract.

Props of NavBar
PropTypeDefault Description
label (required)string-accessible name of the navigation
brand (required)string-
brandHref string-the address of the home page; none: the brand is text, not a link
links (required)NavLink[]-
current string""id of the current link
actions NavBarActions-the buttons at the end of the bar
search (required)NavSearch-the search field of layout search
tone "default" | "inverse""default"inverse: sits on a dark hero band
layout "inline" | "split" | "search""inline"
over "none" | "media""none"
skip string-text of the skip link to the main content; none: no link
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