Closing open accordion items in a callback

Hi,

I have a nested accordion which I created using dmc.AccordionMultiple .
Part of the issues that I’m having with it is that the items always stays open, so I’m trying to close it using a callback.
When the user first click on an item, I’m generating the panel using the following callback:

@app.callback(
    [ 
    Output({'type': 'accordion_panel', 'index': MATCH}, "children") ,
    Output({'type': 'raw_vars_accordion_panel', 'index': MATCH}, "children"),              
                      ],
     Input({'type': 'accordion_', 'index': ALL }, 'value') ,     
      
           prevent_initial_call=True
       
)

Now if a user opens another item, I want the first one to be closed.
I wanted to add another Output to this callback but I don’t know if it’s correct logically:

    Output({'type': 'accordion_', 'index': MATCH }, 'value') ,                             
)

This is also my input, so I’m not sure how to do it, and if its possible…
Any ideas?

1 Like

Hello,

It is possible to have one accordion tab close in response to opening another. AccordionMultiple has specific properties that allow multiple open tabs. If you change dmc.AccordionMultiple to dmc.Accordion that should help.

For more information check out Dash documentation here.`

Best,
Eliza

Hi,
Unfortunately if I am using dmc.Accordion then I can’t create nested accordions ( it doesn’t open the inner accordion).