Search results

Customize the Dialog appearance in JavaScript Dialog control

You can customize the dialog appearance by providing dialog template as string or HTML element to the content property. In the following sample, dialog is customized as error window appearance.

Source
Preview
app.ts
index.html
styles.css
import { enableRipple } from '@syncfusion/ej2-base';
import { Button } from '@syncfusion/ej2-buttons';
import { Dialog } from '@syncfusion/ej2-popups';

let dialogObj: Dialog = new Dialog({
    header: 'File and Folder Rename',
    content: document.getElementById("dlgContent"),
    showCloseIcon: true,
    visible: false,
    buttons: [{
        buttonModel: { isPrimary: true, content: 'Close' }, click:  function() {
            this.hide()
        }
    }],
    target: document.querySelector('body'),
    width: '400px',
    animationSettings: { effect: 'Zoom' },
    beforeOpen: onBeforeopen
});
dialogObj.appendTo('#dialog');

document.getElementById('openBtn').onclick = (): void => {
    dialogObj.show();
};

function onBeforeopen(): void {
    document.getElementById('dlgContent').style.visibility = 'visible';
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Essential JS 2 Dialog customization</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="TypeScript UI Components" />
    <meta name="author" content="Syncfusion" />
    <link href="styles.css" rel="stylesheet" />
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-base/styles/bootstrap.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-buttons/styles/bootstrap.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-inputs/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-popups/styles/bootstrap.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
    <div id='loader'>LOADING....</div>
    <div id='container'>
        <div id="target">
            <center><button id="openBtn" class="e-control e-btn">Open</button></center>
            <div id="dialog"></div>
            <div id="dlgContent" style="visibility: hidden" class ='dialog-content'>
                <div class='msg-wrapper  col-lg-12'>
                    <span class='e-icons close-icon col-lg-2'></span>
                    <span  class='error-msg col-lg-10'>
                        Can not rename 'pictures' because a file or folder with that name already exists 
                    </span>
                </div>
                <div class='error-detail col-lg-8'>
                    <span>Specify a different name</span>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
html,
body,    
#container {
    height: 100%;
    overflow: hidden;
    width: 100%;
}

#loader {
    color: #008cff;
    height: 40px;
    left: 45%;
    position: absolute;
    top: 45%;
    width: 30%;
}
.row {
    padding: 10px 3px;
}

.close-icon {
    width: 24px;
    height: 24px;
    position: relative;
    display: inline-block;
}
.error-msg {
   color: #66afe9;
    display: inline-block;
    position: relative;
    top: -29px;
    left: 32px;
}
.error-detail {
    position: relative;
    left: 45px;
    margin: 0 0 21px;
}
/* csslint ignore:start */
.e-icons.close-icon.col-lg-2:before {
    content: '\e7e9';
    font-size: 26px;
    color:#d9534f;
    position: relative;
    left: -12px;
}

.e-dialog .e-footer-content {
    background-color: #f8f8f8;
}

.e-dialog.e-control.e-popup, .e-dialog.e-control.e-popup .e-dlg-header-content {
    background-color: #d9edf7;
}
.e-dialog.e-control.e-popup {
    padding:3px;
}
.e-dialog.e-control .e-dlg-header-content {
    padding: 10px;
}
.e-dialog.e-control .e-footer-content {
    padding: 8px 12px;
}

.e-dialog.e-control .e-dlg-content {
  padding: 15px 0 0;
}

.msg-wrapper.col-lg-12 {
    margin-top: 20px;
}
/* csslint ignore:end */