Oweys
Oweys

Reputation: 97

Modify Checkboxes based on changes in Streamlit

I wanted to create a checkbox which checks all other checkboxes if checked and if the checkbox is unchecked that all other checkboxes also get unchecked.

For example:

enter image description here

Clicking on “all” should be also checking “option1, option2, etc.”. Same if I uncheck.

I tried to use session_states but could not come up with a solution. Is there a possibility to modify checkboxes?

Upvotes: 1

Views: 3254

Answers (1)

ferdy
ferdy

Reputation: 5024

You can use this way.

import streamlit as st 


isall = st.checkbox(label="All")

st.checkbox(label="option1", value=isall)
st.checkbox(label="option2", value=isall)

Upvotes: 2

Related Questions