reactjsmaterial-ui

How can I add the close icon in the top right corner of the Material UI Dialog Header?


I Want to add the close icon in the header section at the top right corner.

I am using the Material UI Dialog. Everything is working fine, but I want the close button on top section, as shown in the image:

Dialog with close button in top right corner


Solution

  • Put the image icon in the title, and use the css to position it correctly, Try this:

    Apply this css on close image:

    let closeImg = {cursor:'pointer', float:'right', marginTop: '5px', width: '20px'};
    
    <Dialog
        modal={false}
        open={true}
        title={
                <div>
                    ABC 
                    <img src='https://d30y9cdsu7xlg0.cloudfront.net/png/53504-200.png' style={closeImg}/>
                </div>
            }
    >
        Hello
    </Dialog>
    

    Check the working fiddle: https://jsfiddle.net/ve0qbgLr/