When user close st.dialog, i want user use my button not use x or other method

The st.dialog doc not show how to stop the x or esc, I hope can use my button not x or esc.

Because I set a st.session_state[β€œkey”] to make data_editor can reset.
There is any method can solve it?

1 Like

You can refer to the following methods to make adjustments, where the method of hiding buttons is the CSS style design in β€˜st. html’.

import streamlit as st

            div[aria-label="dialog"]>button[aria-label="Close"] {
                display: none;

def test_dialog():
    st.write('Hello Streamlit')

if st.button(label='open_dialog', key='test_dialog', type='primary'):

Thank!!! This help me a lot.
I also want to know how to prevent the dialog from closing when the user clicks on the grey background(purple section).
I can’t find name of the grey background(purple section).

1 Like

There is also an open request around customizing the behavior around the X to close. The discussion includes ignoring the X and basically configuring the dialog to be dismissible or not. Feel free to vote or add to the conversation: