Accordion
A stack of sections that expand when tapped, one at a time or several at once.
Installation
Usage
src/app/app.ts
- Each item needs a unique
value. All items start closed. - The trigger wraps its content in
<text>and adds an arrow, so pass plain text. - Content shows only while its item is open. It slides and fades in as the item opens.
Several open at once
With the default single, opening an item closes the others.
Control from code
src/app/faq.ts
UiAccordion has two public methods: toggle(value) opens or closes an item, and isExpanded(value) says whether it's open. The open values are in its expandedItems signal, a Set<string>.
API
UiAccordion
No outputs.
UiAccordionItem
No outputs.
All other sub-components (UiAccordionTrigger, UiAccordionContent) accept class.
Related
- Collapsible: a single section that opens and closes
- Tabs: show one panel at a time with a tab bar
