Skip to content
ui8kit

block / dashboard

Sidebar Nav

A vertical navigation with the brand on top and the user at the bottom: full, or icons only.

Install

npx ui8kit add sidebar-nav

Pulls in: block, compose, group, inline, kit-box, kit-text, list, list-item, lucide-icon, media-frame, menu-entry, nav-bar, nav-block, stack, text, utils

Preview

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 sidebar-nav
blocks/sidebar-nav.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 vertical navigation: the brand at the top, the links stacked, the user at the bottom. Axes: width (full:
  icon and name, compact: icons only with the name hidden), user (show, hide), density.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { NavLink } from "./nav-bar.types";

  export type SidebarNavProps = {
    label: string;
    brand: string;
    links: NavLink[];
    current?: string;
    userName: string;
    userEmail: string;
    width?: "full" | "compact";
    user?: "show" | "hide";
    density?: "default" | "compact";
    landmarkLabel?: string;
  };
</script>

<script lang="ts">
  import Block from "../compose/Block.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 Stack from "../compose/Stack.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 { cn, tpl, uniqLabel } from "../utils";

  let {
    label,
    brand,
    links,
    current = "",
    userName,
    userEmail,
    width = "full",
    user = "show",
    density = "default",
    landmarkLabel,
  }: SidebarNavProps = $props();
</script>

<Block
  tag="aside"
  class={cn(
    "flex min-h-96 flex-col gap-6 rounded bg-card p-4 inset-ring inset-ring-border",
    (((width as string) === "compact") ? "w-20 items-center" : "w-64")
  )}
  aria-label={(landmarkLabel ?? brand)}
  data-width={width}
  data-slot="sidebar"
