blocks/faq.json in the package: layers with roles, the parts the behavior needs, its settings. No code runs from it.
{
"$schema": "../schema/block.schema.json",
"format": 1,
"id": "faq",
"kind": "accordion",
"label": "FAQ list",
"hint": "A plain list of questions and answers between hairlines, all closed until opened",
"category": "content",
"isNew": true,
"settings": {
"single": false,
"start": -1
},
"root": {
"type": "stack",
"name": "FAQ list",
"w": 640,
"h": 520,
"layout": {
"direction": "column",
"gap": 0,
"pad": [0, 0, 0, 0],
"align": "stretch"
},
"sizeW": "fixed",
"sizeH": "fit",
"children": [
{
"type": "stack",
"name": "Item {n}",
"part": "item",
"w": 640,
"h": 124,
"repeat": 4,
"layout": {
"direction": "column",
"gap": 0,
"pad": [0, 0, 0, 0]
},
"sizeW": "fill",
"sizeH": "fit",
"clip": true,
"children": [
{
"type": "stack",
"name": "Header",
"part": "header",
"w": 640,
"h": 60,
"layout": {
"direction": "row",
"gap": 16,
"pad": [16, 0, 16, 0],
"align": "center",
"justify": "space-between"
},
"sizeW": "fill",
"sizeH": "fit",
"children": [
{
"type": "text",
"name": "Question",
"w": 540,
"h": 24,
"sizeW": "fill",
"text": "Question {n}",
"ink": "ink",
"typography": {
"role": "heading",
"size": 17,
"weight": 600
}
},
{
"type": "text",
"name": "Icon",
"part": "icon",
"w": 24,
"h": 28,
"text": "+",
"ink": "ink",
"typography": {
"role": "body",
"size": 28,
"weight": 300,
"align": "center"
}
}
]
},
{
"type": "stack",
"name": "Panel",
"part": "panel",
"w": 640,
"h": 64,
"layout": {
"direction": "column",
"gap": 0,
"pad": [0, 0, 20, 0]
},
"sizeW": "fill",
"sizeH": "fit",
"children": [
{
"type": "text",
"name": "Answer",
"w": 600,
"h": 44,
"sizeW": "fill",
"text": "The answer to question {n}, in a sentence or two.",
"ink": "ink",
"typography": {
"role": "body",
"size": 15,
"weight": 400
}
}
]
},
{
"type": "frame",
"name": "Divider",
"w": 640,
"h": 1,
"sizeW": "fill",
"sizeH": "fixed",
"fill": "surface"
}
]
}
]
}
}
Drawn in a design: its settings in data-living, its parts in data-living-part. This is the HTML in the Design view.
<div class="lbly">
<div class="lbly-0" data-living="{"kind":"accordion","v":1,"settings":{"single":false,"start":-1}}" role="group" aria-label="FAQ list">
<div class="lbly-1" data-living-part="item">
<div class="lbly-2" data-living-part="header">
<p class="lbly-3">Question 1</p>
<p class="lbly-4" data-living-part="icon">+</p>
</div>
<div class="lbly-5" data-living-part="panel">
<p class="lbly-6">The answer to question 1, in a sentence or two.</p>
</div>
<div class="lbly-7">
</div>
</div>
<div class="lbly-8" data-living-part="item">
<div class="lbly-9" data-living-part="header">
<p class="lbly-10">Question 2</p>
<p class="lbly-11" data-living-part="icon">+</p>
</div>
<div class="lbly-12" data-living-part="panel">
<p class="lbly-13">The answer to question 2, in a sentence or two.</p>
</div>
<div class="lbly-14">
</div>
</div>
<div class="lbly-15" data-living-part="item">
<div class="lbly-16" data-living-part="header">
<p class="lbly-17">Question 3</p>
<p class="lbly-18" data-living-part="icon">+</p>
</div>
<div class="lbly-19" data-living-part="panel">
<p class="lbly-20">The answer to question 3, in a sentence or two.</p>
</div>
<div class="lbly-21">
</div>
</div>
<div class="lbly-22" data-living-part="item">
<div class="lbly-23" data-living-part="header">
<p class="lbly-24">Question 4</p>
<p class="lbly-25" data-living-part="icon">+</p>
</div>
<div class="lbly-26" data-living-part="panel">
<p class="lbly-27">The answer to question 4, in a sentence or two.</p>
</div>
<div class="lbly-28">
</div>
</div>
</div>
</div>