How to derive the mui elements details when action is performed and get the details on the handler function for further calculations

Have used mui components from streamlit-elements for UI. and i need to get the selected components details from on-click which calls an handler function for further backend calls.

Hi @divintajee, and welcome to out forums! :hugs:

Did you check the callback section in @okld’s streamlit-elements documentation?


:smiley:You should clarify what information you need, perhaps you can give an example?

So in GUI I have created n containers where nested expanders are present in each container. Needed perform an button action inside the the nested expander. I’m able to create the key but while performing the onclick= on the expander I’m not able to pass the argument key.

Also when any of one the expander is expanded, all the expanders are getting expanded. Guess it’s due to some parameters missing while initialising the expander and collapse. Since all are in an for loop.

This should be the result you want.:point_down:

import streamlit as st
from streamlit_elements import elements, mui

def onclick_value(value):
    st.session_state['value'] = value

def onclick(value):
    return lambda: onclick_value(value)

if 'value' in st.session_state:

for i in range(0, 3):
    exp = st.expander('title', expanded=False)
    with exp:
        with elements(key=f'test{i}'):
            with mui.Box():
                mui.Button('button', onClick=onclick(i))

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.