Feature Tabs
Features as tabs; the chosen one fills the panel beside or below the tab list.
Install
npx ui8kit add feature-tabsPulls in: compose, empty-state, feature-grid, grid, kit-box, kit-text, lucide-icon, media-frame, section-frame, stack, switcher, switcher-item, text, title, utils
Preview
One product, many jobs
Clear structure
One heading per page, landmarks and a skip link come built in.
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-cdnnpx ui8kit add feature-tabs<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Features behind a tab list: the chosen tab shows its text and a picture. The page keeps the chosen tab
(`active`, empty for the first) and updates it on the `select` event. Axes: panel (split: text beside the
picture, stack: picture below), tone, density.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { Feature } from "./feature-grid.types";
export type FeatureTabsProps = {
id: string;
title: string;
features: Feature[];
empty?: string;
tabsLabel: string;
active?: string;
panel?: "split" | "stack";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
onselect?: (id: string) => void;
};
</script>
<script lang="ts">
import Grid from "../compose/Grid.svelte";
import LucideIcon from "../icons/LucideIcon.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import Title from "../compose/Title.svelte";
import EmptyState from "../components/empty-state.svelte";
import MediaFrame from "../components/media-frame.svelte";
import SectionFrame from "../components/section-frame.svelte";
import Switcher from "../components/switcher.svelte";
import SwitcherItem from "../components/switcher-item.svelte";
let {
id,
title,
features,
empty = "",
tabsLabel,
active = "",
panel = "split",
tone = "default",
density = "default",
landmarkLabel,
onselect,
}: FeatureTabsProps = $props();
</script>
<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{#if ((features?.length ?? 0) === 0)}
<EmptyState icon="layout-grid" title={empty} />
{:else}
<Stack gap="6" align="stretch">
<Switcher label={tabsLabel} class="w-fit max-w-full flex-wrap">
{#each features as f, i (f.id)}
<SwitcherItem
active={((f.id === active) || (((active as string) === "") && (i === 0)))}
onclick={() => onselect?.(f.id)}
>
{f.title}
</SwitcherItem>
{/each}
</Switcher>
{#each features as f, i (f.id)}
{#if ((f.id === active) || (((active as string) === "") && (i === 0)))}
<Grid
cols={(((panel as string) === "split") ? "1-2" : "1")}
class="items-center gap-8"
role="tabpanel"
data-slot="tab-panel"
>
<Stack gap="4">
<LucideIcon name={f.icon} size={24} />
<Title as={3} size="2xl" weight="bold">
{f.title}
</Title>
<Text size="base" class="text-muted-foreground">
{f.text}
</Text>
</Stack>
<MediaFrame alt={f.title} src={f.image} ratio="4/3" />
</Grid>
{/if}
{/each}
</Stack>
{/if}
</SectionFrame>
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-cdnnpx ui8kit add feature-tabs// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Features behind a tab list: the chosen tab shows its text and a picture. The page keeps the chosen tab
* (`active`, empty for the first) and updates it on the `select` event. Axes: panel (split: text beside the
* picture, stack: picture below), tone, density.
*/
import { Fragment, type ReactNode } from "react";
import { Grid, Stack, Text, Title } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { Switcher } from "../components/switcher";
import { SwitcherItem } from "../components/switcher-item";
import type { Feature } from "./feature-grid.types";
export type FeatureTabsProps = {
id: string;
title: string;
features: Feature[];
empty?: string;
tabsLabel: string;
active?: string;
panel?: "split" | "stack";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
onSelect?: (id: string) => void;
};
export function FeatureTabs({
id,
title,
features,
empty = "",
tabsLabel,
active = "",
panel = "split",
tone = "default",
density = "default",
landmarkLabel,
onSelect,
}: FeatureTabsProps) {
return (
<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{((features?.length ?? 0) === 0) ? (
<EmptyState icon="layout-grid" title={empty} />
) : (
<Stack gap="6" align="stretch">
<Switcher label={tabsLabel} className="w-fit max-w-full flex-wrap">
{(features ?? []).map((f, i) => (
<SwitcherItem key={f.id}
active={((f.id === active) || (((active as string) === "") && (i === 0)))}
onClick={() => onSelect?.(f.id)}
>
{f.title}
</SwitcherItem>
))}
</Switcher>
{(features ?? []).map((f, i) => (
<Fragment key={f.id}>
{((f.id === active) || (((active as string) === "") && (i === 0))) ? (
<Grid
cols={(((panel as string) === "split") ? "1-2" : "1")}
className="items-center gap-8"
role="tabpanel"
data-slot="tab-panel"
>
<Stack gap="4">
<LucideIcon name={f.icon} size={24} />
<Title as={3} size="2xl" weight="bold">
{f.title}
</Title>
<Text size="base" className="text-muted-foreground">
{f.text}
</Text>
</Stack>
<MediaFrame alt={f.title} src={f.image} ratio="4/3" />
</Grid>
) : null}
</Fragment>
))}
</Stack>
)}
</SectionFrame>
);
}
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-cdnnpx ui8kit add feature-tabs<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Features behind a tab list: the chosen tab shows its text and a picture. The page keeps the chosen tab
(`active`, empty for the first) and updates it on the `select` event. Axes: panel (split: text beside the
picture, stack: picture below), tone, density.
-->
<script lang="ts">
import type { Feature } from "./feature-grid.types";
export type FeatureTabsProps = {
id: string;
title: string;
features: Feature[];
empty?: string;
tabsLabel: string;
active?: string;
panel?: "split" | "stack";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Grid from "../compose/Grid.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
import EmptyState from "../components/empty-state.vue";
import MediaFrame from "../components/media-frame.vue";
import SectionFrame from "../components/section-frame.vue";
import Switcher from "../components/switcher.vue";
import SwitcherItem from "../components/switcher-item.vue";
const {
id,
title,
features,
empty = "",
tabsLabel,
active = "",
panel = "split",
tone = "default",
density = "default",
landmarkLabel,
} = defineProps<FeatureTabsProps>();
const emit = defineEmits<{ select: [id: string] }>();
</script>
<template>
<SectionFrame :id="id" :title="title" :tone="tone" :density="density" :landmarkLabel="landmarkLabel">
<EmptyState v-if="((features?.length ?? 0) === 0)" icon="layout-grid" :title="empty" />
<Stack v-else gap="6" align="stretch">
<Switcher :label="tabsLabel" class="w-fit max-w-full flex-wrap">
<SwitcherItem v-for="(f, i) in features" :key="f.id"
:active="((f.id === active) || (((active as string) === '') && (i === 0)))"
@click="() => emit('select', f.id)"
>
{{ f.title }}
</SwitcherItem>
</Switcher>
<template v-for="(f, i) in features" :key="f.id">
<Grid v-if="((f.id === active) || (((active as string) === '') && (i === 0)))"
:cols="(((panel as string) === 'split') ? '1-2' : '1')"
class="items-center gap-8"
role="tabpanel"
data-slot="tab-panel"
>
<Stack gap="4">
<LucideIcon :name="f.icon" :size="24" />
<Title :as="3" size="2xl" weight="bold">
{{ f.title }}
</Title>
<Text size="base" class="text-muted-foreground">
{{ f.text }}
</Text>
</Stack>
<MediaFrame :alt="f.title" :src="f.image" ratio="4/3" />
</Grid>
</template>
</Stack>
</SectionFrame>
</template>
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-cdnnpx ui8kit add feature-tabs// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Features behind a tab list: the chosen tab shows its text and a picture. The page keeps the chosen tab
* (`active`, empty for the first) and updates it on the `select` event. Axes: panel (split: text beside the
* picture, stack: picture below), tone, density.
*/
import { For, type JSX } from "solid-js";
import { Grid, Stack, Text, Title } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { Switcher } from "../components/switcher";
import { SwitcherItem } from "../components/switcher-item";
import type { Feature } from "./feature-grid.types";
export type FeatureTabsProps = {
id: string;
title: string;
features: Feature[];
empty?: string;
tabsLabel: string;
active?: string;
panel?: "split" | "stack";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
onSelect?: (id: string) => void;
};
export function FeatureTabs({
id,
title,
features,
empty = "",
tabsLabel,
active = "",
panel = "split",
tone = "default",
density = "default",
landmarkLabel,
onSelect,
}: FeatureTabsProps) {
return (
<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{((features?.length ?? 0) === 0) ? (
<EmptyState icon="layout-grid" title={empty} />
) : (
<Stack gap="6" align="stretch">
<Switcher label={tabsLabel} class="w-fit max-w-full flex-wrap">
<For each={features ?? []}>{(f, iOf) => { const i = iOf(); return (
<SwitcherItem
active={((f.id === active) || (((active as string) === "") && (i === 0)))}
onClick={() => onSelect?.(f.id)}
>
{f.title}
</SwitcherItem>
); }}</For>
</Switcher>
<For each={features ?? []}>{(f, iOf) => { const i = iOf(); return (
<>
{((f.id === active) || (((active as string) === "") && (i === 0))) ? (
<Grid
cols={(((panel as string) === "split") ? "1-2" : "1")}
class="items-center gap-8"
role="tabpanel"
data-slot="tab-panel"
>
<Stack gap="4">
<LucideIcon name={f.icon} size={24} />
<Title as={3} size="2xl" weight="bold">
{f.title}
</Title>
<Text size="base" class="text-muted-foreground">
{f.text}
</Text>
</Stack>
<MediaFrame alt={f.title} src={f.image} ratio="4/3" />
</Grid>
) : null}
</>
); }}</For>
</Stack>
)}
</SectionFrame>
);
}
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-cdnnpx ui8kit add feature-tabs// 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/feature-tabs.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"
)
// FeatureTabsProps are the props of FeatureTabs; the values are the JSON shapes of the TypeScript props.
type FeatureTabsProps struct {
Id any `json:"id"`
Title any `json:"title"`
Features any `json:"features"`
Empty any `json:"empty"`
TabsLabel any `json:"tabsLabel"`
Active any `json:"active"`
Panel any `json:"panel"`
Tone any `json:"tone"`
Density any `json:"density"`
LandmarkLabel any `json:"landmarkLabel"`
}
// Features behind a tab list: the chosen tab shows its text and a picture. The page keeps the chosen tab (`active`, empty for the first) and updates it on the `select` event. Axes: panel (split: text beside the picture, stack: picture below), tone, density.
templ FeatureTabs(p FeatureTabsProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vFeatures := p.Features }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vTabsLabel := p.TabsLabel }}
{{ vActive := uiutils.Def(p.Active, "") }}
{{ vPanel := uiutils.Def(p.Panel, "split") }}
{{ vTone := uiutils.Def(p.Tone, "default") }}
{{ vDensity := uiutils.Def(p.Density, "default") }}
{{ vLandmarkLabel := p.LandmarkLabel }}
@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Tone: vTone, Density: vDensity, LandmarkLabel: vLandmarkLabel}) {
if uiutils.Eq(uiutils.Len(vFeatures), float64(0)) {
@EmptyState(EmptyStateProps{Icon: "layout-grid", Title: vEmpty})
} else {
@compose.Stack(compose.StackProps{Gap: "6", Align: "stretch", BoxProps: box.BoxProps{}}) {
@Switcher(SwitcherProps{Label: vTabsLabel, Class: uiutils.Cnv("w-fit max-w-full flex-wrap")}) {
for vI, vF := range uiutils.L(vFeatures) {
@SwitcherItem(SwitcherItemProps{Active: uiutils.Or(uiutils.Eq(uiutils.Get(vF, "id"), vActive), uiutils.And(uiutils.Eq(vActive, ""), uiutils.Eq(float64(vI), float64(0))))}) {
{ uiutils.Text(uiutils.Get(vF, "title")) }
}
}
}
for vI, vF := range uiutils.L(vFeatures) {
if uiutils.T(uiutils.Or(uiutils.Eq(uiutils.Get(vF, "id"), vActive), uiutils.And(uiutils.Eq(vActive, ""), uiutils.Eq(float64(vI), float64(0))))) {
@compose.Grid(compose.GridProps{Cols: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vPanel, "split")), "1-2", "1")), BoxProps: box.BoxProps{Class: "items-center gap-8", Attrs: uiutils.Attrs("role", "tabpanel", "data-slot", "tab-panel")}}) {
@compose.Stack(compose.StackProps{Gap: "4", BoxProps: box.BoxProps{}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(uiutils.Get(vF, "icon")), Size: 24})
@compose.Title(compose.TitleProps{As: "3", Size: "2xl", Weight: "bold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vF, "title")) }
}
@compose.Text(compose.TextProps{Size: "base", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vF, "text")) }
}
}
@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vF, "title"), Src: uiutils.Get(vF, "image"), Ratio: "4/3"})
}
}
}
}
}
}
}
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-cdnnpx ui8kit add feature-tabs{#- 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/feature-tabs.json
Features behind a tab list: the chosen tab shows its text and a picture. The page keeps the chosen tab (`active`, empty for the first) and updates it on the `select` event. Axes: panel (split: text beside the picture, stack: picture below), tone, density.
Props (p): id, title, features, empty, tabsLabel, active, panel, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_features = (p.features ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_tabsLabel = (p.tabsLabel ?? null) -%}
{%- set v_active = (p.active ?? '') -%}
{%- set v_panel = (p.panel ?? 'split') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_8 -%}
{%- if og_t(og_eq(og_len(v_features), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'layout-grid', 'title': v_empty}}, with_context = false) }}
{%- else %}
{%- set c_7 -%}
{%- set c_2 -%}
{%- for v_f in og_l(v_features) %}
{%- set v_i = loop.index0 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_f, ['title'])) }}
{%- endset -%}
{{ include('blocks/switcher-item.html.twig', {'p': {'active': og_or([og_eq(og_get(v_f, ['id']), v_active), og_and([og_eq(v_active, ''), og_eq(v_i, 0)])])}, 'children': og_markup(c_1)}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('blocks/switcher.html.twig', {'p': {'label': v_tabsLabel, 'className': og_cnv(['w-fit max-w-full flex-wrap'])}, 'children': og_markup(c_2)}, with_context = false) }}
{%- for v_f in og_l(v_features) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_or([og_eq(og_get(v_f, ['id']), v_active), og_and([og_eq(v_active, ''), og_eq(v_i, 0)])])) %}
{%- set c_6 -%}
{%- set c_5 -%}
{{ include('icons/LucideIcon.html.twig', {'name': og_s(og_get(v_f, ['icon'])), 'size': 24}, with_context = false) }}
{%- set c_3 -%}
{{ og_text(og_get(v_f, ['title'])) }}
{%- endset -%}
{{ include('compose/Title.html.twig', {'as': 3, 'size': '2xl', 'weight': 'bold', 'children': c_3}, with_context = false) }}
{%- set c_4 -%}
{{ og_text(og_get(v_f, ['text'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'base', 'class': 'text-muted-foreground', 'children': c_4}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'children': c_5}, with_context = false) }}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_f, ['title']), 'src': og_get(v_f, ['image']), 'ratio': '4/3'}}, with_context = false) }}
{%- endset -%}
{{ include('compose/Grid.html.twig', {'cols': og_s((og_t(og_eq(v_panel, 'split')) ? '1-2' : '1')), 'class': 'items-center gap-8', 'attrs': og_attrs(['role', 'tabpanel', 'data-slot', 'tab-panel']), 'children': c_6}, with_context = false) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '6', 'align': 'stretch', 'children': c_7}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_8)}, with_context = false) }}
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-cdnnpx ui8kit add feature-tabs{* 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/feature-tabs.json
Features behind a tab list: the chosen tab shows its text and a picture. The page keeps the chosen tab (`active`, empty for the first) and updates it on the `select` event. Axes: panel (split: text beside the picture, stack: picture below), tone, density.
Props (p): id, title, features, empty, tabsLabel, active, panel, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_features = ($p['features'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_tabsLabel = ($p['tabsLabel'] ?? null)}
{var $v_active = ($p['active'] ?? '')}
{var $v_panel = ($p['panel'] ?? 'split')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_8}
{if og_t(og_eq(og_len($v_features), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'layout-grid', 'title' => $v_empty]])|noescape}
{else}
{capture $c_7}
{capture $c_2}
{foreach og_l($v_features) as $v_f}
{var $v_i = $iterator->counter0}
{capture $c_1}
{=og_text(og_get($v_f, ['title']))}
{/capture}
{=og_include('blocks/switcher-item.latte', ['p' => ['active' => og_or([og_eq(og_get($v_f, ['id']), $v_active), og_and([og_eq($v_active, ''), og_eq($v_i, 0)])])], 'children' => og_markup($c_1)])|noescape}
{/foreach}
{/capture}
{=og_include('blocks/switcher.latte', ['p' => ['label' => $v_tabsLabel, 'className' => og_cnv(['w-fit max-w-full flex-wrap'])], 'children' => og_markup($c_2)])|noescape}
{foreach og_l($v_features) as $v_f}
{var $v_i = $iterator->counter0}
{if og_t(og_or([og_eq(og_get($v_f, ['id']), $v_active), og_and([og_eq($v_active, ''), og_eq($v_i, 0)])]))}
{capture $c_6}
{capture $c_5}
{=og_include('icons/LucideIcon.latte', ['name' => og_s(og_get($v_f, ['icon'])), 'size' => 24])|noescape}
{capture $c_3}
{=og_text(og_get($v_f, ['title']))}
{/capture}
{=og_include('compose/Title.latte', ['as' => 3, 'size' => '2xl', 'weight' => 'bold', 'children' => (string) $c_3])|noescape}
{capture $c_4}
{=og_text(og_get($v_f, ['text']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'base', 'class' => 'text-muted-foreground', 'children' => (string) $c_4])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'children' => (string) $c_5])|noescape}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_f, ['title']), 'src' => og_get($v_f, ['image']), 'ratio' => '4/3']])|noescape}
{/capture}
{=og_include('compose/Grid.latte', ['cols' => og_s((og_t(og_eq($v_panel, 'split')) ? '1-2' : '1')), 'class' => 'items-center gap-8', 'attrs' => og_attrs(['role', 'tabpanel', 'data-slot', 'tab-panel']), 'children' => (string) $c_6])|noescape}
{/if}
{/foreach}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '6', 'align' => 'stretch', 'children' => (string) $c_7])|noescape}
{/if}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'tone' => $v_tone, 'density' => $v_density, 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_8)])|noescape}
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-cdnnpx ui8kit add feature-tabs{#- 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/feature-tabs.json
Features behind a tab list: the chosen tab shows its text and a picture. The page keeps the chosen tab (`active`, empty for the first) and updates it on the `select` event. Axes: panel (split: text beside the picture, stack: picture below), tone, density.
Props (p): id, title, features, empty, tabsLabel, active, panel, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_features = og_def(p['features'], none) -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_tabsLabel = og_def(p['tabsLabel'], none) -%}
{%- set v_active = og_def(p['active'], '') -%}
{%- set v_panel = og_def(p['panel'], 'split') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_density = og_def(p['density'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_8 -%}
{%- if og_t(og_eq(og_len(v_features), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'layout-grid', 'title': v_empty}}) }}
{%- else %}
{%- set c_7 -%}
{%- set c_2 -%}
{%- for v_f in og_l(v_features) %}
{%- set v_i = loop.index0 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_f, ['title'])) }}
{%- endset -%}
{{ og_include('blocks/switcher-item.html.j2', {'p': {'active': og_or([og_eq(og_get(v_f, ['id']), v_active), og_and([og_eq(v_active, ''), og_eq(v_i, 0)])])}, 'children': og_markup(c_1)}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('blocks/switcher.html.j2', {'p': {'label': v_tabsLabel, 'className': og_cnv(['w-fit max-w-full flex-wrap'])}, 'children': og_markup(c_2)}) }}
{%- for v_f in og_l(v_features) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_or([og_eq(og_get(v_f, ['id']), v_active), og_and([og_eq(v_active, ''), og_eq(v_i, 0)])])) %}
{%- set c_6 -%}
{%- set c_5 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(og_get(v_f, ['icon'])), 'Size': 24}}) }}
{%- set c_3 -%}
{{ og_text(og_get(v_f, ['title'])) }}
{%- endset -%}
{{ og_include('compose/title.html.j2', {'p': {'As': 3, 'Size': '2xl', 'Weight': 'bold'}, 'children': c_3}) }}
{%- set c_4 -%}
{{ og_text(og_get(v_f, ['text'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'base', 'Class': 'text-muted-foreground'}, 'children': c_4}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4'}, 'children': c_5}) }}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_f, ['title']), 'src': og_get(v_f, ['image']), 'ratio': '4/3'}}) }}
{%- endset -%}
{{ og_include('compose/grid.html.j2', {'p': {'Cols': og_s(('1-2' if og_t(og_eq(v_panel, 'split')) else '1')), 'Class': 'items-center gap-8', 'Attrs': og_attrs(['role', 'tabpanel', 'data-slot', 'tab-panel'])}, 'children': c_6}) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '6', 'Align': 'stretch'}, 'children': c_7}) }}
{%- endif %}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_8)}) }}
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.
Features behind a tab list: the chosen tab shows its text and a picture. The page keeps the chosen tab (`active`, empty for the first) and updates it on the `select` event. Axes: panel (split: text beside the picture, stack: picture below), tone, density.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| features (required) | Feature[] | - | |
| empty | string | "" | the text of the empty state (no records), from the dictionary |
| tabsLabel (required) | string | - | |
| active | string | "" | id of the chosen feature; empty: the first |
| panel | "split" | "stack" | "split" | |
| tone | "default" | "muted" | "default" | |
| 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 |