Create a form that batches elements together with a "Submit" button.

A form is a container that visually groups other elements and widgets together, and contains a Submit button. When the form's Submit button is pressed, all widget values inside the form will be sent to Streamlit in a batch.

To add elements to a form object, you can use "with" notation (preferred) or just call methods directly on the form. See examples below.

Forms have a few constraints:

  • Every form must contain a st.form_submit_button.
  • You cannot add a normal st.button to a form.
  • Forms can appear anywhere in your app (sidebar, columns, etc), but they cannot be embedded inside other forms.

For more information about forms, check out our blog post.

Function signature

st.form(key)

Parameters

key (str)

A string that identifies the form. Each form must have its own key. (This key is not displayed to the user in the interface.)

Was this page helpful?

editSuggest edits
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.