>
  <Group gap="2" align="center">
    <LucideIcon name="layers" size={24} />
    <Text size="base" weight="bold" class={(((width as string) === "compact") ? "sr-only" : "")}>
      {brand}
    </Text>
  </Group>
  {#if ((links?.length ?? 0) > 0)}
    <NavBlock label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", label, landmarkLabel)) : label)} class="flex-1">
      <List
        class={cn(
          "m-0 flex list-none flex-col p-0",
          (((density as string) === "compact") ? "gap-0" : "gap-2")
        )}
        data-slot="items"
      >
        {#each links as l (l.id)}
          <ListItem data-slot="links-row">
            <MenuEntry
              href={l.href}
              class={cn(
                "flex items-center gap-4 rounded px-4 text-sm",
                "py-2",
                ((l.id === current) ? "bg-muted font-semibold" : "")
              )}
              current={(l.id === current)}
              testid="item"
            >
              <LucideIcon name={l.icon} size={16} />
              <Inline class={(((width as string) === "compact") ? "sr-only" : "")}>
                {l.name}
              </Inline>
            </MenuEntry>
          </ListItem>
        {/each}
      </List>
    </NavBlock>
  {/if}
  {#if ((user as string) === "show")}
    <Group gap="4" align="center" class="border-t border-border pt-4" data-slot="user">
      <MediaFrame alt={userName} ratio="1/1" class="size-10 shrink-0 rounded-full" />
      <Stack gap="0" class={(((width as string) === "compact") ? "sr-only" : "min-w-0")}>
        <Text size="sm" weight="semibold">
          {userName}
        </Text>
        <Text size="xs" class="text-muted-foreground">
          {userEmail}
        </Text>
      </Stack>
    </Group>
  {/if}
</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 sidebar-nav
blocks/sidebar-nav.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 vertical navigation: the brand at the top, the links stacked, the user at the bottom. Axes: width (full:
 * icon and name, compact: icons only with the name hidden), user (show, hide), density.
 */
import { type ReactNode } from "react";
import { Block, Group, Inline, List, ListItem, Stack, 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 { cn, tpl, uniqLabel } from "../utils";
import type { NavLink } from "./nav-bar.types";

export type SidebarNavProps = {
  label: string;
  brand: string;
  links: NavLink[];
  current?: string;
  userName: string;
  userEmail: string;
  width?: "full" | "compact";
  user?: "show" | "hide";
  density?: "default" | "compact";
  landmarkLabel?: string;
};

export function SidebarNav({
  label,
  brand,
  links,
  current = "",
  userName,
  userEmail,
  width = "full",
  user = "show",
  density = "default",
  landmarkLabel,
}: SidebarNavProps) {
  return (
    <Block
      tag="aside"
      className={cn(
        "flex min-h-96 flex-col gap-6 rounded bg-card p-4 inset-ring inset-ring-border",
        (((width as string) === "compact") ? "w-20 items-center" : "w-64")
      )}
      aria-label={(landmarkLabel ?? brand)}
      data-width={width}
      data-slot="sidebar"
    >
      <Group gap="2" align="center">
        <LucideIcon name="layers" size={24} />
        <Text size="base" weight="bold" className={(((width as string) === "compact") ? "sr-only" : "")}>
          {brand}
        </Text>
      </Group>
      {((links?.length ?? 0) > 0) ? (
        <NavBlock label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", label, landmarkLabel)) : label)} className="flex-1">
          <List
            className={cn(
              "m-0 flex list-none flex-col p-0",
              (((density as string) === "compact") ? "gap-0" : "gap-2")
            )}
            data-slot="items"
          >
            {(links ?? []).map((l) => (
              <ListItem key={l.id} data-slot="links-row">
                <MenuEntry
                  href={l.href}
                  className={cn(
                    "flex items-center gap-4 rounded px-4 text-sm",
                    "py-2",
                    ((l.id === current) ? "bg-muted font-semibold" : "")
                  )}
                  current={(l.id === current)}
                  testid="item"
                >
                  <LucideIcon name={l.icon} size={16} />
                  <Inline className={(((width as string) === "compact") ? "sr-only" : "")}>
                    {l.name}
                  </Inline>
                </MenuEntry>
              </ListItem>
            ))}
          </List>
        </NavBlock>
      ) : null}
      {((user as string) === "show") ? (
        <Group gap="4" align="center" className="border-t border-border pt-4" data-slot="user">
          <MediaFrame alt={userName} ratio="1/1" className="size-10 shrink-0 rounded-full" />
          <Stack gap="0" className={(((width as string) === "compact") ? "sr-only" : "min-w-0")}>
            <Text size="sm" weight="semibold">
              {userName}
            </Text>
            <Text size="xs" className="text-muted-foreground">
              {userEmail}
            </Text>
          </Stack>
        </Group>
      ) : null}
    </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 sidebar-nav
blocks/sidebar-nav.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 vertical navigation: the brand at the top, the links stacked, the user at the bottom. Axes: width (full:
  icon and name, compact: icons only with the name hidden), user (show, hide), density.
-->
<script lang="ts">
import type { NavLink } from "./nav-bar.types";

export type SidebarNavProps = {
  label: string;
  brand: string;
  links: NavLink[];
  current?: string;
  userName: string;
  userEmail: string;
  width?: "full" | "compact";
  user?: "show" | "hide";
  density?: "default" | "compact";
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Block from "../compose/Block.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 Stack from "../compose/Stack.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 { cn, tpl, uniqLabel } from "../utils";

const {
  label,
  brand,
  links,
  current = "",
  userName,
  userEmail,
  width = "full",
  user = "show",
  density = "default",
  landmarkLabel,
} = defineProps<SidebarNavProps>();
</script>

<template>
  <Block
    tag="aside"
    :class="cn(
      'flex min-h-96 flex-col gap-6 rounded bg-card p-4 inset-ring inset-ring-border',
      (((width as string) === 'compact') ? 'w-20 items-center' : 'w-64')
    )"
    :aria-label="(landmarkLabel ?? brand)"
    :data-width="width"
    data-slot="sidebar"
  >
    <Group gap="2" align="center">
      <LucideIcon name="layers" :size="24" />
      <Text size="base" weight="bold" :class="(((width as string) === 'compact') ? 'sr-only' : '')">
        {{ brand }}
      </Text>
    </Group>
    <NavBlock
      v-if="((links?.length ?? 0) > 0)"
      :label="(landmarkLabel ? uniqLabel(tpl('{0}, {1}', label, landmarkLabel)) : label)"
      class="flex-1"
    >
      <List
        :class="cn(
          'm-0 flex list-none flex-col p-0',
          (((density as string) === 'compact') ? 'gap-0' : 'gap-2')
        )"
        data-slot="items"
      >
        <ListItem v-for="l in links" :key="l.id" data-slot="links-row">
          <MenuEntry
            :href="l.href"
            :class="cn(
              'flex items-center gap-4 rounded px-4 text-sm',
              'py-2',
              ((l.id === current) ? 'bg-muted font-semibold' : '')
            )"
            :current="(l.id === current)"
            testid="item"
          >
            <LucideIcon :name="l.icon" :size="16" />
            <Inline :class="(((width as string) === 'compact') ? 'sr-only' : '')">
              {{ l.name }}
            </Inline>
          </MenuEntry>
        </ListItem>
      </List>
    </NavBlock>
    <Group
      v-if="((user as string) === 'show')"
      gap="4"
      align="center"
      class="border-t border-border pt-4"
      data-slot="user"
    >
      <MediaFrame :alt="userName" ratio="1/1" class="size-10 shrink-0 rounded-full" />
      <Stack gap="0" :class="(((width as string) === 'compact') ? 'sr-only' : 'min-w-0')">
        <Text size="sm" weight="semibold">
          {{ userName }}
        </Text>
        <Text size="xs" class="text-muted-foreground">
          {{ userEmail }}
        </Text>
      </Stack>
    </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 sidebar-nav
blocks/sidebar-nav.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 vertical navigation: the brand at the top, the links stacked, the user at the bottom. Axes: width (full:
 * icon and name, compact: icons only with the name hidden), user (show, hide), density.
 */
import { For, type JSX } from "solid-js";
import { Block, Group, Inline, List, ListItem, Stack, 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 { cn, tpl, uniqLabel } from "../utils";
import type { NavLink } from "./nav-bar.types";

export type SidebarNavProps = {
  label: string;
  brand: string;
  links: NavLink[];
  current?: string;
  userName: string;
  userEmail: string;
  width?: "full" | "compact";
  user?: "show" | "hide";
  density?: "default" | "compact";
  landmarkLabel?: string;
};

export function SidebarNav({
  label,
  brand,
  links,
  current = "",
  userName,
  userEmail,
  width = "full",
  user = "show",
  density = "default",
  landmarkLabel,
}: SidebarNavProps) {
  return (
    <Block
      tag="aside"
      class={cn(
        "flex min-h-96 flex-col gap-6 rounded bg-card p-4 inset-ring inset-ring-border",
        (((width as string) === "compact") ? "w-20 items-center" : "w-64")
      )}
      aria-label={(landmarkLabel ?? brand)}
      data-width={width}
      data-slot="sidebar"
    >
      <Group gap="2" align="center">
        <LucideIcon name="layers" size={24} />
        <Text size="base" weight="bold" class={(((width as string) === "compact") ? "sr-only" : "")}>
          {brand}
        </Text>
      </Group>
      {((links?.length ?? 0) > 0) ? (
        <NavBlock label={(landmarkLabel ? uniqLabel(tpl("{0}, {1}", label, landmarkLabel)) : label)} class="flex-1">
          <List
            class={cn(
              "m-0 flex list-none flex-col p-0",
              (((density as string) === "compact") ? "gap-0" : "gap-2")
            )}
            data-slot="items"
          >
            <For each={links ?? []}>{(l) => (
              <ListItem data-slot="links-row">
                <MenuEntry
                  href={l.href}
                  class={cn(
                    "flex items-center gap-4 rounded px-4 text-sm",
                    "py-2",
                    ((l.id === current) ? "bg-muted font-semibold" : "")
                  )}
                  current={(l.id === current)}
                  testid="item"
                >
                  <LucideIcon name={l.icon} size={16} />
                  <Inline class={(((width as string) === "compact") ? "sr-only" : "")}>
                    {l.name}
                  </Inline>
                </MenuEntry>
              </ListItem>
            )}</For>
          </List>
        </NavBlock>
      ) : null}
      {((user as string) === "show") ? (
        <Group gap="4" align="center" class="border-t border-border pt-4" data-slot="user">
          <MediaFrame alt={userName} ratio="1/1" class="size-10 shrink-0 rounded-full" />
          <Stack gap="0" class={(((width as string) === "compact") ? "sr-only" : "min-w-0")}>
            <Text size="sm" weight="semibold">
              {userName}
            </Text>
            <Text size="xs" class="text-muted-foreground">
              {userEmail}
            </Text>
          </Stack>
        </Group>
      ) : null}
    </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 sidebar-nav
blocks/sidebar-nav.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/sidebar-nav.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"
)

// SidebarNavProps are the props of SidebarNav; the values are the JSON shapes of the TypeScript props.
type SidebarNavProps struct {
	Label any `json:"label"`
	Brand any `json:"brand"`
	Links any `json:"links"`
	Current any `json:"current"`
	UserName any `json:"userName"`
	UserEmail any `json:"userEmail"`
	Width any `json:"width"`
	User any `json:"user"`
	Density any `json:"density"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// A vertical navigation: the brand at the top, the links stacked, the user at the bottom. Axes: width (full: icon and name, compact: icons only with the name hidden), user (show, hide), density.
templ SidebarNav(p SidebarNavProps) {
	{{ vLabel := p.Label }}
	{{ vBrand := p.Brand }}
	{{ vLinks := p.Links }}
	{{ vCurrent := uiutils.Def(p.Current, "") }}
	{{ vUserName := p.UserName }}
	{{ vUserEmail := p.UserEmail }}
	{{ vWidth := uiutils.Def(p.Width, "full") }}
	{{ vUser := uiutils.Def(p.User, "show") }}
	{{ vDensity := uiutils.Def(p.Density, "default") }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "aside", Class: uiutils.S(uiutils.Cnv("flex min-h-96 flex-col gap-6 rounded bg-card p-4 inset-ring inset-ring-border", uiutils.Cond(uiutils.T(uiutils.Eq(vWidth, "compact")), "w-20 items-center", "w-64"))), Attrs: uiutils.Attrs("aria-label", uiutils.Coalesce(vLandmarkLabel, vBrand), "data-width", vWidth, "data-slot", "sidebar")}}) {
		@compose.Group(compose.GroupProps{Gap: "2", Align: "center", BoxProps: box.BoxProps{}}) {
			@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(uiutils.Eq(vWidth, "compact")), "sr-only", ""))}}) {
				{ uiutils.Text(vBrand) }
			}
		}
		if uiutils.Gt(uiutils.Len(vLinks), float64(0)) {
			@NavBlock(NavBlockProps{Label: uiutils.Cond(uiutils.T(vLandmarkLabel), uiutils.Uniq(uiutils.Tpl("{0}, {1}", vLabel, vLandmarkLabel)), vLabel), Class: uiutils.Cnv("flex-1")}) {
				@compose.List(compose.ListProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("m-0 flex list-none flex-col p-0", uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "gap-0", "gap-2"))), Attrs: uiutils.Attrs("data-slot", "items")}}) {
					for _, vL := range uiutils.L(vLinks) {
						@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 px-4 text-sm", "py-2", uiutils.Cond(uiutils.T(uiutils.Eq(uiutils.Get(vL, "id"), vCurrent)), "bg-muted font-semibold", ""))), Current: uiutils.Eq(uiutils.Get(vL, "id"), vCurrent), 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(uiutils.Eq(vWidth, "compact")), "sr-only", ""))}}) {
									{ uiutils.Text(uiutils.Get(vL, "name")) }
								}
							}
						}
					}
				}
			}
		}
		if uiutils.Eq(vUser, "show") {
			@compose.Group(compose.GroupProps{Gap: "4", Align: "center", BoxProps: box.BoxProps{Class: "border-t border-border pt-4", Attrs: uiutils.Attrs("data-slot", "user")}}) {
				@MediaFrame(MediaFrameProps{Alt: vUserName, Ratio: "1/1", Class: uiutils.Cnv("size-10 shrink-0 rounded-full")})
				@compose.Stack(compose.StackProps{Gap: "0", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vWidth, "compact")), "sr-only", "min-w-0"))}}) {
					@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
						{ uiutils.Text(vUserName) }
					}
					@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
						{ uiutils.Text(vUserEmail) }
					}
				}
			}
		}
	}
}

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 sidebar-nav
blocks/sidebar-nav.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/sidebar-nav.json
    A vertical navigation: the brand at the top, the links stacked, the user at the bottom. Axes: width (full: icon and name, compact: icons only with the name hidden), user (show, hide), density.
    Props (p): label, brand, links, current, userName, userEmail, width, user, density, landmarkLabel. -#}
{%- set v_label = (p.label ?? null) -%}
{%- set v_brand = (p.brand ?? null) -%}
{%- set v_links = (p.links ?? null) -%}
{%- set v_current = (p.current ?? '') -%}
{%- set v_userName = (p.userName ?? null) -%}
{%- set v_userEmail = (p.userEmail ?? null) -%}
{%- set v_width = (p.width ?? 'full') -%}
{%- set v_user = (p.user ?? 'show') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_12 -%}
  {%- set c_2 -%}
    {{ include('icons/LucideIcon.html.twig', {'name': 'layers', 'size': 24}, with_context = false) }}
    {%- set c_1 -%}
      {{ og_text(v_brand) }}
    {%- endset -%}
    {{ include('compose/Text.html.twig', {'size': 'base', 'weight': 'bold', 'class': og_s((og_t(og_eq(v_width, 'compact')) ? 'sr-only' : '')), 'children': c_1}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Group.html.twig', {'gap': '2', 'align': 'center', 'children': c_2}, with_context = false) }}
  {%- if og_t(og_gt(og_len(v_links), 0)) %}
    {%- set c_7 -%}
      {%- set c_6 -%}
        {%- for v_l in og_l(v_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(og_eq(v_width, 'compact')) ? '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 px-4 text-sm', 'py-2', (og_t(og_eq(og_get(v_l, ['id']), v_current)) ? 'bg-muted font-semibold' : '')])]), 'current': og_eq(og_get(v_l, ['id']), v_current), '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': og_s(og_cnv(['m-0 flex list-none flex-col p-0', (og_t(og_eq(v_density, 'compact')) ? 'gap-0' : 'gap-2')])), 'attrs': og_attrs(['data-slot', 'items']), '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}', [v_label, v_landmarkLabel])) : v_label), 'className': og_cnv(['flex-1'])}, 'children': og_markup(c_7)}, with_context = false) }}
  {%- endif %}
  {%- if og_t(og_eq(v_user, 'show')) %}
    {%- set c_11 -%}
      {{ include('blocks/media-frame.html.twig', {'p': {'alt': v_userName, 'ratio': '1/1', 'className': og_cnv(['size-10 shrink-0 rounded-full'])}}, with_context = false) }}
      {%- set c_10 -%}
        {%- set c_8 -%}
          {{ og_text(v_userName) }}
        {%- endset -%}
        {{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_8}, with_context = false) }}
        {%- set c_9 -%}
          {{ og_text(v_userEmail) }}
        {%- endset -%}
        {{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_9}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Stack.html.twig', {'gap': '0', 'class': og_s((og_t(og_eq(v_width, 'compact')) ? 'sr-only' : 'min-w-0')), 'children': c_10}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'class': 'border-t border-border pt-4', 'attrs': og_attrs(['data-slot', 'user']), 'children': c_11}, with_context = false) }}
  {%- endif %}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'aside', 'class': og_s(og_cnv(['flex min-h-96 flex-col gap-6 rounded bg-card p-4 inset-ring inset-ring-border', (og_t(og_eq(v_width, 'compact')) ? 'w-20 items-center' : 'w-64')])), 'attrs': og_attrs(['aria-label', og_coalesce([v_landmarkLabel, v_brand]), 'data-width', v_width, 'data-slot', 'sidebar']), '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 sidebar-nav
blocks/sidebar-nav.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/sidebar-nav.json
    A vertical navigation: the brand at the top, the links stacked, the user at the bottom. Axes: width (full: icon and name, compact: icons only with the name hidden), user (show, hide), density.
    Props (p): label, brand, links, current, userName, userEmail, width, user, density, landmarkLabel. *}
{var $v_label = ($p['label'] ?? null)}
{var $v_brand = ($p['brand'] ?? null)}
{var $v_links = ($p['links'] ?? null)}
{var $v_current = ($p['current'] ?? '')}
{var $v_userName = ($p['userName'] ?? null)}
{var $v_userEmail = ($p['userEmail'] ?? null)}
{var $v_width = ($p['width'] ?? 'full')}
{var $v_user = ($p['user'] ?? 'show')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_12}
  {capture $c_2}
    {=og_include('icons/LucideIcon.latte', ['name' => 'layers', 'size' => 24])|noescape}
    {capture $c_1}
      {=og_text($v_brand)}
    {/capture}
    {=og_include('compose/Text.latte', ['size' => 'base', 'weight' => 'bold', 'class' => og_s((og_t(og_eq($v_width, 'compact')) ? 'sr-only' : '')), 'children' => (string) $c_1])|noescape}
  {/capture}
  {=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'center', 'children' => (string) $c_2])|noescape}
  {if og_t(og_gt(og_len($v_links), 0))}
    {capture $c_7}
      {capture $c_6}
        {foreach og_l($v_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(og_eq($v_width, 'compact')) ? '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 px-4 text-sm', 'py-2', (og_t(og_eq(og_get($v_l, ['id']), $v_current)) ? 'bg-muted font-semibold' : '')])]), 'current' => og_eq(og_get($v_l, ['id']), $v_current), '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' => og_s(og_cnv(['m-0 flex list-none flex-col p-0', (og_t(og_eq($v_density, 'compact')) ? 'gap-0' : 'gap-2')])), 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_6])|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(['flex-1'])], 'children' => og_markup($c_7)])|noescape}
  {/if}
  {if og_t(og_eq($v_user, 'show'))}
    {capture $c_11}
      {=og_include('blocks/media-frame.latte', ['p' => ['alt' => $v_userName, 'ratio' => '1/1', 'className' => og_cnv(['size-10 shrink-0 rounded-full'])]])|noescape}
      {capture $c_10}
        {capture $c_8}
          {=og_text($v_userName)}
        {/capture}
        {=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_8])|noescape}
        {capture $c_9}
          {=og_text($v_userEmail)}
        {/capture}
        {=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_9])|noescape}
      {/capture}
      {=og_include('compose/Stack.latte', ['gap' => '0', 'class' => og_s((og_t(og_eq($v_width, 'compact')) ? 'sr-only' : 'min-w-0')), 'children' => (string) $c_10])|noescape}
    {/capture}
    {=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'class' => 'border-t border-border pt-4', 'attrs' => og_attrs(['data-slot', 'user']), 'children' => (string) $c_11])|noescape}
  {/if}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'aside', 'class' => og_s(og_cnv(['flex min-h-96 flex-col gap-6 rounded bg-card p-4 inset-ring inset-ring-border', (og_t(og_eq($v_width, 'compact')) ? 'w-20 items-center' : 'w-64')])), 'attrs' => og_attrs(['aria-label', og_coalesce([$v_landmarkLabel, $v_brand]), 'data-width', $v_width, 'data-slot', 'sidebar']), '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 sidebar-nav
blocks/sidebar-nav.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/sidebar-nav.json
    A vertical navigation: the brand at the top, the links stacked, the user at the bottom. Axes: width (full: icon and name, compact: icons only with the name hidden), user (show, hide), density.
    Props (p): label, brand, links, current, userName, userEmail, width, user, density, landmarkLabel. -#}
{%- set v_label = og_def(p['label'], none) -%}
{%- set v_brand = og_def(p['brand'], none) -%}
{%- set v_links = og_def(p['links'], none) -%}
{%- set v_current = og_def(p['current'], '') -%}
{%- set v_userName = og_def(p['userName'], none) -%}
{%- set v_userEmail = og_def(p['userEmail'], none) -%}
{%- set v_width = og_def(p['width'], 'full') -%}
{%- set v_user = og_def(p['user'], 'show') -%}
{%- set v_density = og_def(p['density'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_12 -%}
  {%- set c_2 -%}
    {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'layers', 'Size': 24}}) }}
    {%- set c_1 -%}
      {{ og_text(v_brand) }}
    {%- endset -%}
    {{ og_include('compose/text.html.j2', {'p': {'Size': 'base', 'Weight': 'bold', 'Class': og_s(('sr-only' if og_t(og_eq(v_width, 'compact')) else ''))}, 'children': c_1}) }}
  {%- endset -%}
  {{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'center'}, 'children': c_2}) }}
  {%- if og_t(og_gt(og_len(v_links), 0)) %}
    {%- set c_7 -%}
      {%- set c_6 -%}
        {%- for v_l in og_l(v_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(('sr-only' if og_t(og_eq(v_width, 'compact')) else ''))}, '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 px-4 text-sm', 'py-2', ('bg-muted font-semibold' if og_t(og_eq(og_get(v_l, ['id']), v_current)) else '')])]), 'current': og_eq(og_get(v_l, ['id']), v_current), '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': og_s(og_cnv(['m-0 flex list-none flex-col p-0', ('gap-0' if og_t(og_eq(v_density, 'compact')) else 'gap-2')])), 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_6}) }}
    {%- 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(['flex-1'])}, 'children': og_markup(c_7)}) }}
  {%- endif %}
  {%- if og_t(og_eq(v_user, 'show')) %}
    {%- set c_11 -%}
      {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': v_userName, 'ratio': '1/1', 'className': og_cnv(['size-10 shrink-0 rounded-full'])}}) }}
      {%- set c_10 -%}
        {%- set c_8 -%}
          {{ og_text(v_userName) }}
        {%- endset -%}
        {{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_8}) }}
        {%- set c_9 -%}
          {{ og_text(v_userEmail) }}
        {%- endset -%}
        {{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_9}) }}
      {%- endset -%}
      {{ og_include('compose/stack.html.j2', {'p': {'Gap': '0', 'Class': og_s(('sr-only' if og_t(og_eq(v_width, 'compact')) else 'min-w-0'))}, 'children': c_10}) }}
    {%- endset -%}
    {{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Class': 'border-t border-border pt-4', 'Attrs': og_attrs(['data-slot', 'user'])}, 'children': c_11}) }}
  {%- endif %}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'aside', 'Class': og_s(og_cnv(['flex min-h-96 flex-col gap-6 rounded bg-card p-4 inset-ring inset-ring-border', ('w-20 items-center' if og_t(og_eq(v_width, 'compact')) else 'w-64')])), 'Attrs': og_attrs(['aria-label', og_coalesce([v_landmarkLabel, v_brand]), 'data-width', v_width, 'data-slot', 'sidebar'])}, '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 vertical navigation: the brand at the top, the links stacked, the user at the bottom. Axes: width (full: icon and name, compact: icons only with the name hidden), user (show, hide), density.

Props of SidebarNav
PropTypeDefault Description
label (required)string-
brand (required)string-
links (required)NavLink[]-
current string""
userName (required)string-
userEmail (required)string-
width "full" | "compact""full"
user "show" | "hide""show"
density "default" | "compact""default"
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