πΒ Β Stateful Button
Submitted by Zachary Blackwood
Summary
Button that keeps track of its state, so that it works as a toggle button
Functions
button
Works just like a normal streamlit button, but it remembers its state, so that it works as a toggle button. If you click it, it will be pressed, and if you click it again, it will be unpressed. Args and output are the same as for st.button
Source code in src/streamlit_extras/stateful_button/__init__.py
Import:
- You should add this to the top of your .py file
Examples
example
def example():
if button("Button 1", key="button1"):
if button("Button 2", key="button2"):
if button("Button 3", key="button3"):
st.write("All 3 buttons are pressed")