Need a detailed view without crowding the main dashboard? `st.dialog` turns a Python function into a modal dialog: its interface appears over the app, temporarily blocking interaction with the page beneath it. It is a decorator, not a container like `st.tabs` or `st.container`. section 7.5.1
Listing 7.1 A drilldown dialog
import streamlit as st
@st.dialog("Drilldown", width="large")
def drilldown(main_df, compare_df):
main_tab, compare_tab = st.tabs(["Main", "Compare"])
with main_tab:
st.dataframe(main_df, use_container_width=True)
with compare_tab:
st.dataframe(compare_df, use_container_width=True)
The drilldown example decorates a function with `@st.dialog("Drilldown", width="large")`. Calling that function with two dataframes opens a dialog with Main and Compare tabs. The `width` option can be `small` (500 pixels) or `large` (750 pixels). section 7.5.1
A button can trigger the decorated function. Unlike an ordinary app-wide rerun, interacting with a widget inside the dialog reruns only that function. This lets a drilldown dimension selector update the dialog without clearing the triggering button’s clicked state. The behavior comes from `st.fragment`. section 7.5.3
Save from a dialog
An Add Haiku button opens a dialog containing a text area and Save button. Saving calls a service that writes to a database and reports success or failure. On success, `st.rerun()` reruns the whole app, closing the dialog because its triggering button is no longer clicked. This deliberate full rerun differs from a widget interaction that reruns only the dialog. section 8.5.2
