I need to create an accordion where all sections must be inactive on load and will only be activated when clicked.

Reading the documentation I saw that the first section will always be active by default.

Expands the specified accordion sections. Pass in a string or list of section names. Section names are case-sensitive. The first section in the accordion is expanded by default. To support multiple active sections, set allowMultipleSectionsOpen to true.

How could I create an accordion with all sections inactive when loading?

This is bothering me because I want to call a function only when a section is clicked and I'm trying to use the onsectiontoggle attribute, but it's always triggered when loading the accordion as there will always be an active section, the first one.

onsectiontoggle Fired when the accordion loads with at least one active section or when a section is toggled. Returns the openSections parameter containing an array of strings for the active section names.

1 Answer 1


If you specify allowMultipleSectionsOpen=true, then the component defaults to no open sections, and you won't get the initial onsectiontoggle event. You can always choose to toggle allowMultipleSectionsOpen on the first onsectiontoggle if you want to keep one accordion element open after the initial event.


<aura:application extends="force:slds">
    <lightning:accordion allowMultipleSectionsOpen="true">
        <lightning:accordionSection name="Section1" label="Section 1">
            Section 1 Content
        <lightning:accordionSection name="Section2" label="Section 2">
            Section 2 Content
  • I've tried this way but the onsectiontoggle keeps running when the accordion is initially loaded. <lightning:accordion aura:id="accordion" allowMultipleSectionsOpen="true" onsectiontoggle="{!c.displayOtherField}"> Jan 12 at 16:38
  • @MarcusVinicius The documentation and behavior don't seem to match then? I'll do some research on that.
    – sfdcfox
    Jan 13 at 4:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.