Accordion
A stack of sections, each with a header button that shows or hides its panel. It uses the Bootstrap collapse plugin
bundled in tabler.js. By default, opening a section closes the one that was open.
<twig:Tabler:Accordion id="billing-faq" items="{{ [ {title: 'When am I charged?', text: 'Your card is charged on the first day of each billing period, in euros.', open: true}, {title: 'Can I change my plan?', text: 'Upgrades apply at once and are prorated. Downgrades apply at the next renewal.'}, {title: 'Where are my invoices?', text: 'Every invoice is sent by email and listed under Settings, then Billing.'},] }}" /><div class="accordion" id="billing-faq"> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#billing-faq-1" aria-controls="billing-faq-1" aria-expanded="true" > When am I charged? <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="billing-faq-1" class="accordion-collapse collapse show" data-bs-parent="#billing-faq"> <div class="accordion-body">Your card is charged on the first day of each billing period, in euros.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#billing-faq-2" aria-controls="billing-faq-2" aria-expanded="false" > Can I change my plan? <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="billing-faq-2" class="accordion-collapse collapse" data-bs-parent="#billing-faq"> <div class="accordion-body"> Upgrades apply at once and are prorated. Downgrades apply at the next renewal. </div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#billing-faq-3" aria-controls="billing-faq-3" aria-expanded="false" > Where are my invoices? <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="billing-faq-3" class="accordion-collapse collapse" data-bs-parent="#billing-faq"> <div class="accordion-body">Every invoice is sent by email and listed under Settings, then Billing.</div> </div> </div></div>items is an array of {title, text, open?, icon?, id?, level?, toggleIcon?}. Each item gets the id <id>-<n>,
starting at 1, unless it has its own id, and uses the accordion id as its data-bs-parent, so that opening one
closes the others. Without an id, the accordion gets a random one (accordion-<n>): set your own when the ids must
stay the same between renders, for example to link to a section or to restore the open one.
Accordion:Item renders one section from its props. Give each item an id for its panel, and the id of the
accordion as parent: opening the item then closes the others. Mark the section to show on load open.
<twig:Tabler:Accordion id="project-settings"> <twig:Tabler:Accordion:Item id="project-general" parent="project-settings" title="General" text="Project name, description and default branch." open /> <twig:Tabler:Accordion:Item id="project-members" parent="project-settings" title="Members" text="12 members, 3 of them maintainers." /> <twig:Tabler:Accordion:Item id="project-integrations" parent="project-settings" title="Integrations" text="Slack and GitHub are connected." /></twig:Tabler:Accordion><div class="accordion" id="project-settings"> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#project-general" aria-controls="project-general" aria-expanded="true" > General <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="project-general" class="accordion-collapse collapse show" data-bs-parent="#project-settings"> <div class="accordion-body">Project name, description and default branch.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#project-members" aria-controls="project-members" aria-expanded="false" > Members <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="project-members" class="accordion-collapse collapse" data-bs-parent="#project-settings"> <div class="accordion-body">12 members, 3 of them maintainers.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#project-integrations" aria-controls="project-integrations" aria-expanded="false" > Integrations <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="project-integrations" class="accordion-collapse collapse" data-bs-parent="#project-settings"> <div class="accordion-body">Slack and GitHub are connected.</div> </div> </div></div>The header is an <h3> by default. Set level on the item (1 to 6, any other value falls back to 3) to fit the
outline of the page. The button
inherits the font size of the heading, so the level changes the size of the label too. With items, set level on the
accordion for every generated item, or on an entry for that item only. toggleIcon works the same way.
Always open
Section titled “Always open”alwaysOpen leaves out data-bs-parent on the generated items, so several sections can stay open at once. Several
items can then be open on load. With Accordion:Item, leave out parent instead.
<twig:Tabler:Accordion id="release-notes" alwaysOpen items="{{ [ {title: 'Version 2.4.0', text: 'Adds CSV export to the reports page.', open: true}, {title: 'Version 2.3.2', text: 'Fixes the date filter on invoices.', open: true}, {title: 'Version 2.3.1', text: 'Speeds up the user search.'},] }}" /><div class="accordion" id="release-notes"> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#release-notes-1" aria-controls="release-notes-1" aria-expanded="true" > Version 2.4.0 <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="release-notes-1" class="accordion-collapse collapse show"> <div class="accordion-body">Adds CSV export to the reports page.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#release-notes-2" aria-controls="release-notes-2" aria-expanded="true" > Version 2.3.2 <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="release-notes-2" class="accordion-collapse collapse show"> <div class="accordion-body">Fixes the date filter on invoices.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#release-notes-3" aria-controls="release-notes-3" aria-expanded="false" > Version 2.3.1 <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="release-notes-3" class="accordion-collapse collapse"> <div class="accordion-body">Speeds up the user search.</div> </div> </div></div>flush removes the outer border and the rounded corners, to fit the accordion edge to edge in a card or a list:
<div class="card"> <div class="card-header"> <h3 class="card-title">Notification settings</h3> </div> <twig:Tabler:Accordion id="notification-settings" flush items="{{ [ {title: 'Email', text: 'A daily digest at 8:00, plus an email for each failed payment.', open: true}, {title: 'Push', text: 'Mentions and direct messages only.'}, {title: 'SMS', text: 'Security alerts, to +33 6 12 34 56 78.'}, ] }}" /></div><div class="card"> <div class="card-header"> <h3 class="card-title">Notification settings</h3> </div> <div class="accordion accordion-flush" id="notification-settings"> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#notification-settings-1" aria-controls="notification-settings-1" aria-expanded="true" > Email <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="notification-settings-1" class="accordion-collapse collapse show" data-bs-parent="#notification-settings" > <div class="accordion-body">A daily digest at 8:00, plus an email for each failed payment.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#notification-settings-2" aria-controls="notification-settings-2" aria-expanded="false" > Push <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="notification-settings-2" class="accordion-collapse collapse" data-bs-parent="#notification-settings" > <div class="accordion-body">Mentions and direct messages only.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#notification-settings-3" aria-controls="notification-settings-3" aria-expanded="false" > SMS <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="notification-settings-3" class="accordion-collapse collapse" data-bs-parent="#notification-settings" > <div class="accordion-body">Security alerts, to +33 6 12 34 56 78.</div> </div> </div> </div></div>tabs spaces the items out and gives each one its own border and rounded corners:
<twig:Tabler:Accordion id="support-topics" tabs items="{{ [ {title: 'Reset a password', text: 'Open the user, then click Send reset link. The link expires after 24 hours.', open: true}, {title: 'Export data', text: 'Reports, then Export. Large exports are sent by email.'}, {title: 'Close an account', text: 'Only an owner can close the account, from Settings, then Danger zone.'},] }}" /><div class="accordion accordion-tabs" id="support-topics"> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#support-topics-1" aria-controls="support-topics-1" aria-expanded="true" > Reset a password <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="support-topics-1" class="accordion-collapse collapse show" data-bs-parent="#support-topics"> <div class="accordion-body"> Open the user, then click Send reset link. The link expires after 24 hours. </div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#support-topics-2" aria-controls="support-topics-2" aria-expanded="false" > Export data <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="support-topics-2" class="accordion-collapse collapse" data-bs-parent="#support-topics"> <div class="accordion-body">Reports, then Export. Large exports are sent by email.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#support-topics-3" aria-controls="support-topics-3" aria-expanded="false" > Close an account <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="support-topics-3" class="accordion-collapse collapse" data-bs-parent="#support-topics"> <div class="accordion-body">Only an owner can close the account, from Settings, then Danger zone.</div> </div> </div></div>Inverted
Section titled “Inverted”inverted moves the toggle indicator to the start of the header, before the label:
<twig:Tabler:Accordion id="order-steps" inverted items="{{ [ {title: 'Shipping address', text: '12 rue de la Paix, 75002 Paris, France.', open: true}, {title: 'Delivery method', text: 'Standard delivery, 3 to 5 business days.'}, {title: 'Payment', text: 'Visa ending in 4242.'},] }}" /><div class="accordion accordion-inverted" id="order-steps"> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#order-steps-1" aria-controls="order-steps-1" aria-expanded="true" > Shipping address <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="order-steps-1" class="accordion-collapse collapse show" data-bs-parent="#order-steps"> <div class="accordion-body">12 rue de la Paix, 75002 Paris, France.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#order-steps-2" aria-controls="order-steps-2" aria-expanded="false" > Delivery method <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="order-steps-2" class="accordion-collapse collapse" data-bs-parent="#order-steps"> <div class="accordion-body">Standard delivery, 3 to 5 business days.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#order-steps-3" aria-controls="order-steps-3" aria-expanded="false" > Payment <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="order-steps-3" class="accordion-collapse collapse" data-bs-parent="#order-steps"> <div class="accordion-body">Visa ending in 4242.</div> </div> </div></div>Icons and toggles
Section titled “Icons and toggles”icon adds a leading Tabler icon before the label. plus swaps the chevron for a plus
that turns into a close icon when the section opens. On the accordion, plus applies to every generated item; icon
is set per item.
<twig:Tabler:Accordion id="account-sections" plus items="{{ [ {title: 'Profile', text: 'Jane Cooper, jane.cooper@example.com.', icon: 'user', open: true}, {title: 'Security', text: 'Two-factor authentication is enabled.', icon: 'lock'}, {title: 'Billing', text: 'Pro plan, renews on November 1.', icon: 'credit-card'},] }}" /><div class="accordion" id="account-sections"> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#account-sections-1" aria-controls="account-sections-1" aria-expanded="true" > <span class="accordion-button-icon"><i class="ti ti-user" aria-hidden="true"></i></span> Profile <span class="accordion-button-toggle accordion-button-toggle-plus"> <i class="ti ti-plus" aria-hidden="true"></i> </span> </button> </h3> <div id="account-sections-1" class="accordion-collapse collapse show" data-bs-parent="#account-sections"> <div class="accordion-body">Jane Cooper, jane.cooper@example.com.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#account-sections-2" aria-controls="account-sections-2" aria-expanded="false" > <span class="accordion-button-icon"><i class="ti ti-lock" aria-hidden="true"></i></span> Security <span class="accordion-button-toggle accordion-button-toggle-plus"> <i class="ti ti-plus" aria-hidden="true"></i> </span> </button> </h3> <div id="account-sections-2" class="accordion-collapse collapse" data-bs-parent="#account-sections"> <div class="accordion-body">Two-factor authentication is enabled.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#account-sections-3" aria-controls="account-sections-3" aria-expanded="false" > <span class="accordion-button-icon"><i class="ti ti-credit-card" aria-hidden="true"></i></span> Billing <span class="accordion-button-toggle accordion-button-toggle-plus"> <i class="ti ti-plus" aria-hidden="true"></i> </span> </button> </h3> <div id="account-sections-3" class="accordion-collapse collapse" data-bs-parent="#account-sections"> <div class="accordion-body">Pro plan, renews on November 1.</div> </div> </div></div>toggleIcon on Accordion:Item (or Accordion:Button) picks another icon for the indicator. It rotates half a turn
when the section opens:
<twig:Tabler:Accordion id="server-logs"> <twig:Tabler:Accordion:Item id="server-logs-web" parent="server-logs" title="web-01" text="Nginx restarted at 09:42." toggleIcon="caret-down" open /> <twig:Tabler:Accordion:Item id="server-logs-db" parent="server-logs" title="db-01" text="Backup finished at 03:00, 2.4 GB." toggleIcon="caret-down" /></twig:Tabler:Accordion><div class="accordion" id="server-logs"> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#server-logs-web" aria-controls="server-logs-web" aria-expanded="true" > web-01 <span class="accordion-button-toggle"><i class="ti ti-caret-down" aria-hidden="true"></i></span> </button> </h3> <div id="server-logs-web" class="accordion-collapse collapse show" data-bs-parent="#server-logs"> <div class="accordion-body">Nginx restarted at 09:42.</div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#server-logs-db" aria-controls="server-logs-db" aria-expanded="false" > db-01 <span class="accordion-button-toggle"><i class="ti ti-caret-down" aria-hidden="true"></i></span> </button> </h3> <div id="server-logs-db" class="accordion-collapse collapse" data-bs-parent="#server-logs"> <div class="accordion-body">Backup finished at 03:00, 2.4 GB.</div> </div> </div></div>Blocks
Section titled “Blocks”The title and body blocks of Accordion:Item replace the label and the panel content, while the item keeps the
header, the button and the collapse wiring. Wrap the body block in Accordion:Body to keep the padding:
<twig:Tabler:Accordion id="team-access"> <twig:Tabler:Accordion:Item id="team-access-admins" parent="team-access" open> <twig:block name="title"> Administrators <twig:Tabler:Badge variant="primary" light="{{ true }}" class="ms-2">2</twig:Tabler:Badge> </twig:block> <twig:block name="body"> <twig:Tabler:Accordion:Body> <strong>Jane Cooper</strong> and <strong>Paul Martin</strong> can manage billing and members. </twig:Tabler:Accordion:Body> </twig:block> </twig:Tabler:Accordion:Item> <twig:Tabler:Accordion:Item id="team-access-viewers" parent="team-access" title="Viewers" text="Viewers can read reports but not edit them." /></twig:Tabler:Accordion><div class="accordion" id="team-access"> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#team-access-admins" aria-controls="team-access-admins" aria-expanded="true" > Administrators <span class="badge bg-primary-lt ms-2">2</span> <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="team-access-admins" class="accordion-collapse collapse show" data-bs-parent="#team-access"> <div class="accordion-body"> <strong>Jane Cooper</strong> and <strong>Paul Martin</strong> can manage billing and members. </div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#team-access-viewers" aria-controls="team-access-viewers" aria-expanded="false" > Viewers <span class="accordion-button-toggle"><i class="ti ti-chevron-down" aria-hidden="true"></i></span> </button> </h3> <div id="team-access-viewers" class="accordion-collapse collapse" data-bs-parent="#team-access"> <div class="accordion-body">Viewers can read reports but not edit them.</div> </div> </div></div>See Composition for how blocks work.
Composed
Section titled “Composed”To build a section from its parts, pass children to Accordion:Item: they replace its content block. Keep the ids in
sync: the target of Accordion:Button is the id of Accordion:Collapse, without #. The icon and toggle
blocks of Accordion:Button frame its label:
<twig:Tabler:Accordion id="api-docs"> <twig:Tabler:Accordion:Item> <twig:Tabler:Accordion:Header> <twig:Tabler:Accordion:Button target="api-docs-auth" open> <twig:block name="icon"> <twig:Tabler:Accordion:Icon><twig:Tabler:Icon name="key" aria-hidden="true" /></twig:Tabler:Accordion:Icon> </twig:block> Authentication <twig:block name="toggle"> <twig:Tabler:Accordion:Toggle plus /> </twig:block> </twig:Tabler:Accordion:Button> </twig:Tabler:Accordion:Header> <twig:Tabler:Accordion:Collapse id="api-docs-auth" parent="api-docs" open> <twig:Tabler:Accordion:Body> Send the token in the <code>Authorization</code> header: <code>Bearer <token></code>. </twig:Tabler:Accordion:Body> </twig:Tabler:Accordion:Collapse> </twig:Tabler:Accordion:Item> <twig:Tabler:Accordion:Item> <twig:Tabler:Accordion:Header> <twig:Tabler:Accordion:Button target="api-docs-limits"> <twig:block name="icon"> <twig:Tabler:Accordion:Icon><twig:Tabler:Icon name="gauge" aria-hidden="true" /></twig:Tabler:Accordion:Icon> </twig:block> Rate limits <twig:block name="toggle"> <twig:Tabler:Accordion:Toggle plus /> </twig:block> </twig:Tabler:Accordion:Button> </twig:Tabler:Accordion:Header> <twig:Tabler:Accordion:Collapse id="api-docs-limits" parent="api-docs"> <twig:Tabler:Accordion:Body> 600 requests per minute and per token. Over the limit, the API answers <code>429</code>. </twig:Tabler:Accordion:Body> </twig:Tabler:Accordion:Collapse> </twig:Tabler:Accordion:Item></twig:Tabler:Accordion><div class="accordion" id="api-docs"> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#api-docs-auth" aria-controls="api-docs-auth" aria-expanded="true" > <span class="accordion-button-icon"><i class="ti ti-key" aria-hidden="true"></i></span> Authentication <span class="accordion-button-toggle accordion-button-toggle-plus"> <i class="ti ti-plus" aria-hidden="true"></i> </span> </button> </h3> <div id="api-docs-auth" class="accordion-collapse collapse show" data-bs-parent="#api-docs"> <div class="accordion-body"> Send the token in the <code>Authorization</code> header: <code>Bearer <token></code> . </div> </div> </div> <div class="accordion-item"> <h3 class="accordion-header"> <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#api-docs-limits" aria-controls="api-docs-limits" aria-expanded="false" > <span class="accordion-button-icon"><i class="ti ti-gauge" aria-hidden="true"></i></span> Rate limits <span class="accordion-button-toggle accordion-button-toggle-plus"> <i class="ti ti-plus" aria-hidden="true"></i> </span> </button> </h3> <div id="api-docs-limits" class="accordion-collapse collapse" data-bs-parent="#api-docs"> <div class="accordion-body"> 600 requests per minute and per token. Over the limit, the API answers <code>429</code> . </div> </div> </div></div>Accessibility
Section titled “Accessibility”Accordion:Button is a <button type="button"> with aria-controls set to the panel id and aria-expanded set
from open. Bootstrap updates aria-expanded and the collapsed class when the section opens or closes. The leading
icon and the toggle indicator are aria-hidden="true". Each button sits in a heading (Accordion:Header), so screen
reader users can jump from section to section.
Accordion:
| Prop | Type | Default | Description |
|---|---|---|---|
id |
string? | null |
DOM id, the data-bs-parent of the generated items and the prefix of their ids; random when null |
items |
array? | null |
{title, text, open?, icon?, id?, level?, toggleIcon?} entries, rendered with Accordion:Item |
flush |
bool | false |
No outer border nor rounded corners (accordion-flush) |
inverted |
bool | false |
Toggle indicator at the start of the header (accordion-inverted) |
tabs |
bool | false |
Spaced items, each fully bordered (accordion-tabs) |
alwaysOpen |
bool | false |
Generated items stay open when another one opens (no data-bs-parent) |
plus |
bool | false |
Generated items use the plus indicator (accordion-button-toggle-plus) |
level |
int | 3 |
Heading level of the generated items, 1 to 6; an entry’s level wins |
toggleIcon |
string? | null |
Toggle indicator icon of the generated items; an entry’s toggleIcon wins |
Other attributes go to the root <div class="accordion">.
Accordion:Item:
| Prop | Type | Default | Description |
|---|---|---|---|
id |
string? | null |
Id of the panel, targeted by the button |
parent |
string? | null |
Id of the accordion: when set, opening this item closes the others (data-bs-parent) |
title |
string? | null |
Button label |
text |
string? | null |
Panel text, rendered with Accordion:Body |
open |
bool | false |
Expanded on load |
icon |
string? | null |
Leading Tabler icon name, rendered with Accordion:Icon |
plus |
bool | false |
Plus indicator that turns into a close icon (accordion-button-toggle-plus) |
toggleIcon |
string? | null |
Tabler icon name of the indicator (default chevron-down, or plus) |
level |
int | 3 |
Heading level of the header, 1 to 6; any other value renders an <h3> |
Other attributes go to the <div class="accordion-item">.
Accordion:Button takes target (the panel id, without #), open, icon, plus and toggleIcon, as on the
item. Accordion:Collapse takes id, parent and open (show). Accordion:Toggle takes plus and icon (the
indicator icon name). Accordion:Header takes level (default 3). On each of them, other attributes go to the
rendered element.
Sub-components
Section titled “Sub-components”| Component | Renders |
|---|---|
Accordion:Item |
<div class="accordion-item">: one section, with its header and its panel |
Accordion:Header |
<h3 class="accordion-header"> (or the level set): holds the button |
Accordion:Button |
<button class="accordion-button" data-bs-toggle="collapse">: the label and indicator |
Accordion:Icon |
<span class="accordion-button-icon">: a leading icon before the label |
Accordion:Toggle |
<span class="accordion-button-toggle">: the indicator at the end, a chevron by default |
Accordion:Collapse |
<div class="accordion-collapse collapse">: the panel the button opens |
Accordion:Body |
<div class="accordion-body">: the padded content of the panel |
Blocks
Section titled “Blocks”Accordion:
| Block | Default |
|---|---|
content |
An Accordion:Item for each entry of the items prop |
Accordion:Item:
| Block | Default |
|---|---|
title |
The title prop |
body |
Accordion:Body with the text prop, when set |
header |
Accordion:Header with an Accordion:Button holding the title block |
content |
header, then Accordion:Collapse holding the body block: replace it to compose freely |
Accordion:Button:
| Block | Default |
|---|---|
icon |
Accordion:Icon with the icon prop, when set |
toggle |
Accordion:Toggle, with the plus and toggleIcon props |
The content of Accordion:Button is its label. Accordion:Toggle has a content block too: it holds the indicator
icon, so pass children to use your own SVG.
