Accordion Section
lightning:accordionSection
A single section that is nested in a lightning:accordion component. This component requires version 41.0 and later.
For Aura components only. For LWC development, use lightning-accordion-section.
For Use In
Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App, Mobile Offline
A lightning:accordionSection defines the content of an accordion section inside a lightning:accordion component. Each section can contain HTML markup or Lightning components.
This component implements styling from accordion in the Lightning Design System.
To additionally style this component, use the Lightning Design System classes in Utilities.
This example creates a basic accordion with three sections, where section B is expanded by specifying it with the activeSectionName attribute in lightning:accordion.
This example creates the same basic accordion with an added buttonMenu on the first section. The button menu is included in the actions attribute, which makes it display on the section header.
Use the label attribute to provide optional header text for an accordion section. When the header text is too long to display in the viewport, the text is truncated and displayed with an ellipsis. On desktop, you can hover with the mouse to see the full text.
To expand or collapse a section, click the toggle button or header text.
If two or more sections use the same name and that name is also specified as the activeSectionName, the first section using that name is expanded by default.
lightning:accordionSection renders the toggle button and title in a <button> element. When a section is expanded, the button renders with aria-expanded="true". When a section is collapsed, the button renders with aria-expanded="false".
To expand or collapse a section using the keyboard, press the Tab key to set focus on the toggle button or header text and press Enter.
To set the aria-level value on the section header, pass in a number from 1 to 6 on the headingLevel attribute.
lightning:accordionSection observes these roles, states, and properties.
- The button on a section header displays the label you provide to the
labelattribute. - The button on a section header assigns
aria-controlsto the ID of the element that contains the accordion section content. This attribute sets a relationship between the button and the element with the accordion section content. When the button is clicked, the element with the content specifies eitheraria-hidden="true"oraria-hidden="false"depending on whether the content is visible or not.