Stop reloading page when st.checkbox is checked

Summary

I am looping through a bunch of sentences that will have a check box next to them, where the user can click the check box for all true sentences example code below.
outputs, text_outputs = get_sentences_associated_with_phrase(nl_query)

text_outputs = ['dogs are cute', 'dragons are real', 'birds fly'']
for text_output in text_outputs:
        correct = st.checkbox(text_output)

As of right now, when I click the check box associated with the sentence. The page will automatically reload. What I would want to happen, is when I click a check box, the page will not reload, until I hit an st.button. psuedocode below

text_outputs = ['dogs are cute', 'dragons are real', 'birds fly'']
for text_output in text_outputs:
      correct = st.checkbox(text_output)
if(st.button('Submit')):
      do something with the text that has its check box clicked
else:
      don't do anything

Is this possible? or does streamline need to re render once a check box is clicked?

Hi @bnicholl ,
what I think you want is to use st.form. the code would look probably along the lines of:

# Im not sure if you want to clear on submit, but it does seem like that
with st.form("my_form", clear_on_submit=True):
   text_outputs = ['dogs are cute', 'dragons are real', 'birds fly'']
   for text_output in text_outputs:
       correct = st.checkbox(text_output)

   # Every form must have a submit button.
   submitted = st.form_submit_button("Submit")
   if submitted:
       st.write("slider", slider_val, "checkbox", checkbox_val)

st.write("Outside the form")

Let me know if this works for you.