faq-list
Frequently asked questions, each opening to its answer, on native <details>: the browser does the keyboard, find-in-page opens the right answer, and with single only one is open at a time. items is [{ question, answer }].
This one has no events: it shows what it's given.
Source: faq-list.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/faq-list.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/faq-list.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/faq-list.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/faq-list.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/faq-list.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/faq-list.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/faq-list.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/faq-list.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/faq-list.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/faq-list.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/faq-list.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/faq-list.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/faq-list.js"></script>The compiled install writes src/components/zubra/faq-list.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<faq-list heading="Questions"></faq-list>
<script type="module">
import './components/zubra/faq-list.js';
const element = document.querySelector('faq-list');
element.single = true;
element.items = [
{
question: 'Do I need my own starter?',
answer: 'No. Every class gives you a starter to take home, with a feeding schedule.',
},
{
question: 'Can I cancel?',
answer: 'Yes, up to 48 hours before the class, for a full refund.',
},
{
question: 'Are classes accessible?',
answer: 'The kitchen is step-free, and benches can be lowered.',
},
];
</script>import './components/zubra/faq-list.js';
const single = true;
const items = [
{
question: 'Do I need my own starter?',
answer: 'No. Every class gives you a starter to take home, with a feeding schedule.',
},
{
question: 'Can I cancel?',
answer: 'Yes, up to 48 hours before the class, for a full refund.',
},
{
question: 'Are classes accessible?',
answer: 'The kitchen is step-free, and benches can be lowered.',
},
];
export function FaqListExample() {
return (
<faq-list heading="Questions" single={single} items={items}></faq-list>
);
}<script setup>
import './components/zubra/faq-list.js';
const single = true;
const items = [
{
question: 'Do I need my own starter?',
answer: 'No. Every class gives you a starter to take home, with a feeding schedule.',
},
{
question: 'Can I cancel?',
answer: 'Yes, up to 48 hours before the class, for a full refund.',
},
{
question: 'Are classes accessible?',
answer: 'The kitchen is step-free, and benches can be lowered.',
},
];
</script>
<template>
<faq-list heading="Questions" :single.prop="single" :items.prop="items"></faq-list>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/faq-list.js';
const single = true;
const items = [
{
question: 'Do I need my own starter?',
answer: 'No. Every class gives you a starter to take home, with a feeding schedule.',
},
{
question: 'Can I cancel?',
answer: 'Yes, up to 48 hours before the class, for a full refund.',
},
{
question: 'Are classes accessible?',
answer: 'The kitchen is step-free, and benches can be lowered.',
},
];
</script>
<faq-list heading="Questions" {single} {items}></faq-list>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/faq-list.js';
@Component({
selector: 'app-faq-list-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<faq-list heading="Questions" [single]="single" [items]="items"></faq-list>
`,
})
export class FaqListExample {
single = true;
items = [
{
question: 'Do I need my own starter?',
answer: 'No. Every class gives you a starter to take home, with a feeding schedule.',
},
{
question: 'Can I cancel?',
answer: 'Yes, up to 48 hours before the class, for a full refund.',
},
{
question: 'Are classes accessible?',
answer: 'The kitchen is step-free, and benches can be lowered.',
},
];
}API
| Property | Type | Default |
|---|---|---|
itemsproperty only | { question, answer }[] | [] |
heading | string | "" |
single | boolean | false |
| Slot | For |
|---|---|
heading | A heading above the list (defaults to heading, shown only when set). |
Size
1.1 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.3 KB.