# Execution flow

Source: https://docs.streamlit.io/develop/api-reference/execution-flow

## Change execution

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

**[Modal dialog](https://docs.streamlit.io/develop/api-reference/execution-flow/st.dialog)**: Insert a modal dialog that can rerun independently from the rest of the script.

```python
@st.dialog("Sign up")
def email_form():
    name = st.text_input("Name")
    email = st.text_input("Email", type="email")
```

**[Fragments](https://docs.streamlit.io/develop/api-reference/execution-flow/st.fragment)**: Define a fragment to rerun independently from the rest of the script.

```python
@st.fragment(run_every="10s")
def fragment():
    df = get_data()
    st.line_chart(df)
```

**[Rerun script](https://docs.streamlit.io/develop/api-reference/execution-flow/st.rerun)**: Rerun the script immediately.

```python
st.rerun()
```

**[Stop execution](https://docs.streamlit.io/develop/api-reference/execution-flow/st.stop)**: Stops execution immediately.

```python
st.stop()
```

## Group multiple widgets

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](https://docs.streamlit.io/develop/api-reference/execution-flow/st.form)**: Create a form that batches elements together with a “Submit" button.

```python
with st.form(key='my_form'):
    name = st.text_input("Name")
    email = st.text_input("Email", type="email")
    st.form_submit_button("Sign up")
```

**[Form submit button](https://docs.streamlit.io/develop/api-reference/execution-flow/st.form_submit_button)**: Display a form submit button.

```python
with st.form(key='my_form'):
    name = st.text_input("Name")
    email = st.text_input("Email", type="email")
    st.form_submit_button("Sign up")
```
