St.download_button in a form

Is it possible to have a st.download_button behave like a st.form_submit_button in a form?

It would have to be the other way around, I think: add download functionality to the form_submit_button.

Check out @snehankekre’s solution from before the download button existed on how to manually add download functionality to a button:

1 Like

i use try except as a workaround

    with st.form('smth'):
        ....
        submitted2 = st.form_submit_button("Submit")

        if submitted2:
            ...

    try:
        st.download_button(
            label="Download data as CSV",
            data=csv_output,
            file_name='test_outputs.csv',
            mime='text/csv',
        )
    except:
        pass

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.