Skip to content
ui8kit

component / components

Shell Topbar

Shell Topbar component

Install

npx ui8kit add shell-topbar

Pulls in: block, box, compose, dashboard-shell, group, inline, kit-box, kit-text, list, list-item, lucide-icon, media-frame, menu-entry, nav-block, search-palette, text, utils

Preview

Northwind

Ctrl K

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 shell-topbar
components/shell-topbar.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 top bar of DashboardShell: the brand (when no sidebar carries it), the links (when there is no sidebar),
  an optional search field, and the signed-in person.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { ShellNav } from "../blocks/dashboard-shell.types";

  export type ShellTopbarProps = {
    nav: ShellNav;
    brand?: "show" | "hide";
    links?: "show" | "hide";
    search?: "show" | "hide";
    landmarkLabel?: string;
  };
</script>

<script lang="ts">
  import Block from "../compose/Block.svelte";
  import Box from "../compose/Box.svelte";
  import Group from "../compose/Group.svelte";
  import Inline from "../compose/Inline.svelte";
  import List from "../compose/List.svelte";
  import ListItem from "../compose/ListItem.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";
  import Text from "../compose/Text.svelte";
  import MediaFrame from "../components/media-frame.svelte";
  import MenuEntry from "../components/menu-entry.svelte";
  import NavBlock from "../components/nav-block.svelte";
  import SearchPalette from "../components/search-palette.svelte";
  import { cn, tpl, uniqLabel } from "../utils";

  let { nav, brand = "show", links = "hide", search = "show", landmarkLabel }: ShellTopbarProps = $props();
</script>

<Block
  tag="header"
  class="flex h-16 shrink-0 items-center gap-6 border-b border-border bg-background px-6"
  aria-label={landmarkLabel}
  data-slot="topbar"
>
  {#if ((brand as string) === "show")}
    <Group gap="2" align="center" class="shrink-0" data-slot="brand">
      <LucideIcon name="layers" size={24} />
      <Text size="base" weight="bold" class={(true ? "" : "sr-only")}>
        {nav.brand}
      </Text>
    </Group>
  {/if}
  {#if (((links as string) === "show") && ((nav.links?.length ?? 0) > 0))}
    <NavBlock
      label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", nav.label, landmarkLabel)) : nav.label)}
      class="hidden lg:block"
    >
      <List class="m-0 flex list-none items-center gap-2 p-0">
        {#each nav.links as l (l.id)}
          <ListItem data-slot="links-row">
            <MenuEntry
              href={l.href}
              class={cn(
                "flex items-center gap-4 rounded py-2 text-sm",
                (true ? "px-4" : "justify-center px-2"),
                ((l.id === nav.current) ? "bg-muted font-medium" : "")
              )}
              current={(l.id === nav.current)}
              size="sm"
              testid="item"
            >
              <LucideIcon name={l.icon} size={16} />
              <Inline class={(true ? "" : "sr-only")}>
                {l.name}
              </Inline>
            </MenuEntry>
          </ListItem>
        {/each}
      </List>
    </NavBlock>
  {/if}
  {#if ((search as string) === "show")}
    {#if ((links as string) === "show")}
      <Box class="ml-auto hidden w-64 shrink-0 xl:block">
        <SearchPalette label={nav.search} shortcut={nav.shortcut} />
      </Box>
    {:else}
      <SearchPalette label={nav.search} shortcut={nav.shortcut} />
    {/if}
  {/if}
  <Group
    gap="4"
    align="center"
    class={
      ((links as string) === "show") && ((search as string) === "show") ? "shrink-0"
      : "ml-auto shrink-0"
    }
    data-slot="user"
  >
    <LucideIcon name="bell" size={20} class="text-muted-foreground" />
    <MediaFrame alt={nav.userName} ratio="1/1" class="size-8 shrink-0 rounded-full" />
  </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 shell-topbar
components/shell-topbar.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 top bar of DashboardShell: the brand (when no sidebar carries it), the links (when there is no sidebar),
 * an optional search field, and the signed-in person.
 */
import { type ReactNode } from "react";
import { Block, Box, Group, Inline, List, ListItem, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { MediaFrame } from "../components/media-frame";
import { MenuEntry } from "../components/menu-entry";
import { NavBlock } from "../components/nav-block";
import { SearchPalette } from "../components/search-palette";
import { cn, tpl, uniqLabel } from "../utils";
import type { ShellNav } from "../blocks/dashboard-shell.types";

export type ShellTopbarProps = {
  nav: ShellNav;
  brand?: "show" | "hide";
  links?: "show" | "hide";
  search?: "show" | "hide";
  landmarkLabel?: string;
};

export function ShellTopbar({
  nav,
  brand = "show",
  links = "hide",
  search = "show",
  landmarkLabel,
}: ShellTopbarProps) {
  return (
    <Block
      tag="header"
      className="flex h-16 shrink-0 items-center gap-6 border-b border-border bg-background px-6"
      aria-label={landmarkLabel}
      data-slot="topbar"
    >
      {((brand as string) === "show") ? (
        <Group gap="2" align="center" className="shrink-0" data-slot="brand">
          <LucideIcon name="layers" size={24} />
          <Text size="base" weight="bold" className={(true ? "" : "sr-only")}>
            {nav.brand}
          </Text>
        </Group>
      ) : null}
      {(((links as string) === "show") && ((nav.links?.length ?? 0) > 0)) ? (
        <NavBlock
          label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", nav.label, landmarkLabel)) : nav.label)}
          className="hidden lg:block"
        >
          <List className="m-0 flex list-none items-center gap-2 p-0">
            {(nav.links ?? []).map((l) => (
              <ListItem key={l.id} data-slot="links-row">
                <MenuEntry
                  href={l.href}
                  className={cn(
                    "flex items-center gap-4 rounded py-2 text-sm",
                    (true ? "px-4" : "justify-center px-2"),
                    ((l.id === nav.current) ? "bg-muted font-medium" : "")
                  )}
                  current={(l.id === nav.current)}
                  size="sm"
                  testid="item"
                >
                  <LucideIcon name={l.icon} size={16} />
                  <Inline className={(true ? "" : "sr-only")}>
                    {l.name}
                  </Inline>
                </MenuEntry>
              </ListItem>
            ))}
          </List>
        </NavBlock>
      ) : null}
      {((search as string) === "show") ? (
        <>
          {((links as string) === "show") ? (
            <Box className="ml-auto hidden w-64 shrink-0 xl:block">
              <SearchPalette label={nav.search} shortcut={nav.shortcut} />
            </Box>
          ) : (
            <SearchPalette label={nav.search} shortcut={nav.shortcut} />
          )}
        </>
      ) : null}
      <Group
        gap="4"
        align="center"
        className={
          ((links as string) === "show") && ((search as string) === "show") ? "shrink-0"
          : "ml-auto shrink-0"
        }
        data-slot="user"
      >
        <LucideIcon name="bell" size={20} className="text-muted-foreground" />
        <MediaFrame alt={nav.userName} ratio="1/1" className="size-8 shrink-0 rounded-full" />
      </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 shell-topbar
components/shell-topbar.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 top bar of DashboardShell: the brand (when no sidebar carries it), the links (when there is no sidebar),
  an optional search field, and the signed-in person.
-->
<script lang="ts">
import type { ShellNav } from "../blocks/dashboard-shell.types";

export type ShellTopbarProps = {
  nav: ShellNav;
  brand?: "show" | "hide";
  links?: "show" | "hide";
  search?: "show" | "hide";
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Block from "../compose/Block.vue";
import Box from "../compose/Box.vue";
import Group from "../compose/Group.vue";
import Inline from "../compose/Inline.vue";
import List from "../compose/List.vue";
import ListItem from "../compose/ListItem.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Text from "../compose/Text.vue";
import MediaFrame from "../components/media-frame.vue";
import MenuEntry from "../components/menu-entry.vue";
import NavBlock from "../components/nav-block.vue";
import SearchPalette from "../components/search-palette.vue";
import { cn, tpl, uniqLabel } from "../utils";

const {
  nav,
  brand = "show",
  links = "hide",
  search = "show",
  landmarkLabel,
} = defineProps<ShellTopbarProps>();
</script>

<template>
  <Block
    tag="header"
    class="flex h-16 shrink-0 items-center gap-6 border-b border-border bg-background px-6"
    :aria-label="landmarkLabel"
    data-slot="topbar"
  >
    <Group v-if="((brand as string) === 'show')" gap="2" align="center" class="shrink-0" data-slot="brand">
      <LucideIcon name="layers" :size="24" />
      <Text size="base" weight="bold" :class="(true ? '' : 'sr-only')">
        {{ nav.brand }}
      </Text>
    </Group>
    <NavBlock v-if="(((links as string) === 'show') && ((nav.links?.length ?? 0) > 0))"
      :label="(landmarkLabel ? uniqLabel(tpl('{0}, {1}', nav.label, landmarkLabel)) : nav.label)"
      class="hidden lg:block"
    >
      <List class="m-0 flex list-none items-center gap-2 p-0">
        <ListItem v-for="l in nav.links" :key="l.id" data-slot="links-row">
          <MenuEntry
            :href="l.href"
            :class="cn(
              'flex items-center gap-4 rounded py-2 text-sm',
              (true ? 'px-4' : 'justify-center px-2'),
              ((l.id === nav.current) ? 'bg-muted font-medium' : '')
            )"
            :current="(l.id === nav.current)"
            size="sm"
            testid="item"
          >
            <LucideIcon :name="l.icon" :size="16" />
            <Inline :class="(true ? '' : 'sr-only')">
              {{ l.name }}
            </Inline>
          </MenuEntry>
        </ListItem>
      </List>
    </NavBlock>
    <template v-if="((search as string) === 'show')">
      <Box v-if="((links as string) === 'show')" class="ml-auto hidden w-64 shrink-0 xl:block">
        <SearchPalette :label="nav.search" :shortcut="nav.shortcut" />
      </Box>
      <SearchPalette v-else :label="nav.search" :shortcut="nav.shortcut" />
    </template>
    <Group
      gap="4"
      align="center"
      :class="
        ((links as string) === 'show') && ((search as string) === 'show') ? 'shrink-0'
        : 'ml-auto shrink-0'
      "
      data-slot="user"
    >
      <LucideIcon name="bell" :size="20" class="text-muted-foreground" />
      <MediaFrame :alt="nav.userName" ratio="1/1" class="size-8 shrink-0 rounded-full" />
    </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 shell-topbar
components/shell-topbar.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 top bar of DashboardShell: the brand (when no sidebar carries it), the links (when there is no sidebar),
 * an optional search field, and the signed-in person.
 */
import { For, type JSX } from "solid-js";
import { Block, Box, Group, Inline, List, ListItem, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { MediaFrame } from "../components/media-frame";
import { MenuEntry } from "../components/menu-entry";
import { NavBlock } from "../components/nav-block";
import { SearchPalette } from "../components/search-palette";
import { cn, tpl, uniqLabel } from "../utils";
import type { ShellNav } from "../blocks/dashboard-shell.types";

export type ShellTopbarProps = {
  nav: ShellNav;
  brand?: "show" | "hide";
  links?: "show" | "hide";
  search?: "show" | "hide";
  landmarkLabel?: string;
};

export function ShellTopbar({
  nav,
  brand = "show",
  links = "hide",
  search = "show",
  landmarkLabel,
}: ShellTopbarProps) {
  return (
    <Block
      tag="header"
      class="flex h-16 shrink-0 items-center gap-6 border-b border-border bg-background px-6"
      aria-label={landmarkLabel}
      data-slot="topbar"
    >
      {((brand as string) === "show") ? (
        <Group gap="2" align="center" class="shrink-0" data-slot="brand">
          <LucideIcon name="layers" size={24} />
          <Text size="base" weight="bold" class={(true ? "" : "sr-only")}>
            {nav.brand}
          </Text>
        </Group>
      ) : null}
      {(((links as string) === "show") && ((nav.links?.length ?? 0) > 0)) ? (
        <NavBlock
          label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", nav.label, landmarkLabel)) : nav.label)}
          class="hidden lg:block"
        >
          <List class="m-0 flex list-none items-center gap-2 p-0">
            <For each={nav.links ?? []}>{(l) => (
              <ListItem data-slot="links-row">
                <MenuEntry
                  href={l.href}
                  class={cn(
                    "flex items-center gap-4 rounded py-2 text-sm",
                    (true ? "px-4" : "justify-center px-2"),
                    ((l.id === nav.current) ? "bg-muted font-medium" : "")
                  )}
                  current={(l.id === nav.current)}
                  size="sm"
                  testid="item"
                >
                  <LucideIcon name={l.icon} size={16} />
                  <Inline class={(true ? "" : "sr-only")}>
                    {l.name}
                  </Inline>
                </MenuEntry>
              </ListItem>
            )}</For>
          </List>
        </NavBlock>
      ) : null}
      {((search as string) === "show") ? (
        <>
          {((links as string) === "show") ? (
            <Box class="ml-auto hidden w-64 shrink-0 xl:block">
              <SearchPalette label={nav.search} shortcut={nav.shortcut} />
            </Box>
          ) : (
            <SearchPalette label={nav.search} shortcut={nav.shortcut} />
          )}
        </>
      ) : null}
      <Group
        gap="4"
        align="center"
        class={
          ((links as string) === "show") && ((search as string) === "show") ? "shrink-0"
          : "ml-auto shrink-0"
        }
        data-slot="user"
      >
        <LucideIcon name="bell" size={20} class="text-muted-foreground" />
        <MediaFrame alt={nav.userName} ratio="1/1" class="size-8 shrink-0 rounded-full" />
      </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 shell-topbar
blocks/shell-topbar.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/shell-topbar.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/icons"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// ShellTopbarProps are the props of ShellTopbar; the values are the JSON shapes of the TypeScript props.
type ShellTopbarProps struct {
	Nav any `json:"nav"`
	Brand any `json:"brand"`
	Links any `json:"links"`
	Search any `json:"search"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// The top bar of DashboardShell: the brand (when no sidebar carries it), the links (when there is no sidebar), an optional search field, and the signed-in person.
templ ShellTopbar(p ShellTopbarProps) {
	{{ vNav := p.Nav }}
	{{ vBrand := uiutils.Def(p.Brand, "show") }}
	{{ vLinks := uiutils.Def(p.Links, "hide") }}
	{{ vSearch := uiutils.Def(p.Search, "show") }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "header", Class: "flex h-16 shrink-0 items-center gap-6 border-b border-border bg-background px-6", Attrs: uiutils.Attrs("aria-label", vLandmarkLabel, "data-slot", "topbar")}}) {
		if uiutils.Eq(vBrand, "show") {
			@compose.Group(compose.GroupProps{Gap: "2", Align: "center", BoxProps: box.BoxProps{Class: "shrink-0", Attrs: uiutils.Attrs("data-slot", "brand")}}) {
				@icons.LucideIcon(icons.LucideIconProps{Name: "layers", Size: 24})
				@compose.Text(compose.TextProps{Size: "base", Weight: "bold", TextProps: text.TextProps{Class: uiutils.S(uiutils.Cond(uiutils.T(true), "", "sr-only"))}}) {
					{ uiutils.Text(uiutils.Get(vNav, "brand")) }
				}
			}
		}
		if uiutils.T(uiutils.And(uiutils.Eq(vLinks, "show"), uiutils.Gt(uiutils.Len(uiutils.Get(vNav, "links")), float64(0)))) {
			@NavBlock(NavBlockProps{Label: uiutils.Cond(uiutils.T(vLandmarkLabel), uiutils.Uniq(uiutils.Tpl("{0}, {1}", uiutils.Get(vNav, "label"), vLandmarkLabel)), uiutils.Get(vNav, "label")), Class: uiutils.Cnv("hidden lg:block")}) {
				@compose.List(compose.ListProps{BoxProps: box.BoxProps{Class: "m-0 flex list-none items-center gap-2 p-0"}}) {
					for _, vL := range uiutils.L(uiutils.Get(vNav, "links")) {
						@compose.ListItem(compose.ListItemProps{BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "links-row")}}) {
							@MenuEntry(MenuEntryProps{Href: uiutils.Get(vL, "href"), Class: uiutils.Cnv(uiutils.Cnv("flex items-center gap-4 rounded py-2 text-sm", uiutils.Cond(uiutils.T(true), "px-4", "justify-center px-2"), uiutils.Cond(uiutils.T(uiutils.Eq(uiutils.Get(vL, "id"), uiutils.Get(vNav, "current"))), "bg-muted font-medium", ""))), Current: uiutils.Eq(uiutils.Get(vL, "id"), uiutils.Get(vNav, "current")), Size: "sm", Testid: "item"}) {
								@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(uiutils.Get(vL, "icon")), Size: 16})
								@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: uiutils.S(uiutils.Cond(uiutils.T(true), "", "sr-only"))}}) {
									{ uiutils.Text(uiutils.Get(vL, "name")) }
								}
							}
						}
					}
				}
			}
		}
		if uiutils.Eq(vSearch, "show") {
			if uiutils.Eq(vLinks, "show") {
				@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "ml-auto hidden w-64 shrink-0 xl:block"}}) {
					@SearchPalette(SearchPaletteProps{Label: uiutils.Get(vNav, "search"), Shortcut: uiutils.Get(vNav, "shortcut")})
				}
			} else {
				@SearchPalette(SearchPaletteProps{Label: uiutils.Get(vNav, "search"), Shortcut: uiutils.Get(vNav, "shortcut")})
			}
		}
		@compose.Group(compose.GroupProps{Gap: "4", Align: "center", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.And(uiutils.Eq(vLinks, "show"), uiutils.Eq(vSearch, "show"))), "shrink-0", "ml-auto shrink-0")), Attrs: uiutils.Attrs("data-slot", "user")}}) {
			@icons.LucideIcon(icons.LucideIconProps{Name: "bell", Size: 20, Class: "text-muted-foreground"})
			@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vNav, "userName"), Ratio: "1/1", Class: uiutils.Cnv("size-8 shrink-0 rounded-full")})
		}
	}
}

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 shell-topbar
blocks/shell-topbar.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/shell-topbar.json
    The top bar of DashboardShell: the brand (when no sidebar carries it), the links (when there is no sidebar), an optional search field, and the signed-in person.
    Props (p): nav, brand, links, search, landmarkLabel. -#}
{%- set v_nav = (p.nav ?? null) -%}
{%- set v_brand = (p.brand ?? 'show') -%}
{%- set v_links = (p.links ?? 'hide') -%}
{%- set v_search = (p.search ?? 'show') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_10 -%}
  {%- if og_t(og_eq(v_brand, 'show')) %}
    {%- set c_2 -%}
      {{ include('icons/LucideIcon.html.twig', {'name': 'layers', 'size': 24}, with_context = false) }}
      {%- set c_1 -%}
        {{ og_text(og_get(v_nav, ['brand'])) }}
      {%- endset -%}
      {{ include('compose/Text.html.twig', {'size': 'base', 'weight': 'bold', 'class': og_s((og_t(true) ? '' : 'sr-only')), 'children': c_1}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Group.html.twig', {'gap': '2', 'align': 'center', 'class': 'shrink-0', 'attrs': og_attrs(['data-slot', 'brand']), 'children': c_2}, with_context = false) }}
  {%- endif %}
  {%- if og_t(og_and([og_eq(v_links, 'show'), og_gt(og_len(og_get(v_nav, ['links'])), 0)])) %}
    {%- set c_7 -%}
      {%- set c_6 -%}
        {%- for v_l in og_l(og_get(v_nav, ['links'])) %}
          {%- set c_5 -%}
            {%- set c_4 -%}
              {{ include('icons/LucideIcon.html.twig', {'name': og_s(og_get(v_l, ['icon'])), 'size': 16}, with_context = false) }}
              {%- set c_3 -%}
                {{ og_text(og_get(v_l, ['name'])) }}
              {%- endset -%}
              {{ include('compose/Inline.html.twig', {'class': og_s((og_t(true) ? '' : 'sr-only')), 'children': c_3}, with_context = false) }}
            {%- endset -%}
            {{ include('blocks/menu-entry.html.twig', {'p': {'href': og_get(v_l, ['href']), 'className': og_cnv([og_cnv(['flex items-center gap-4 rounded py-2 text-sm', (og_t(true) ? 'px-4' : 'justify-center px-2'), (og_t(og_eq(og_get(v_l, ['id']), og_get(v_nav, ['current']))) ? 'bg-muted font-medium' : '')])]), 'current': og_eq(og_get(v_l, ['id']), og_get(v_nav, ['current'])), 'size': 'sm', 'testid': 'item'}, 'children': og_markup(c_4)}, with_context = false) }}
          {%- endset -%}
          {{ include('compose/ListItem.html.twig', {'attrs': og_attrs(['data-slot', 'links-row']), 'children': c_5}, with_context = false) }}
        {%- endfor %}
      {%- endset -%}
      {{ include('compose/List.html.twig', {'class': 'm-0 flex list-none items-center gap-2 p-0', 'children': c_6}, 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_nav, ['label']), v_landmarkLabel])) : og_get(v_nav, ['label'])), 'className': og_cnv(['hidden lg:block'])}, 'children': og_markup(c_7)}, with_context = false) }}
  {%- endif %}
  {%- if og_t(og_eq(v_search, 'show')) %}
    {%- if og_t(og_eq(v_links, 'show')) %}
      {%- set c_8 -%}
        {{ include('blocks/search-palette.html.twig', {'p': {'label': og_get(v_nav, ['search']), 'shortcut': og_get(v_nav, ['shortcut'])}}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Box.html.twig', {'class': 'ml-auto hidden w-64 shrink-0 xl:block', 'children': c_8}, with_context = false) }}
    {%- else %}
      {{ include('blocks/search-palette.html.twig', {'p': {'label': og_get(v_nav, ['search']), 'shortcut': og_get(v_nav, ['shortcut'])}}, with_context = false) }}
    {%- endif %}
  {%- endif %}
  {%- set c_9 -%}
    {{ include('icons/LucideIcon.html.twig', {'name': 'bell', 'size': 20, 'class': 'text-muted-foreground'}, with_context = false) }}
    {{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_nav, ['userName']), 'ratio': '1/1', 'className': og_cnv(['size-8 shrink-0 rounded-full'])}}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'class': og_s((og_t(og_and([og_eq(v_links, 'show'), og_eq(v_search, 'show')])) ? 'shrink-0' : 'ml-auto shrink-0')), 'attrs': og_attrs(['data-slot', 'user']), 'children': c_9}, with_context = false) }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'header', 'class': 'flex h-16 shrink-0 items-center gap-6 border-b border-border bg-background px-6', 'attrs': og_attrs(['aria-label', v_landmarkLabel, 'data-slot', 'topbar']), '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 shell-topbar
blocks/shell-topbar.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/shell-topbar.json
    The top bar of DashboardShell: the brand (when no sidebar carries it), the links (when there is no sidebar), an optional search field, and the signed-in person.
    Props (p): nav, brand, links, search, landmarkLabel. *}
{var $v_nav = ($p['nav'] ?? null)}
{var $v_brand = ($p['brand'] ?? 'show')}
{var $v_links = ($p['links'] ?? 'hide')}
{var $v_search = ($p['search'] ?? 'show')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_10}
  {if og_t(og_eq($v_brand, 'show'))}
    {capture $c_2}
      {=og_include('icons/LucideIcon.latte', ['name' => 'layers', 'size' => 24])|noescape}
      {capture $c_1}
        {=og_text(og_get($v_nav, ['brand']))}
      {/capture}
      {=og_include('compose/Text.latte', ['size' => 'base', 'weight' => 'bold', 'class' => og_s((og_t(true) ? '' : 'sr-only')), 'children' => (string) $c_1])|noescape}
    {/capture}
    {=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'center', 'class' => 'shrink-0', 'attrs' => og_attrs(['data-slot', 'brand']), 'children' => (string) $c_2])|noescape}
  {/if}
  {if og_t(og_and([og_eq($v_links, 'show'), og_gt(og_len(og_get($v_nav, ['links'])), 0)]))}
    {capture $c_7}
      {capture $c_6}
        {foreach og_l(og_get($v_nav, ['links'])) as $v_l}
          {capture $c_5}
            {capture $c_4}
              {=og_include('icons/LucideIcon.latte', ['name' => og_s(og_get($v_l, ['icon'])), 'size' => 16])|noescape}
              {capture $c_3}
                {=og_text(og_get($v_l, ['name']))}
              {/capture}
              {=og_include('compose/Inline.latte', ['class' => og_s((og_t(true) ? '' : 'sr-only')), 'children' => (string) $c_3])|noescape}
            {/capture}
            {=og_include('blocks/menu-entry.latte', ['p' => ['href' => og_get($v_l, ['href']), 'className' => og_cnv([og_cnv(['flex items-center gap-4 rounded py-2 text-sm', (og_t(true) ? 'px-4' : 'justify-center px-2'), (og_t(og_eq(og_get($v_l, ['id']), og_get($v_nav, ['current']))) ? 'bg-muted font-medium' : '')])]), 'current' => og_eq(og_get($v_l, ['id']), og_get($v_nav, ['current'])), 'size' => 'sm', 'testid' => 'item'], 'children' => og_markup($c_4)])|noescape}
          {/capture}
          {=og_include('compose/ListItem.latte', ['attrs' => og_attrs(['data-slot', 'links-row']), 'children' => (string) $c_5])|noescape}
        {/foreach}
      {/capture}
      {=og_include('compose/List.latte', ['class' => 'm-0 flex list-none items-center gap-2 p-0', 'children' => (string) $c_6])|noescape}
    {/capture}
    {=og_include('blocks/nav-block.latte', ['p' => ['label' => (og_t($v_landmarkLabel) ? og_uniq(og_tpl('{0}, {1}', [og_get($v_nav, ['label']), $v_landmarkLabel])) : og_get($v_nav, ['label'])), 'className' => og_cnv(['hidden lg:block'])], 'children' => og_markup($c_7)])|noescape}
  {/if}
  {if og_t(og_eq($v_search, 'show'))}
    {if og_t(og_eq($v_links, 'show'))}
      {capture $c_8}
        {=og_include('blocks/search-palette.latte', ['p' => ['label' => og_get($v_nav, ['search']), 'shortcut' => og_get($v_nav, ['shortcut'])]])|noescape}
      {/capture}
      {=og_include('compose/Box.latte', ['class' => 'ml-auto hidden w-64 shrink-0 xl:block', 'children' => (string) $c_8])|noescape}
    {else}
      {=og_include('blocks/search-palette.latte', ['p' => ['label' => og_get($v_nav, ['search']), 'shortcut' => og_get($v_nav, ['shortcut'])]])|noescape}
    {/if}
  {/if}
  {capture $c_9}
    {=og_include('icons/LucideIcon.latte', ['name' => 'bell', 'size' => 20, 'class' => 'text-muted-foreground'])|noescape}
    {=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_nav, ['userName']), 'ratio' => '1/1', 'className' => og_cnv(['size-8 shrink-0 rounded-full'])]])|noescape}
  {/capture}
  {=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'class' => og_s((og_t(og_and([og_eq($v_links, 'show'), og_eq($v_search, 'show')])) ? 'shrink-0' : 'ml-auto shrink-0')), 'attrs' => og_attrs(['data-slot', 'user']), 'children' => (string) $c_9])|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'header', 'class' => 'flex h-16 shrink-0 items-center gap-6 border-b border-border bg-background px-6', 'attrs' => og_attrs(['aria-label', $v_landmarkLabel, 'data-slot', 'topbar']), '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 shell-topbar
blocks/shell-topbar.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/shell-topbar.json
    The top bar of DashboardShell: the brand (when no sidebar carries it), the links (when there is no sidebar), an optional search field, and the signed-in person.
    Props (p): nav, brand, links, search, landmarkLabel. -#}
{%- set v_nav = og_def(p['nav'], none) -%}
{%- set v_brand = og_def(p['brand'], 'show') -%}
{%- set v_links = og_def(p['links'], 'hide') -%}
{%- set v_search = og_def(p['search'], 'show') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_10 -%}
  {%- if og_t(og_eq(v_brand, 'show')) %}
    {%- set c_2 -%}
      {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'layers', 'Size': 24}}) }}
      {%- set c_1 -%}
        {{ og_text(og_get(v_nav, ['brand'])) }}
      {%- endset -%}
      {{ og_include('compose/text.html.j2', {'p': {'Size': 'base', 'Weight': 'bold', 'Class': og_s(('' if og_t(true) else 'sr-only'))}, 'children': c_1}) }}
    {%- endset -%}
    {{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'center', 'Class': 'shrink-0', 'Attrs': og_attrs(['data-slot', 'brand'])}, 'children': c_2}) }}
  {%- endif %}
  {%- if og_t(og_and([og_eq(v_links, 'show'), og_gt(og_len(og_get(v_nav, ['links'])), 0)])) %}
    {%- set c_7 -%}
      {%- set c_6 -%}
        {%- for v_l in og_l(og_get(v_nav, ['links'])) %}
          {%- set c_5 -%}
            {%- set c_4 -%}
              {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(og_get(v_l, ['icon'])), 'Size': 16}}) }}
              {%- set c_3 -%}
                {{ og_text(og_get(v_l, ['name'])) }}
              {%- endset -%}
              {{ og_include('compose/inline.html.j2', {'p': {'Class': og_s(('' if og_t(true) else 'sr-only'))}, 'children': c_3}) }}
            {%- endset -%}
            {{ og_include('blocks/menu-entry.html.j2', {'p': {'href': og_get(v_l, ['href']), 'className': og_cnv([og_cnv(['flex items-center gap-4 rounded py-2 text-sm', ('px-4' if og_t(true) else 'justify-center px-2'), ('bg-muted font-medium' if og_t(og_eq(og_get(v_l, ['id']), og_get(v_nav, ['current']))) else '')])]), 'current': og_eq(og_get(v_l, ['id']), og_get(v_nav, ['current'])), 'size': 'sm', 'testid': 'item'}, 'children': og_markup(c_4)}) }}
          {%- endset -%}
          {{ og_include('compose/list-item.html.j2', {'p': {'Attrs': og_attrs(['data-slot', 'links-row'])}, 'children': c_5}) }}
        {%- endfor %}
      {%- endset -%}
      {{ og_include('compose/list.html.j2', {'p': {'Class': 'm-0 flex list-none items-center gap-2 p-0'}, 'children': c_6}) }}
    {%- endset -%}
    {{ og_include('blocks/nav-block.html.j2', {'p': {'label': (og_uniq(og_tpl('{0}, {1}', [og_get(v_nav, ['label']), v_landmarkLabel])) if og_t(v_landmarkLabel) else og_get(v_nav, ['label'])), 'className': og_cnv(['hidden lg:block'])}, 'children': og_markup(c_7)}) }}
  {%- endif %}
  {%- if og_t(og_eq(v_search, 'show')) %}
    {%- if og_t(og_eq(v_links, 'show')) %}
      {%- set c_8 -%}
        {{ og_include('blocks/search-palette.html.j2', {'p': {'label': og_get(v_nav, ['search']), 'shortcut': og_get(v_nav, ['shortcut'])}}) }}
      {%- endset -%}
      {{ og_include('compose/box.html.j2', {'p': {'Class': 'ml-auto hidden w-64 shrink-0 xl:block'}, 'children': c_8}) }}
    {%- else %}
      {{ og_include('blocks/search-palette.html.j2', {'p': {'label': og_get(v_nav, ['search']), 'shortcut': og_get(v_nav, ['shortcut'])}}) }}
    {%- endif %}
  {%- endif %}
  {%- set c_9 -%}
    {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'bell', 'Size': 20, 'Class': 'text-muted-foreground'}}) }}
    {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_nav, ['userName']), 'ratio': '1/1', 'className': og_cnv(['size-8 shrink-0 rounded-full'])}}) }}
  {%- endset -%}
  {{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Class': og_s(('shrink-0' if og_t(og_and([og_eq(v_links, 'show'), og_eq(v_search, 'show')])) else 'ml-auto shrink-0')), 'Attrs': og_attrs(['data-slot', 'user'])}, 'children': c_9}) }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'header', 'Class': 'flex h-16 shrink-0 items-center gap-6 border-b border-border bg-background px-6', 'Attrs': og_attrs(['aria-label', v_landmarkLabel, 'data-slot', 'topbar'])}, '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 top bar of DashboardShell: the brand (when no sidebar carries it), the links (when there is no sidebar), an optional search field, and the signed-in person.

Props of ShellTopbar
PropTypeDefault Description
nav (required)ShellNav-the brand, the links and the texts of the shell
brand "show" | "hide""show"
links "show" | "hide""hide"
search "show" | "hide""show"
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