Accordion
Data Displayatlas-accordionExamples
Basic
Sections are data. One section is open at a time unless multiple is set.
Controlled
Bind [(expanded)] to open sections from code and read toggles back. The sidebar of this site uses it to open the group of the current page.
Open: returns
Custom title and content
Set titleTemplate / contentTemplate on an item to render your own markup; title and content stay the text fallback. Templates get the item ( let-item , with your payload in item.data ) and its open state ( let-expanded="expanded" ), so one template can serve every section.
API
Generated from the library source, so it always matches the code.
AtlasAccordionComponent atlas-accordion
| Input | Type | Default | Description |
|---|---|---|---|
| items required | AccordionItem[] | — | |
| multiple | boolean | false | |
| expanded two-way | string[] | [] | [(expanded)] ). Lets the host open the section that matches the current route, or restore state. With multiple off, at most one id stays in the list. |
| headingLevel | 1 | 2 | 3 | 4 | 5 | 6 | null | 3 | null when the accordion is not part of the document outline, for example inside a navigation menu. |
| class | string | '' | cn() ; yours win on conflicts. |
| bordered | boolean | false |
Types
AccordionItem
title / content are plain text; set titleTemplate / contentTemplate to render your own markup instead (the text is the fallback). Templates get the item and its open state as context, so one template can serve every section: html <ng-template #answer let-item let-expanded="expanded"> <p>{{ item.data.answer }}</p> </ng-template> ts private readonly answer = viewChild.required<TemplateRef<AccordionItemContext<Faq>>>('answer'); protected readonly items = computed(() => this.faqs.map((faq) => ({ id: faq.id, title: faq.question, data: faq, contentTemplate: this.answer() })), );
| Property | Type | Description |
|---|---|---|
| id | string | [(expanded)] ); not rendered. |
| title | string | titleTemplate . |
| content? | string | |
| titleTemplate? | TemplateRef<AccordionItemContext<T>> | title . |
| contentTemplate? | TemplateRef<AccordionItemContext<T>> | content . |
| data? | T | item.data ). |
AccordionItemContext
titleTemplate / contentTemplate : let-item and let-expanded="expanded" .
| Property | Type | Description |
|---|---|---|
| $implicit | AccordionItem<T> | |
| expanded | boolean |