Skip to content
ui8kit

component / components

Nav Block

Nav Block component

Install

npx ui8kit add nav-block

Pulls in: block, compose, kit-box, 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 nav-block
components/nav-block.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 navigation region in its own file: Block tag nav named by `label`. -->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type NavBlockProps = {
    label?: string;
    testid?: string;
    landmarkLabel?: string;
    class?: string;
    children?: Snippet;
  };
</script>

<script lang="ts">
  import Block from "../compose/Block.svelte";
  import { cn } from "../utils";

  let { label, testid, landmarkLabel, class: className, children }: NavBlockProps = $props();
</script>

<Block
  tag="nav"
  class={cn(className)}
  aria-label={(landmarkLabel ?? label)}
  data-slot={(testid ?? "nav-block")}
>
  {@render children?.()}
</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 nav-block
components/nav-block.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 navigation region in its own file: Block tag nav named by `label`. */
import { type ReactNode } from "react";
import { Block } from "../compose";
import { cn } from "../utils";

export type NavBlockProps = {
  label?: string;
  testid?: string;
  landmarkLabel?: string;
  className?: string;
  children?: ReactNode;
};

export function NavBlock({ label, testid, landmarkLabel, className, children }: NavBlockProps) {
  return (
    <Block
      tag="nav"
      className={cn(className)}
      aria-label={(landmarkLabel ?? label)}
      data-slot={(testid ?? "nav-block")}
    >
      {children}
    </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 nav-block
components/nav-block.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 navigation region in its own file: Block tag nav named by `label`. -->
<script lang="ts">
export type NavBlockProps = {
  label?: string;
  testid?: string;
  landmarkLabel?: string;
  class?: string;
};
</script>

<script setup lang="ts">
import Block from "../compose/Block.vue";
import { cn } from "../utils";

const { label, testid, landmarkLabel, class: className } = defineProps<NavBlockProps>();
defineSlots<{ default?(): unknown }>();
</script>

<template>
  <Block
    tag="nav"
    :class="cn(className)"
    :aria-label="(landmarkLabel ?? label)"
    :data-slot="(testid ?? 'nav-block')"
  >
    <slot />
  </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-block
components/nav-block.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 navigation region in its own file: Block tag nav named by `label`. */
import { type JSX } from "solid-js";
import { Block } from "../compose";
import { cn } from "../utils";

export type NavBlockProps = {
  label?: string;
  testid?: string;
  landmarkLabel?: string;
  class?: string;
  children?: JSX.Element;
};

export function NavBlock({ label, testid, landmarkLabel, class: className, children }: NavBlockProps) {
  return (
    <Block
      tag="nav"
      class={cn(className)}
      aria-label={(landmarkLabel ?? label)}
      data-slot={(testid ?? "nav-block")}
    >
      {children}
    </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 nav-block
blocks/nav-block.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-block.json

package blocks

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

// NavBlockProps are the props of NavBlock; the values are the JSON shapes of the TypeScript props.
type NavBlockProps struct {
	Label any `json:"label"`
	Testid any `json:"testid"`
	LandmarkLabel any `json:"landmarkLabel"`
	Class string `json:"className"`
}

// A navigation region in its own file: Block tag nav named by `label`.
templ NavBlock(p NavBlockProps) {
	{{ vLabel := p.Label }}
	{{ vTestid := p.Testid }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "nav", Class: uiutils.S(uiutils.Cnv(p.Class)), Attrs: uiutils.Attrs("aria-label", uiutils.Coalesce(vLandmarkLabel, vLabel), "data-slot", uiutils.Coalesce(vTestid, "nav-block"))}}) {
		{ children... }
	}
}

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-block
blocks/nav-block.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-block.json
    A navigation region in its own file: Block tag nav named by `label`.
    Props (p): label, testid, landmarkLabel, className; children: markup. -#}
{%- set v_label = (p.label ?? null) -%}
{%- set v_testid = (p.testid ?? null) -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_1 -%}
  {{ og_slot((children ?? null))|raw }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'nav', 'class': og_s(og_cnv([(p.className ?? '')])), 'attrs': og_attrs(['aria-label', og_coalesce([v_landmarkLabel, v_label]), 'data-slot', og_coalesce([v_testid, 'nav-block'])]), 'children': c_1}, 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-block
blocks/nav-block.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-block.json
    A navigation region in its own file: Block tag nav named by `label`.
    Props (p): label, testid, landmarkLabel, className; children: markup. *}
{var $v_label = ($p['label'] ?? null)}
{var $v_testid = ($p['testid'] ?? null)}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_1}
  {=og_slot(($children ?? null))|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'nav', 'class' => og_s(og_cnv([($p['className'] ?? '')])), 'attrs' => og_attrs(['aria-label', og_coalesce([$v_landmarkLabel, $v_label]), 'data-slot', og_coalesce([$v_testid, 'nav-block'])]), 'children' => (string) $c_1])|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-block
blocks/nav-block.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-block.json
    A navigation region in its own file: Block tag nav named by `label`.
    Props (p): label, testid, landmarkLabel, className; children: markup. -#}
{%- set v_label = og_def(p['label'], none) -%}
{%- set v_testid = og_def(p['testid'], none) -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_1 -%}
  {{ og_slot(og_def(children, none))|safe }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'nav', 'Class': og_s(og_cnv([og_def(p['className'], '')])), 'Attrs': og_attrs(['aria-label', og_coalesce([v_landmarkLabel, v_label]), 'data-slot', og_coalesce([v_testid, 'nav-block'])])}, 'children': c_1}) }}

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 navigation region in its own file: Block tag nav named by `label`.

Props of NavBlock
PropTypeDefault Description
label string-accessible name of the navigation
testid string-data-slot of the root (default: the component name)
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