Skip to content
ui8kit

component / components

Region

Region component

Install

npx ui8kit add region

Pulls in: block, compose, kit-box, 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 region
components/region.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 landmark region (header, nav, section, aside, footer, article, figure) inside another file: one Block, never
  nested, so a nested landmark is its own component.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type RegionProps = {
    tag: "header" | "nav" | "section" | "aside" | "footer" | "article" | "figure" | "main" | "search" | "div";
    landmarkLabel?: string;
    class?: string;
    children?: Snippet;
  };
</script>

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

  let { tag, landmarkLabel, class: className, children }: RegionProps = $props();
</script>

<Block tag={tag} class={className} aria-label={landmarkLabel} data-slot="region">
  {@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 region
components/region.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 landmark region (header, nav, section, aside, footer, article, figure) inside another file: one Block, never
 * nested, so a nested landmark is its own component.
 */
import { type ReactNode } from "react";
import { Block } from "../compose";

export type RegionProps = {
  tag: "header" | "nav" | "section" | "aside" | "footer" | "article" | "figure" | "main" | "search" | "div";
  landmarkLabel?: string;
  className?: string;
  children?: ReactNode;
};

export function Region({ tag, landmarkLabel, className, children }: RegionProps) {
  return (
    <Block tag={tag} className={className} aria-label={landmarkLabel} data-slot="region">
      {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 region
components/region.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 landmark region (header, nav, section, aside, footer, article, figure) inside another file: one Block, never
  nested, so a nested landmark is its own component.
-->
<script lang="ts">
export type RegionProps = {
  tag: "header" | "nav" | "section" | "aside" | "footer" | "article" | "figure" | "main" | "search" | "div";
  landmarkLabel?: string;
  class?: string;
};
</script>

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

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

<template>
  <Block :tag="tag" :class="className" :aria-label="landmarkLabel" data-slot="region">
    <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 region
components/region.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 landmark region (header, nav, section, aside, footer, article, figure) inside another file: one Block, never
 * nested, so a nested landmark is its own component.
 */
import { type JSX } from "solid-js";
import { Block } from "../compose";

export type RegionProps = {
  tag: "header" | "nav" | "section" | "aside" | "footer" | "article" | "figure" | "main" | "search" | "div";
  landmarkLabel?: string;
  class?: string;
  children?: JSX.Element;
};

export function Region({ tag, landmarkLabel, class: className, children }: RegionProps) {
  return (
    <Block tag={tag} class={className} aria-label={landmarkLabel} data-slot="region">
      {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 region
blocks/region.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/parts/region.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"
)

// RegionProps are the props of Region; the values are the JSON shapes of the TypeScript props.
type RegionProps struct {
	Tag any `json:"tag"`
	LandmarkLabel any `json:"landmarkLabel"`
	Class string `json:"className"`
}

// A landmark region (header, nav, section, aside, footer, article, figure) inside another file: one Block, never nested, so a nested landmark is its own component.
templ Region(p RegionProps) {
	{{ vTag := p.Tag }}
	{{ vLandmarkLabel := p.LandmarkLabel }}
	@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: uiutils.S(vTag), Class: uiutils.S(p.Class), Attrs: uiutils.Attrs("aria-label", vLandmarkLabel, "data-slot", "region")}}) {
		{ 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 region
blocks/region.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/parts/region.json
    A landmark region (header, nav, section, aside, footer, article, figure) inside another file: one Block, never nested, so a nested landmark is its own component.
    Props (p): tag, landmarkLabel, className; children: markup. -#}
{%- set v_tag = (p.tag ?? null) -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_1 -%}
  {{ og_slot((children ?? null))|raw }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': og_s(v_tag), 'class': og_s((p.className ?? '')), 'attrs': og_attrs(['aria-label', v_landmarkLabel, 'data-slot', 'region']), '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 region
blocks/region.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/parts/region.json
    A landmark region (header, nav, section, aside, footer, article, figure) inside another file: one Block, never nested, so a nested landmark is its own component.
    Props (p): tag, landmarkLabel, className; children: markup. *}
{var $v_tag = ($p['tag'] ?? null)}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_1}
  {=og_slot(($children ?? null))|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => og_s($v_tag), 'class' => og_s(($p['className'] ?? '')), 'attrs' => og_attrs(['aria-label', $v_landmarkLabel, 'data-slot', 'region']), '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 region
blocks/region.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/parts/region.json
    A landmark region (header, nav, section, aside, footer, article, figure) inside another file: one Block, never nested, so a nested landmark is its own component.
    Props (p): tag, landmarkLabel, className; children: markup. -#}
{%- set v_tag = og_def(p['tag'], 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': og_s(v_tag), 'Class': og_s(og_def(p['className'], '')), 'Attrs': og_attrs(['aria-label', v_landmarkLabel, 'data-slot', 'region'])}, '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 landmark region (header, nav, section, aside, footer, article, figure) inside another file: one Block, never nested, so a nested landmark is its own component.

Props of Region
PropTypeDefault Description
tag (required)"header" | "nav" | "section" | "aside" | "footer" | "article" | "figure" | "main" | "search" | "div"-the element
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