Faq List
Questions as native disclosures.
Install
npx ui8kit add faq-listPulls in: box, compose, disclosure, empty-state, grid, kit-box, kit-disclosure, kit-text, search-field, section-frame, stack, summary, switcher, switcher-item, text, utils
Preview
Questions
Is there a free plan?
Yes. Solo is free and has no time limit.
Can I change plans later?
You can move up or down at any time; the change applies to the next month.
Can I export my data?
Every plan can export all content as files.
How fast is support?
Team answers within one working day, Scale within four hours.
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 faq-list<!-- 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 section with a heading and the questions. Axes: layout (accordion: native disclosures that open without
script; chat: question and answer as alternating bubbles), columns (1, 2), search mode (none, field: a search
field above; the page filters by `search.query`), filter mode (none, categories: tabs above; the page filters
by `filter.category`), density, tone.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { Faq, FaqTab, FaqSearch, FaqFilter } from "./faq-list.types";
export type FaqListProps = {
id: string;
title: string;
items: Faq[];
search?: FaqSearch;
filter?: FaqFilter;
layout?: "accordion" | "chat";
cols?: "1" | "2";
empty?: string;
multiple?: boolean;
tone?: "default" | "muted";
density?: "roomy" | "default" | "compact";
landmarkLabel?: string;
onquery?: (text: string) => void;
oncategory?: (value: string) => void;
};
</script>
<script lang="ts">
import Box from "../compose/Box.svelte";
import Disclosure from "../compose/Disclosure.svelte";
import Grid from "../compose/Grid.svelte";
import Stack from "../compose/Stack.svelte";
import Summary from "../compose/Summary.svelte";
import Text from "../compose/Text.svelte";
import EmptyState from "../components/empty-state.svelte";
import SearchField from "../components/search-field.svelte";
import SectionFrame from "../components/section-frame.svelte";
import Switcher from "../components/switcher.svelte";
import SwitcherItem from "../components/switcher-item.svelte";
import { tpl } from "../utils";
let {
id,
title,
items,
search,
filter,
layout = "accordion",
cols = "1",
empty = "",
multiple = false,
tone = "default",
density = "default",
landmarkLabel,
onquery,
oncategory,
}: FaqListProps = $props();
const inCategory = $derived(items.filter((i) => !filter?.category || i["category"] === filter?.category));
const shown = $derived(inCategory.filter((i) => !search?.query || String(i["question"]).toLowerCase().includes(String(search?.query).toLowerCase())));
</script>
<SectionFrame
id={id}
title={title}
tone={tone}
density={density}
measure={(((layout as string) === "chat") ? "2xl" : "default")}
landmarkLabel={landmarkLabel}
>
{#if (search?.mode === "field")}
<SearchField
label={(search?.label ?? "")}
placeholder={search?.label}
value={(search?.query ?? "")}
onvalue={(arg: string) => onquery?.(arg)}
/>
{/if}
{#if (filter?.mode === "categories")}
<Switcher label={filter?.label}>
{#each filter?.tabs as tab (tab.id)}
<SwitcherItem active={(tab.value === filter?.category)} onclick={() => oncategory?.(tab.value)}>
{tab.title}
</SwitcherItem>
{/each}
</Switcher>
{/if}
{#if ((shown?.length ?? 0) === 0)}
<EmptyState icon="circle-question-mark" title={empty} />
{/if}
{#if ((layout as string) === "chat")}
<Stack gap="4" align="stretch" data-slot="faq">
{#each shown as item (item.id)}
<Stack gap="2" align="stretch" data-slot="faq-item">
<Box class="ml-auto max-w-xs sm:max-w-md rounded bg-primary px-4 py-4 text-primary-foreground">
<Text size="sm" weight="semibold">
{item.question}
</Text>
</Box>
<Box class="mr-auto max-w-xs sm:max-w-md rounded bg-muted px-4 py-4">
<Text size="sm">
{item.answer}
</Text>
</Box>
</Stack>
{/each}
</Stack>
{:else}
<Grid cols={(((cols as string) === "2") ? "1-2" : "1")} class="items-start gap-x-8" data-slot="faq">
{#each shown as item (item.id)}
<Disclosure variant="item" name={(multiple ? undefined : tpl("{0}-faq", (id ?? "faq")))} data-slot="faq-item">
<Summary variant="item">
{item.question}
</Summary>
<Text size="sm" class="pb-4 text-muted-foreground">
{item.answer}
</Text>
</Disclosure>
{/each}
</Grid>
{/if}
</SectionFrame>
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type Faq = {
id: string;
question: string;
answer: string;
category?: string;
};
export type FaqTab = {
id: string;
title: string;
value: string;
};
export type FaqSearch = {
/** field: a search field above the questions */
mode?: "none" | "field";
/** accessible name and placeholder of the search field */
label?: string;
/** the text the questions are filtered by */
query?: string;
};
export type FaqFilter = {
/** categories: tabs above the questions */
mode?: "none" | "categories";
/** the category tabs */
tabs?: FaqTab[];
/** accessible name of the tabs */
label?: string;
/** the value of the chosen tab */
category?: string;
};
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 faq-list// 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 section with a heading and the questions. Axes: layout (accordion: native disclosures that open without
* script; chat: question and answer as alternating bubbles), columns (1, 2), search mode (none, field: a search
* field above; the page filters by `search.query`), filter mode (none, categories: tabs above; the page filters
* by `filter.category`), density, tone.
*/
import { type ReactNode } from "react";
import { Box, Disclosure, Grid, Stack, Summary, Text } from "../compose";
import { EmptyState } from "../components/empty-state";
import { SearchField } from "../components/search-field";
import { SectionFrame } from "../components/section-frame";
import { Switcher } from "../components/switcher";
import { SwitcherItem } from "../components/switcher-item";
import { tpl } from "../utils";
import type { Faq, FaqTab, FaqSearch, FaqFilter } from "./faq-list.types";
export type FaqListProps = {
id: string;
title: string;
items: Faq[];
search?: FaqSearch;
filter?: FaqFilter;
layout?: "accordion" | "chat";
cols?: "1" | "2";
empty?: string;
multiple?: boolean;
tone?: "default" | "muted";
density?: "roomy" | "default" | "compact";
landmarkLabel?: string;
onQuery?: (text: string) => void;
onCategory?: (value: string) => void;
};
export function FaqList({
id,
title,
items,
search,
filter,
layout = "accordion",
cols = "1",
empty = "",
multiple = false,
tone = "default",
density = "default",
landmarkLabel,
onQuery,
onCategory,
}: FaqListProps) {
const inCategory = items.filter((i) => !filter?.category || i["category"] === filter?.category);
const shown = inCategory.filter((i) => !search?.query || String(i["question"]).toLowerCase().includes(String(search?.query).toLowerCase()));
return (
<SectionFrame
id={id}
title={title}
tone={tone}
density={density}
measure={(((layout as string) === "chat") ? "2xl" : "default")}
landmarkLabel={landmarkLabel}
>
{(search?.mode === "field") ? (
<SearchField
label={(search?.label ?? "")}
placeholder={search?.label}
value={(search?.query ?? "")}
onValue={(arg: string) => onQuery?.(arg)}
/>
) : null}
{(filter?.mode === "categories") ? (
<Switcher label={filter?.label}>
{(filter?.tabs ?? []).map((tab) => (
<SwitcherItem key={tab.id} active={(tab.value === filter?.category)} onClick={() => onCategory?.(tab.value)}>
{tab.title}
</SwitcherItem>
))}
</Switcher>
) : null}
{((shown?.length ?? 0) === 0) ? (
<EmptyState icon="circle-question-mark" title={empty} />
) : null}
{((layout as string) === "chat") ? (
<Stack gap="4" align="stretch" data-slot="faq">
{(shown ?? []).map((item) => (
<Stack key={item.id} gap="2" align="stretch" data-slot="faq-item">
<Box className="ml-auto max-w-xs sm:max-w-md rounded bg-primary px-4 py-4 text-primary-foreground">
<Text size="sm" weight="semibold">
{item.question}
</Text>
</Box>
<Box className="mr-auto max-w-xs sm:max-w-md rounded bg-muted px-4 py-4">
<Text size="sm">
{item.answer}
</Text>
</Box>
</Stack>
))}
</Stack>
) : (
<Grid cols={(((cols as string) === "2") ? "1-2" : "1")} className="items-start gap-x-8" data-slot="faq">
{(shown ?? []).map((item) => (
<Disclosure key={item.id} variant="item" name={(multiple ? undefined : tpl("{0}-faq", (id ?? "faq")))} data-slot="faq-item">
<Summary variant="item">
{item.question}
</Summary>
<Text size="sm" className="pb-4 text-muted-foreground">
{item.answer}
</Text>
</Disclosure>
))}
</Grid>
)}
</SectionFrame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type Faq = {
id: string;
question: string;
answer: string;
category?: string;
};
export type FaqTab = {
id: string;
title: string;
value: string;
};
export type FaqSearch = {
/** field: a search field above the questions */
mode?: "none" | "field";
/** accessible name and placeholder of the search field */
label?: string;
/** the text the questions are filtered by */
query?: string;
};
export type FaqFilter = {
/** categories: tabs above the questions */
mode?: "none" | "categories";
/** the category tabs */
tabs?: FaqTab[];
/** accessible name of the tabs */
label?: string;
/** the value of the chosen tab */
category?: string;
};
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 faq-list// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type Faq = {
id: string;
question: string;
answer: string;
category?: string;
};
export type FaqTab = {
id: string;
title: string;
value: string;
};
export type FaqSearch = {
/** field: a search field above the questions */
mode?: "none" | "field";
/** accessible name and placeholder of the search field */
label?: string;
/** the text the questions are filtered by */
query?: string;
};
export type FaqFilter = {
/** categories: tabs above the questions */
mode?: "none" | "categories";
/** the category tabs */
tabs?: FaqTab[];
/** accessible name of the tabs */
label?: string;
/** the value of the chosen tab */
category?: string;
};
<!-- 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 section with a heading and the questions. Axes: layout (accordion: native disclosures that open without
script; chat: question and answer as alternating bubbles), columns (1, 2), search mode (none, field: a search
field above; the page filters by `search.query`), filter mode (none, categories: tabs above; the page filters
by `filter.category`), density, tone.
-->
<script lang="ts">
import type { Faq, FaqTab, FaqSearch, FaqFilter } from "./faq-list.types";
export type FaqListProps = {
id: string;
title: string;
items: Faq[];
search?: FaqSearch;
filter?: FaqFilter;
layout?: "accordion" | "chat";
cols?: "1" | "2";
empty?: string;
multiple?: boolean;
tone?: "default" | "muted";
density?: "roomy" | "default" | "compact";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import { computed } from "vue";
import Box from "../compose/Box.vue";
import Disclosure from "../compose/Disclosure.vue";
import Grid from "../compose/Grid.vue";
import Stack from "../compose/Stack.vue";
import Summary from "../compose/Summary.vue";
import Text from "../compose/Text.vue";
import EmptyState from "../components/empty-state.vue";
import SearchField from "../components/search-field.vue";
import SectionFrame from "../components/section-frame.vue";
import Switcher from "../components/switcher.vue";
import SwitcherItem from "../components/switcher-item.vue";
import { tpl } from "../utils";
const {
id,
title,
items,
search,
filter,
layout = "accordion",
cols = "1",
empty = "",
multiple = false,
tone = "default",
density = "default",
landmarkLabel,
} = defineProps<FaqListProps>();
const emit = defineEmits<{ query: [text: string], category: [value: string] }>();
const inCategory = computed(() => items.filter((i) => !filter?.category || i["category"] === filter?.category));
const shown = computed(() =>
inCategory.value.filter((i) => !search?.query || String(i["question"]).toLowerCase().includes(String(search?.query).toLowerCase()))
);
</script>
<template>
<SectionFrame
:id="id"
:title="title"
:tone="tone"
:density="density"
:measure="(((layout as string) === 'chat') ? '2xl' : 'default')"
:landmarkLabel="landmarkLabel"
>
<SearchField v-if="(search?.mode === 'field')"
:label="(search?.label ?? '')"
:placeholder="search?.label"
:value="(search?.query ?? '')"
@value="(arg: string) => emit('query', arg)"
/>
<Switcher v-if="(filter?.mode === 'categories')" :label="filter?.label">
<SwitcherItem
v-for="tab in filter?.tabs"
:key="tab.id"
:active="(tab.value === filter?.category)"
@click="() => emit('category', tab.value)"
>
{{ tab.title }}
</SwitcherItem>
</Switcher>
<EmptyState v-if="((shown?.length ?? 0) === 0)" icon="circle-question-mark" :title="empty" />
<Stack v-if="((layout as string) === 'chat')" gap="4" align="stretch" data-slot="faq">
<Stack v-for="item in shown" :key="item.id" gap="2" align="stretch" data-slot="faq-item">
<Box class="ml-auto max-w-xs sm:max-w-md rounded bg-primary px-4 py-4 text-primary-foreground">
<Text size="sm" weight="semibold">
{{ item.question }}
</Text>
</Box>
<Box class="mr-auto max-w-xs sm:max-w-md rounded bg-muted px-4 py-4">
<Text size="sm">
{{ item.answer }}
</Text>
</Box>
</Stack>
</Stack>
<Grid v-else :cols="(((cols as string) === '2') ? '1-2' : '1')" class="items-start gap-x-8" data-slot="faq">
<Disclosure
v-for="item in shown"
:key="item.id"
variant="item"
:name="(multiple ? undefined : tpl('{0}-faq', (id ?? 'faq')))"
data-slot="faq-item"
>
<Summary variant="item">
{{ item.question }}
</Summary>
<Text size="sm" class="pb-4 text-muted-foreground">
{{ item.answer }}
</Text>
</Disclosure>
</Grid>
</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 faq-list// 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 section with a heading and the questions. Axes: layout (accordion: native disclosures that open without
* script; chat: question and answer as alternating bubbles), columns (1, 2), search mode (none, field: a search
* field above; the page filters by `search.query`), filter mode (none, categories: tabs above; the page filters
* by `filter.category`), density, tone.
*/
import { For, type JSX } from "solid-js";
import { Box, Disclosure, Grid, Stack, Summary, Text } from "../compose";
import { EmptyState } from "../components/empty-state";
import { SearchField } from "../components/search-field";
import { SectionFrame } from "../components/section-frame";
import { Switcher } from "../components/switcher";
import { SwitcherItem } from "../components/switcher-item";
import { tpl } from "../utils";
import type { Faq, FaqTab, FaqSearch, FaqFilter } from "./faq-list.types";
export type FaqListProps = {
id: string;
title: string;
items: Faq[];
search?: FaqSearch;
filter?: FaqFilter;
layout?: "accordion" | "chat";
cols?: "1" | "2";
empty?: string;
multiple?: boolean;
tone?: "default" | "muted";
density?: "roomy" | "default" | "compact";
landmarkLabel?: string;
onQuery?: (text: string) => void;
onCategory?: (value: string) => void;
};
export function FaqList({
id,
title,
items,
search,
filter,
layout = "accordion",
cols = "1",
empty = "",
multiple = false,
tone = "default",
density = "default",
landmarkLabel,
onQuery,
onCategory,
}: FaqListProps) {
const inCategory = items.filter((i) => !filter?.category || i["category"] === filter?.category);
const shown = inCategory.filter((i) => !search?.query || String(i["question"]).toLowerCase().includes(String(search?.query).toLowerCase()));
return (
<SectionFrame
id={id}
title={title}
tone={tone}
density={density}
measure={(((layout as string) === "chat") ? "2xl" : "default")}
landmarkLabel={landmarkLabel}
>
{(search?.mode === "field") ? (
<SearchField
label={(search?.label ?? "")}
placeholder={search?.label}
value={(search?.query ?? "")}
onValue={(arg: string) => onQuery?.(arg)}
/>
) : null}
{(filter?.mode === "categories") ? (
<Switcher label={filter?.label}>
<For each={filter?.tabs ?? []}>{(tab) => (
<SwitcherItem active={(tab.value === filter?.category)} onClick={() => onCategory?.(tab.value)}>
{tab.title}
</SwitcherItem>
)}</For>
</Switcher>
) : null}
{((shown?.length ?? 0) === 0) ? (
<EmptyState icon="circle-question-mark" title={empty} />
) : null}
{((layout as string) === "chat") ? (
<Stack gap="4" align="stretch" data-slot="faq">
<For each={shown ?? []}>{(item) => (
<Stack gap="2" align="stretch" data-slot="faq-item">
<Box class="ml-auto max-w-xs sm:max-w-md rounded bg-primary px-4 py-4 text-primary-foreground">
<Text size="sm" weight="semibold">
{item.question}
</Text>
</Box>
<Box class="mr-auto max-w-xs sm:max-w-md rounded bg-muted px-4 py-4">
<Text size="sm">
{item.answer}
</Text>
</Box>
</Stack>
)}</For>
</Stack>
) : (
<Grid cols={(((cols as string) === "2") ? "1-2" : "1")} class="items-start gap-x-8" data-slot="faq">
<For each={shown ?? []}>{(item) => (
<Disclosure variant="item" name={(multiple ? undefined : tpl("{0}-faq", (id ?? "faq")))} data-slot="faq-item">
<Summary variant="item">
{item.question}
</Summary>
<Text size="sm" class="pb-4 text-muted-foreground">
{item.answer}
</Text>
</Disclosure>
)}</For>
</Grid>
)}
</SectionFrame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type Faq = {
id: string;
question: string;
answer: string;
category?: string;
};
export type FaqTab = {
id: string;
title: string;
value: string;
};
export type FaqSearch = {
/** field: a search field above the questions */
mode?: "none" | "field";
/** accessible name and placeholder of the search field */
label?: string;
/** the text the questions are filtered by */
query?: string;
};
export type FaqFilter = {
/** categories: tabs above the questions */
mode?: "none" | "categories";
/** the category tabs */
tabs?: FaqTab[];
/** accessible name of the tabs */
label?: string;
/** the value of the chosen tab */
category?: string;
};
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 faq-list// 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/faq-list.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/ui/disclosure"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// FaqListProps are the props of FaqList; the values are the JSON shapes of the TypeScript props.
type FaqListProps struct {
Id any `json:"id"`
Title any `json:"title"`
Items any `json:"items"`
Search any `json:"search"`
Filter any `json:"filter"`
Layout any `json:"layout"`
Cols any `json:"cols"`
Empty any `json:"empty"`
Multiple any `json:"multiple"`
Tone any `json:"tone"`
Density any `json:"density"`
LandmarkLabel any `json:"landmarkLabel"`
}
// A section with a heading and the questions. Axes: layout (accordion: native disclosures that open without script; chat: question and answer as alternating bubbles), columns (1, 2), search mode (none, field: a search field above; the page filters by `search.query`), filter mode (none, categories: tabs above; the page filters by `filter.category`), density, tone.
templ FaqList(p FaqListProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vItems := p.Items }}
{{ vSearch := p.Search }}
{{ vFilter := p.Filter }}
{{ vLayout := uiutils.Def(p.Layout, "accordion") }}
{{ vCols := uiutils.Def(p.Cols, "1") }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vMultiple := uiutils.Def(p.Multiple, false) }}
{{ vTone := uiutils.Def(p.Tone, "default") }}
{{ vDensity := uiutils.Def(p.Density, "default") }}
{{ vLandmarkLabel := p.LandmarkLabel }}
{{ vInCategory := any(uiutils.Where(vItems, "category", uiutils.Get(vFilter, "category"))) }}
{{ vShown := any(uiutils.Match(vInCategory, "question", uiutils.Get(vSearch, "query"))) }}
@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Tone: vTone, Density: vDensity, Measure: uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "chat")), "2xl", "default"), LandmarkLabel: vLandmarkLabel}) {
if uiutils.Eq(uiutils.Get(vSearch, "mode"), "field") {
@SearchField(SearchFieldProps{Label: uiutils.Coalesce(uiutils.Get(vSearch, "label"), ""), Placeholder: uiutils.Get(vSearch, "label"), Value: uiutils.Coalesce(uiutils.Get(vSearch, "query"), "")})
}
if uiutils.Eq(uiutils.Get(vFilter, "mode"), "categories") {
@Switcher(SwitcherProps{Label: uiutils.Get(vFilter, "label")}) {
for _, vTab := range uiutils.L(uiutils.Get(vFilter, "tabs")) {
@SwitcherItem(SwitcherItemProps{Active: uiutils.Eq(uiutils.Get(vTab, "value"), uiutils.Get(vFilter, "category"))}) {
{ uiutils.Text(uiutils.Get(vTab, "title")) }
}
}
}
}
if uiutils.Eq(uiutils.Len(vShown), float64(0)) {
@EmptyState(EmptyStateProps{Icon: "circle-question-mark", Title: vEmpty})
}
if uiutils.Eq(vLayout, "chat") {
@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "faq")}}) {
for _, vItem := range uiutils.L(vShown) {
@compose.Stack(compose.StackProps{Gap: "2", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "faq-item")}}) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "ml-auto max-w-xs sm:max-w-md rounded bg-primary px-4 py-4 text-primary-foreground"}}) {
@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vItem, "question")) }
}
}
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "mr-auto max-w-xs sm:max-w-md rounded bg-muted px-4 py-4"}}) {
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vItem, "answer")) }
}
}
}
}
}
} else {
@compose.Grid(compose.GridProps{Cols: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vCols, "2")), "1-2", "1")), BoxProps: box.BoxProps{Class: "items-start gap-x-8", Attrs: uiutils.Attrs("data-slot", "faq")}}) {
for _, vItem := range uiutils.L(vShown) {
@compose.Disclosure(compose.DisclosureProps{Variant: "item", DisclosureProps: disclosure.DisclosureProps{Name: uiutils.S(uiutils.Cond(uiutils.T(vMultiple), nil, uiutils.Tpl("{0}-faq", uiutils.Coalesce(vId, "faq")))), Attrs: uiutils.Attrs("data-slot", "faq-item")}}) {
@compose.Summary(compose.SummaryProps{Variant: "item", SummaryProps: disclosure.SummaryProps{}}) {
{ uiutils.Text(uiutils.Get(vItem, "question")) }
}
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{Class: "pb-4 text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vItem, "answer")) }
}
}
}
}
}
}
}
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 faq-list{#- 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/faq-list.json
A section with a heading and the questions. Axes: layout (accordion: native disclosures that open without script; chat: question and answer as alternating bubbles), columns (1, 2), search mode (none, field: a search field above; the page filters by `search.query`), filter mode (none, categories: tabs above; the page filters by `filter.category`), density, tone.
Props (p): id, title, items, search, filter, layout, cols, empty, multiple, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_items = (p.items ?? null) -%}
{%- set v_search = (p.search ?? null) -%}
{%- set v_filter = (p.filter ?? null) -%}
{%- set v_layout = (p.layout ?? 'accordion') -%}
{%- set v_cols = (p.cols ?? '1') -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_multiple = (p.multiple ?? false) -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set v_inCategory = og_where(v_items, 'category', og_get(v_filter, ['category'])) -%}
{%- set v_shown = og_match(v_inCategory, 'question', og_get(v_search, ['query'])) -%}
{%- set c_13 -%}
{%- if og_t(og_eq(og_get(v_search, ['mode']), 'field')) %}
{{ include('blocks/search-field.html.twig', {'p': {'label': og_coalesce([og_get(v_search, ['label']), '']), 'placeholder': og_get(v_search, ['label']), 'value': og_coalesce([og_get(v_search, ['query']), ''])}}, with_context = false) }}
{%- endif %}
{%- if og_t(og_eq(og_get(v_filter, ['mode']), 'categories')) %}
{%- set c_2 -%}
{%- for v_tab in og_l(og_get(v_filter, ['tabs'])) %}
{%- set c_1 -%}
{{ og_text(og_get(v_tab, ['title'])) }}
{%- endset -%}
{{ include('blocks/switcher-item.html.twig', {'p': {'active': og_eq(og_get(v_tab, ['value']), og_get(v_filter, ['category']))}, 'children': og_markup(c_1)}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('blocks/switcher.html.twig', {'p': {'label': og_get(v_filter, ['label'])}, 'children': og_markup(c_2)}, with_context = false) }}
{%- endif %}
{%- if og_t(og_eq(og_len(v_shown), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'circle-question-mark', 'title': v_empty}}, with_context = false) }}
{%- endif %}
{%- if og_t(og_eq(v_layout, 'chat')) %}
{%- set c_8 -%}
{%- for v_item in og_l(v_shown) %}
{%- set c_7 -%}
{%- set c_4 -%}
{%- set c_3 -%}
{{ og_text(og_get(v_item, ['question'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_3}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'ml-auto max-w-xs sm:max-w-md rounded bg-primary px-4 py-4 text-primary-foreground', 'children': c_4}, with_context = false) }}
{%- set c_6 -%}
{%- set c_5 -%}
{{ og_text(og_get(v_item, ['answer'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'children': c_5}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'mr-auto max-w-xs sm:max-w-md rounded bg-muted px-4 py-4', 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '2', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'faq-item']), 'children': c_7}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'faq']), 'children': c_8}, with_context = false) }}
{%- else %}
{%- set c_12 -%}
{%- for v_item in og_l(v_shown) %}
{%- set c_11 -%}
{%- set c_9 -%}
{{ og_text(og_get(v_item, ['question'])) }}
{%- endset -%}
{{ include('compose/Summary.html.twig', {'variant': 'item', 'children': c_9}, with_context = false) }}
{%- set c_10 -%}
{{ og_text(og_get(v_item, ['answer'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'class': 'pb-4 text-muted-foreground', 'children': c_10}, with_context = false) }}
{%- endset -%}
{{ include('compose/Disclosure.html.twig', {'variant': 'item', 'name': og_s((og_t(v_multiple) ? null : og_tpl('{0}-faq', [og_coalesce([v_id, 'faq'])]))), 'attrs': og_attrs(['data-slot', 'faq-item']), 'children': c_11}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Grid.html.twig', {'cols': og_s((og_t(og_eq(v_cols, '2')) ? '1-2' : '1')), 'class': 'items-start gap-x-8', 'attrs': og_attrs(['data-slot', 'faq']), 'children': c_12}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'measure': (og_t(og_eq(v_layout, 'chat')) ? '2xl' : 'default'), 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_13)}, 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 faq-list{* 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/faq-list.json
A section with a heading and the questions. Axes: layout (accordion: native disclosures that open without script; chat: question and answer as alternating bubbles), columns (1, 2), search mode (none, field: a search field above; the page filters by `search.query`), filter mode (none, categories: tabs above; the page filters by `filter.category`), density, tone.
Props (p): id, title, items, search, filter, layout, cols, empty, multiple, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_items = ($p['items'] ?? null)}
{var $v_search = ($p['search'] ?? null)}
{var $v_filter = ($p['filter'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'accordion')}
{var $v_cols = ($p['cols'] ?? '1')}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_multiple = ($p['multiple'] ?? false)}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{var $v_inCategory = og_where($v_items, 'category', og_get($v_filter, ['category']))}
{var $v_shown = og_match($v_inCategory, 'question', og_get($v_search, ['query']))}
{capture $c_13}
{if og_t(og_eq(og_get($v_search, ['mode']), 'field'))}
{=og_include('blocks/search-field.latte', ['p' => ['label' => og_coalesce([og_get($v_search, ['label']), '']), 'placeholder' => og_get($v_search, ['label']), 'value' => og_coalesce([og_get($v_search, ['query']), ''])]])|noescape}
{/if}
{if og_t(og_eq(og_get($v_filter, ['mode']), 'categories'))}
{capture $c_2}
{foreach og_l(og_get($v_filter, ['tabs'])) as $v_tab}
{capture $c_1}
{=og_text(og_get($v_tab, ['title']))}
{/capture}
{=og_include('blocks/switcher-item.latte', ['p' => ['active' => og_eq(og_get($v_tab, ['value']), og_get($v_filter, ['category']))], 'children' => og_markup($c_1)])|noescape}
{/foreach}
{/capture}
{=og_include('blocks/switcher.latte', ['p' => ['label' => og_get($v_filter, ['label'])], 'children' => og_markup($c_2)])|noescape}
{/if}
{if og_t(og_eq(og_len($v_shown), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'circle-question-mark', 'title' => $v_empty]])|noescape}
{/if}
{if og_t(og_eq($v_layout, 'chat'))}
{capture $c_8}
{foreach og_l($v_shown) as $v_item}
{capture $c_7}
{capture $c_4}
{capture $c_3}
{=og_text(og_get($v_item, ['question']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_3])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'ml-auto max-w-xs sm:max-w-md rounded bg-primary px-4 py-4 text-primary-foreground', 'children' => (string) $c_4])|noescape}
{capture $c_6}
{capture $c_5}
{=og_text(og_get($v_item, ['answer']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'children' => (string) $c_5])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'mr-auto max-w-xs sm:max-w-md rounded bg-muted px-4 py-4', 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '2', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'faq-item']), 'children' => (string) $c_7])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'faq']), 'children' => (string) $c_8])|noescape}
{else}
{capture $c_12}
{foreach og_l($v_shown) as $v_item}
{capture $c_11}
{capture $c_9}
{=og_text(og_get($v_item, ['question']))}
{/capture}
{=og_include('compose/Summary.latte', ['variant' => 'item', 'children' => (string) $c_9])|noescape}
{capture $c_10}
{=og_text(og_get($v_item, ['answer']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'class' => 'pb-4 text-muted-foreground', 'children' => (string) $c_10])|noescape}
{/capture}
{=og_include('compose/Disclosure.latte', ['variant' => 'item', 'name' => og_s((og_t($v_multiple) ? null : og_tpl('{0}-faq', [og_coalesce([$v_id, 'faq'])]))), 'attrs' => og_attrs(['data-slot', 'faq-item']), 'children' => (string) $c_11])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Grid.latte', ['cols' => og_s((og_t(og_eq($v_cols, '2')) ? '1-2' : '1')), 'class' => 'items-start gap-x-8', 'attrs' => og_attrs(['data-slot', 'faq']), 'children' => (string) $c_12])|noescape}
{/if}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'tone' => $v_tone, 'density' => $v_density, 'measure' => (og_t(og_eq($v_layout, 'chat')) ? '2xl' : 'default'), 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_13)])|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 faq-list{#- 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/faq-list.json
A section with a heading and the questions. Axes: layout (accordion: native disclosures that open without script; chat: question and answer as alternating bubbles), columns (1, 2), search mode (none, field: a search field above; the page filters by `search.query`), filter mode (none, categories: tabs above; the page filters by `filter.category`), density, tone.
Props (p): id, title, items, search, filter, layout, cols, empty, multiple, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_items = og_def(p['items'], none) -%}
{%- set v_search = og_def(p['search'], none) -%}
{%- set v_filter = og_def(p['filter'], none) -%}
{%- set v_layout = og_def(p['layout'], 'accordion') -%}
{%- set v_cols = og_def(p['cols'], '1') -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_multiple = og_def(p['multiple'], false) -%}
{%- 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 v_inCategory = og_where(v_items, 'category', og_get(v_filter, ['category'])) -%}
{%- set v_shown = og_match(v_inCategory, 'question', og_get(v_search, ['query'])) -%}
{%- set c_13 -%}
{%- if og_t(og_eq(og_get(v_search, ['mode']), 'field')) %}
{{ og_include('blocks/search-field.html.j2', {'p': {'label': og_coalesce([og_get(v_search, ['label']), '']), 'placeholder': og_get(v_search, ['label']), 'value': og_coalesce([og_get(v_search, ['query']), ''])}}) }}
{%- endif %}
{%- if og_t(og_eq(og_get(v_filter, ['mode']), 'categories')) %}
{%- set c_2 -%}
{%- for v_tab in og_l(og_get(v_filter, ['tabs'])) %}
{%- set c_1 -%}
{{ og_text(og_get(v_tab, ['title'])) }}
{%- endset -%}
{{ og_include('blocks/switcher-item.html.j2', {'p': {'active': og_eq(og_get(v_tab, ['value']), og_get(v_filter, ['category']))}, 'children': og_markup(c_1)}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('blocks/switcher.html.j2', {'p': {'label': og_get(v_filter, ['label'])}, 'children': og_markup(c_2)}) }}
{%- endif %}
{%- if og_t(og_eq(og_len(v_shown), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'circle-question-mark', 'title': v_empty}}) }}
{%- endif %}
{%- if og_t(og_eq(v_layout, 'chat')) %}
{%- set c_8 -%}
{%- for v_item in og_l(v_shown) %}
{%- set c_7 -%}
{%- set c_4 -%}
{%- set c_3 -%}
{{ og_text(og_get(v_item, ['question'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_3}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'ml-auto max-w-xs sm:max-w-md rounded bg-primary px-4 py-4 text-primary-foreground'}, 'children': c_4}) }}
{%- set c_6 -%}
{%- set c_5 -%}
{{ og_text(og_get(v_item, ['answer'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm'}, 'children': c_5}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'mr-auto max-w-xs sm:max-w-md rounded bg-muted px-4 py-4'}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '2', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'faq-item'])}, 'children': c_7}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'faq'])}, 'children': c_8}) }}
{%- else %}
{%- set c_12 -%}
{%- for v_item in og_l(v_shown) %}
{%- set c_11 -%}
{%- set c_9 -%}
{{ og_text(og_get(v_item, ['question'])) }}
{%- endset -%}
{{ og_include('compose/summary.html.j2', {'p': {'Variant': 'item'}, 'children': c_9}) }}
{%- set c_10 -%}
{{ og_text(og_get(v_item, ['answer'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Class': 'pb-4 text-muted-foreground'}, 'children': c_10}) }}
{%- endset -%}
{{ og_include('compose/disclosure.html.j2', {'p': {'Variant': 'item', 'Name': og_s((none if og_t(v_multiple) else og_tpl('{0}-faq', [og_coalesce([v_id, 'faq'])]))), 'Attrs': og_attrs(['data-slot', 'faq-item'])}, 'children': c_11}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/grid.html.j2', {'p': {'Cols': og_s(('1-2' if og_t(og_eq(v_cols, '2')) else '1')), 'Class': 'items-start gap-x-8', 'Attrs': og_attrs(['data-slot', 'faq'])}, 'children': c_12}) }}
{%- endif %}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'measure': ('2xl' if og_t(og_eq(v_layout, 'chat')) else 'default'), 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_13)}) }}
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 section with a heading and the questions. Axes: layout (accordion: native disclosures that open without script; chat: question and answer as alternating bubbles), columns (1, 2), search mode (none, field: a search field above; the page filters by `search.query`), filter mode (none, categories: tabs above; the page filters by `filter.category`), density, tone.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| items (required) | Faq[] | - | |
| search | FaqSearch | - | the search field and its text |
| filter | FaqFilter | - | the category tabs and the chosen one |
| layout | "accordion" | "chat" | "accordion" | |
| cols | "1" | "2" | "1" | |
| empty | string | "" | the text of the empty state (no question, or none matches the search or tab), from the dictionary |
| multiple | boolean | false | true: several can be open at once; false: opening one closes the others (native details name) |
| tone | "default" | "muted" | "default" | |
| density | "roomy" | "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 |