Control flow

By default, Streamlit apps execute the script entirely, but we allow some functionality to handle control flow in your applications.

Stop execution

Stops execution immediately.

st.stop()

By default, Streamlit reruns your script everytime a user interacts with your app. However, sometimes it's a better user experience to wait until a group of related widgets is filled before actually rerunning the script. That's what st.form is for!

Forms

Create a form that batches elements together with a “Submit” button.

with st.form(key="my_form"):
    username = st.text_input("Username")
    password = st.text_input("Password")
    st.form_submit_button("Login")

Form submit button

Display a form submit button.

with st.form(key="my_form"):
    username = st.text_input("Username")
    password = st.text_input("Password")
    st.form_submit_button("Login")

Was this page helpful?

forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.