Skip to content
ui8kit

component / components

Nav Item Row

Nav Item Row component

Install

npx ui8kit add nav-item-row

Pulls in: compose, inline, kit-text, utils

Preview

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

Code

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdn
npx ui8kit add nav-item-row
components/nav-item-row.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 row inside NavItem: the icon and the label on the left, the right slot (or an empty 20 by 20 frame) on the
  right.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type NavItemRowProps = {
    inner?: string;
    reserveRight?: boolean;
    children?: Snippet;
    icon?: Snippet;
    right?: Snippet;
  };
</script>

<script lang="ts">
  import Inline from "../compose/Inline.svelte";

  let { inner, reserveRight = false, children, icon, right }: NavItemRowProps = $props();
</script>

<Inline class={inner} data-slot="nav-item-content">
  <Inline
    class={"flex min-w-0 flex-1 items-center gap-4 in-data-[nav=collapsed]:flex-none in-data-[nav=collapsed]:justify-center"}
    data-slot="nav-item-left"
  >
    {@render icon?.()}
    <Inline class="min-w-0 flex-1 truncate in-data-[nav=collapsed]:hidden" data-slot="nav-item-label">
      {@render children?.()}
    </Inline>
  </Inline>
  {#if right}
    <Inline class="flex items-center gap-2 in-data-[nav=collapsed]:hidden" data-slot="nav-item-right">
      {@render right?.()}
    </Inline>
  {:else if reserveRight}
    <Inline class="size-5 shrink-0 in-data-[nav=collapsed]:hidden" data-slot="nav-item-right" />
  {/if}
</Inline>

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-item-row
components/nav-item-row.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 row inside NavItem: the icon and the label on the left, the right slot (or an empty 20 by 20 frame) on the
 * right.
 */
import { type ReactNode } from "react";
import { Inline } from "../compose";

export type NavItemRowProps = {
  inner?: string;
  reserveRight?: boolean;
  children?: ReactNode;
  icon?: ReactNode;
  right?: ReactNode;
};

export function NavItemRow({ inner, reserveRight = false, children, icon, right }: NavItemRowProps) {
  return (
    <Inline className={inner} data-slot="nav-item-content">
      <Inline
        className={"flex min-w-0 flex-1 items-center gap-4 in-data-[nav=collapsed]:flex-none in-data-[nav=collapsed]:justify-center"}
        data-slot="nav-item-left"
      >
        {icon}
        <Inline className="min-w-0 flex-1 truncate in-data-[nav=collapsed]:hidden" data-slot="nav-item-label">
          {children}
        </Inline>
      </Inline>
      {right ? (
        <Inline className="flex items-center gap-2 in-data-[nav=collapsed]:hidden" data-slot="nav-item-right">
          {right}
        </Inline>
      ) : reserveRight ? (
        <Inline className="size-5 shrink-0 in-data-[nav=collapsed]:hidden" data-slot="nav-item-right" />
      ) : null}
    </Inline>
  );
}

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-item-row
components/nav-item-row.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 row inside NavItem: the icon and the label on the left, the right slot (or an empty 20 by 20 frame) on the
  right.
-->
<script lang="ts">
export type NavItemRowProps = {
  inner?: string;
  reserveRight?: boolean;
};
</script>

<script setup lang="ts">
import Inline from "../compose/Inline.vue";

const { inner, reserveRight = false } = defineProps<NavItemRowProps>();
defineSlots<{ default?(): unknown, icon?(): unknown, right?(): unknown }>();
</script>

<template>
  <Inline :class="inner" data-slot="nav-item-content">
    <Inline
      :class="'flex min-w-0 flex-1 items-center gap-4 in-data-[nav=collapsed]:flex-none in-data-[nav=collapsed]:justify-center'"
      data-slot="nav-item-left"
    >
      <slot name="icon" />
      <Inline class="min-w-0 flex-1 truncate in-data-[nav=collapsed]:hidden" data-slot="nav-item-label">
        <slot />
      </Inline>
    </Inline>
    <Inline
      v-if="$slots.right"
      class="flex items-center gap-2 in-data-[nav=collapsed]:hidden"
      data-slot="nav-item-right"
    >
      <slot name="right" />
    </Inline>
    <Inline
      v-else-if="reserveRight"
      class="size-5 shrink-0 in-data-[nav=collapsed]:hidden"
      data-slot="nav-item-right"
    />
  </Inline>
</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-item-row
components/nav-item-row.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 row inside NavItem: the icon and the label on the left, the right slot (or an empty 20 by 20 frame) on the
 * right.
 */
import { type JSX } from "solid-js";
import { Inline } from "../compose";

export type NavItemRowProps = {
  inner?: string;
  reserveRight?: boolean;
  children?: JSX.Element;
  icon?: JSX.Element;
  right?: JSX.Element;
};

export function NavItemRow({ inner, reserveRight = false, children, icon, right }: NavItemRowProps) {
  return (
    <Inline class={inner} data-slot="nav-item-content">
      <Inline
        class={"flex min-w-0 flex-1 items-center gap-4 in-data-[nav=collapsed]:flex-none in-data-[nav=collapsed]:justify-center"}
        data-slot="nav-item-left"
      >
        {icon}
        <Inline class="min-w-0 flex-1 truncate in-data-[nav=collapsed]:hidden" data-slot="nav-item-label">
          {children}
        </Inline>
      </Inline>
      {right ? (
        <Inline class="flex items-center gap-2 in-data-[nav=collapsed]:hidden" data-slot="nav-item-right">
          {right}
        </Inline>
      ) : reserveRight ? (
        <Inline class="size-5 shrink-0 in-data-[nav=collapsed]:hidden" data-slot="nav-item-right" />
      ) : null}
    </Inline>
  );
}

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-item-row
blocks/nav-item-row.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/patterns/nav-item-row.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/compose"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// NavItemRowProps are the props of NavItemRow; the values are the JSON shapes of the TypeScript props.
type NavItemRowProps struct {
	Inner any `json:"inner"`
	ReserveRight any `json:"reserveRight"`
	Icon templ.Component `json:"-"`
	Right templ.Component `json:"-"`
}

// The row inside NavItem: the icon and the label on the left, the right slot (or an empty 20 by 20 frame) on the right.
templ NavItemRow(p NavItemRowProps) {
	{{ vInner := p.Inner }}
	{{ vReserveRight := uiutils.Def(p.ReserveRight, false) }}
	@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: uiutils.S(vInner), Attrs: uiutils.Attrs("data-slot", "nav-item-content")}}) {
		@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "flex min-w-0 flex-1 items-center gap-4 in-data-[nav=collapsed]:flex-none in-data-[nav=collapsed]:justify-center", Attrs: uiutils.Attrs("data-slot", "nav-item-left")}}) {
			if p.Icon != nil {
				@p.Icon
			}
			@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "min-w-0 flex-1 truncate in-data-[nav=collapsed]:hidden", Attrs: uiutils.Attrs("data-slot", "nav-item-label")}}) {
				{ children... }
			}
		}
		if uiutils.T((p.Right != nil)) {
			@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "flex items-center gap-2 in-data-[nav=collapsed]:hidden", Attrs: uiutils.Attrs("data-slot", "nav-item-right")}}) {
				if p.Right != nil {
					@p.Right
				}
			}
		} else if uiutils.T(vReserveRight) {
			@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "size-5 shrink-0 in-data-[nav=collapsed]:hidden", Attrs: uiutils.Attrs("data-slot", "nav-item-right")}})
		}
	}
}

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-item-row
blocks/nav-item-row.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/patterns/nav-item-row.json
    The row inside NavItem: the icon and the label on the left, the right slot (or an empty 20 by 20 frame) on the right.
    Props (p): inner, reserveRight, icon (slot), right (slot); children: markup. -#}
{%- set v_inner = (p.inner ?? null) -%}
{%- set v_reserveRight = (p.reserveRight ?? false) -%}
{%- set c_4 -%}
  {%- set c_2 -%}
    {{ og_slot((p.icon ?? null))|raw }}
    {%- set c_1 -%}
      {{ og_slot((children ?? null))|raw }}
    {%- endset -%}
    {{ include('compose/Inline.html.twig', {'class': 'min-w-0 flex-1 truncate in-data-[nav=collapsed]:hidden', 'attrs': og_attrs(['data-slot', 'nav-item-label']), 'children': c_1}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Inline.html.twig', {'class': 'flex min-w-0 flex-1 items-center gap-4 in-data-[nav=collapsed]:flex-none in-data-[nav=collapsed]:justify-center', 'attrs': og_attrs(['data-slot', 'nav-item-left']), 'children': c_2}, with_context = false) }}
  {%- if og_t(((p.right ?? null) is not null)) %}
    {%- set c_3 -%}
      {{ og_slot((p.right ?? null))|raw }}
    {%- endset -%}
    {{ include('compose/Inline.html.twig', {'class': 'flex items-center gap-2 in-data-[nav=collapsed]:hidden', 'attrs': og_attrs(['data-slot', 'nav-item-right']), 'children': c_3}, with_context = false) }}
  {%- elseif og_t(v_reserveRight) %}
    {{ include('compose/Inline.html.twig', {'class': 'size-5 shrink-0 in-data-[nav=collapsed]:hidden', 'attrs': og_attrs(['data-slot', 'nav-item-right'])}, with_context = false) }}
  {%- endif %}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': og_s(v_inner), 'attrs': og_attrs(['data-slot', 'nav-item-content']), 'children': c_4}, 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-item-row
blocks/nav-item-row.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/patterns/nav-item-row.json
    The row inside NavItem: the icon and the label on the left, the right slot (or an empty 20 by 20 frame) on the right.
    Props (p): inner, reserveRight, icon (slot), right (slot); children: markup. *}
{var $v_inner = ($p['inner'] ?? null)}
{var $v_reserveRight = ($p['reserveRight'] ?? false)}
{capture $c_4}
  {capture $c_2}
    {=og_slot(($p['icon'] ?? null))|noescape}
    {capture $c_1}
      {=og_slot(($children ?? null))|noescape}
    {/capture}
    {=og_include('compose/Inline.latte', ['class' => 'min-w-0 flex-1 truncate in-data-[nav=collapsed]:hidden', 'attrs' => og_attrs(['data-slot', 'nav-item-label']), 'children' => (string) $c_1])|noescape}
  {/capture}
  {=og_include('compose/Inline.latte', ['class' => 'flex min-w-0 flex-1 items-center gap-4 in-data-[nav=collapsed]:flex-none in-data-[nav=collapsed]:justify-center', 'attrs' => og_attrs(['data-slot', 'nav-item-left']), 'children' => (string) $c_2])|noescape}
  {if og_t(((($p['right'] ?? null) !== null)))}
    {capture $c_3}
      {=og_slot(($p['right'] ?? null))|noescape}
    {/capture}
    {=og_include('compose/Inline.latte', ['class' => 'flex items-center gap-2 in-data-[nav=collapsed]:hidden', 'attrs' => og_attrs(['data-slot', 'nav-item-right']), 'children' => (string) $c_3])|noescape}
  {elseif og_t($v_reserveRight)}
    {=og_include('compose/Inline.latte', ['class' => 'size-5 shrink-0 in-data-[nav=collapsed]:hidden', 'attrs' => og_attrs(['data-slot', 'nav-item-right'])])|noescape}
  {/if}
{/capture}
{=og_include('compose/Inline.latte', ['class' => og_s($v_inner), 'attrs' => og_attrs(['data-slot', 'nav-item-content']), 'children' => (string) $c_4])|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-item-row
blocks/nav-item-row.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/patterns/nav-item-row.json
    The row inside NavItem: the icon and the label on the left, the right slot (or an empty 20 by 20 frame) on the right.
    Props (p): inner, reserveRight, icon (slot), right (slot); children: markup. -#}
{%- set v_inner = og_def(p['inner'], none) -%}
{%- set v_reserveRight = og_def(p['reserveRight'], false) -%}
{%- set c_4 -%}
  {%- set c_2 -%}
    {{ og_slot(og_def(p['icon'], none))|safe }}
    {%- set c_1 -%}
      {{ og_slot(og_def(children, none))|safe }}
    {%- endset -%}
    {{ og_include('compose/inline.html.j2', {'p': {'Class': 'min-w-0 flex-1 truncate in-data-[nav=collapsed]:hidden', 'Attrs': og_attrs(['data-slot', 'nav-item-label'])}, 'children': c_1}) }}
  {%- endset -%}
  {{ og_include('compose/inline.html.j2', {'p': {'Class': 'flex min-w-0 flex-1 items-center gap-4 in-data-[nav=collapsed]:flex-none in-data-[nav=collapsed]:justify-center', 'Attrs': og_attrs(['data-slot', 'nav-item-left'])}, 'children': c_2}) }}
  {%- if og_t((og_def(p['right'], none) is not none)) %}
    {%- set c_3 -%}
      {{ og_slot(og_def(p['right'], none))|safe }}
    {%- endset -%}
    {{ og_include('compose/inline.html.j2', {'p': {'Class': 'flex items-center gap-2 in-data-[nav=collapsed]:hidden', 'Attrs': og_attrs(['data-slot', 'nav-item-right'])}, 'children': c_3}) }}
  {%- elif og_t(v_reserveRight) %}
    {{ og_include('compose/inline.html.j2', {'p': {'Class': 'size-5 shrink-0 in-data-[nav=collapsed]:hidden', 'Attrs': og_attrs(['data-slot', 'nav-item-right'])}}) }}
  {%- endif %}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': og_s(v_inner), 'Attrs': og_attrs(['data-slot', 'nav-item-content'])}, 'children': c_4}) }}

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 row inside NavItem: the icon and the label on the left, the right slot (or an empty 20 by 20 frame) on the right.

Props of NavItemRow
PropTypeDefault Description
inner string-classes of the row (the nav-item-content recipe, worked out by NavItem)
reserveRight booleanfalsekeep the empty 20 by 20 frame on the right when there is no right content

Used in