How to reset the status of button in streamlit-antd-components?

in the antd component i have multiple button (add,edit, delete). based on what is clicked i open a dialog box and after submit the st.rerun() is executed. the problem is sac.button keeps the previous value and does not reset like streamlit button. this leads to infinite loop. how to reset the button state after script run.

1 Like

What’s sac.button?

In streamlit-antd-components, the sac.button retains its value across reruns, unlike native Streamlit buttons. To reset its state and avoid infinite loops, use st.session_state to manually reset the button’s value after it’s used. For example:

if st.session_state.get(“action”) == “add”:
# handle add logic
st.session_state[“action”] = None # reset button state

Then, in your button:

if sac.button(“Add”, key=“add_btn”):
st.session_state[“action”] = “add”
st.rerun()
This approach gives developers full control over button state management, preventing unwanted loops or dialog persistence.