Customization in Vue Predefined dialogs component
11 Jun 202419 minutes to read
You can customize the predefined dialogs buttons by using below properties.
-
okButton
- Use this property to customize OK button text. -
cancelButton
- Use this property to customize Cancel button text.
Use the following code snippet for alert, confirm and prompt to customize the predefined dialogs action buttons.
For alert dialog , customized the default dialog button content as Dismiss
by using the text
property.
For confirm dialog, customized the default dialog buttons content as Yes
and No
by using the text
property and also customized the dialog button icons by using icon
property.
For prompt dialog , customized the default dialog buttons content as Connect
and Close
by using text
property.
Alert action button
<template>
<div class="predefinedDialog">
<ejs-button id="alertDlgBtn" v-on:click="alertBtnClick" cssClass="e-danger">Alert</ejs-button>
</div>
</template>
<script setup>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
const alertBtnClick = () => {
DialogUtility.alert({
title: 'Good job!',
content: 'You clicked the alert button!',
width: '250px',
okButton: { text: 'Done' }
});
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialog {
height: 100%;
min-height: 350px;
}
.e-dialog.customClass {
min-width: 300px;
min-height: 200px;
}
</style>
<template>
<div class="predefinedDialog">
<ejs-button id="alertDlgBtn" v-on:click="alertBtnClick" cssClass="e-danger">Alert</ejs-button>
</div>
</template>
<script>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
export default {
name: "App",
components: {
"ejs-button":ButtonComponent
},
data: function () {
return {};
},
methods: {
alertBtnClick: function () {
DialogUtility.alert({
title: 'Good job!',
content: 'You clicked the alert button!',
width:'250px',
okButton: { text: 'Done'}
});
},
},
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialog {
height: 100%;
min-height: 350px;
}
.e-dialog.customClass {
min-width: 300px;
min-height: 200px;
}
</style>
Confirm action buttons
<template>
<div class="predefinedDialogs">
<ejs-button id="confirmDlgBtn" v-on:click="confirmBtnClick" cssClass="e-success">Confirm</ejs-button>
</div>
</template>
<script setup>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
const confirmBtnClick = () => {
DialogUtility.confirm({
title: 'Delete file',
content: "Are you sure you want to permanently delete these file?",
width: '300px',
okButton: { text: 'Yes', icon: 'e-icons e-check' },
cancelButton: { text: 'No', icon: 'e-icons e-close' }
});
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
<template>
<div class="predefinedDialogs">
<ejs-button id="confirmDlgBtn" v-on:click="confirmBtnClick" cssClass="e-success">Confirm</ejs-button>
</div>
</template>
<script>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
export default {
name: "App",
components: {
"ejs-button": ButtonComponent
},
data: function () {
return {};
},
methods: {
confirmBtnClick: function () {
DialogUtility.confirm({
title: 'Delete file',
content: "Are you sure you want to permanently delete these file?",
width: '300px',
okButton: { text: 'Yes', icon: 'e-icons e-check' },
cancelButton: { text: 'No', icon: 'e-icons e-close' }
});
},
},
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
Prompt action buttons
<template>
<div class="predefinedDialogs">
<ejs-button id="promptDlgBtn" v-on:click="promptBtnClick" :isPrimary="true">Prompt</ejs-button>
</div>
</template>
<script setup>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
const promptBtnClick = () => {
DialogUtility.confirm({
title: 'Join chat group',
width: '300px',
content: '<p>Enter your name: </p><input id= "inputEle" type="text" name="Required" class="e-input" placeholder="Type here.." />',
okButton: { text: 'Connect' },
cancelButton: { text: 'Close' }
});
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
<template>
<div class="predefinedDialogs">
<ejs-button id="promptDlgBtn" v-on:click="promptBtnClick" :isPrimary="true">Prompt</ejs-button>
</div>
</template>
<script>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
export default {
name: "App",
components: {
"ejs-button": ButtonComponent
},
data: function () {
return {};
},
methods: {
promptBtnClick: function () {
DialogUtility.confirm({
title: 'Join chat group',
width: '300px',
content: '<p>Enter your name: </p><input id= "inputEle" type="text" name="Required" class="e-input" placeholder="Type here.." />',
okButton: { text: 'Connect' },
cancelButton: { text: 'Close' }
});
},
},
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
Show or hide dialog close button
When rendering the predefined dialogs through utility methods, You can close the dialog using the following ways. The default values of closeOnEscape
and showCloseIcon
is false
.
- By pressing the escape key if the closeOnEscape property is enabled.
- By clicking the close button if the showCloseIcon property is enabled.
You can also manually close the Dialogs by creating an instance to the dialog and call the hide method.
Use the following code for alert, confirm and prompt to demonstrates the different ways of hiding the utility dialog.
Alert dialog close button
<template>
<div class="predefinedDialogs">
<ejs-button id="alertDlgBtn" v-on:click="alertBtnClick" cssClass="e-danger">Alert</ejs-button>
</div>
</template>
<script setup>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
const alertBtnClick = () => {
DialogUtility.alert({
title: "Low battery",
content: "10% of battery remaining",
width: "250px",
showCloseIcon: true,
closeOnEscape: true
});
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
<template>
<div class="predefinedDialogs">
<ejs-button id="alertDlgBtn" v-on:click="alertBtnClick" cssClass="e-danger">Alert</ejs-button>
</div>
</template>
<script>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
export default {
name: "App",
components: {
"ejs-button": ButtonComponent
},
data: function () {
return {};
},
methods: {
alertBtnClick: function () {
DialogUtility.alert({
title: "Low battery",
content: "10% of battery remaining",
width: "250px",
showCloseIcon: true,
closeOnEscape: true
});
},
},
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
Confirm dialog close button
<template>
<div class="predefinedDialogs">
<ejs-button id="confirmDlgBtn" v-on:click="confirmBtnClick" cssClass="e-success">Confirm</ejs-button>
</div>
</template>
<script setup>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
const confirmBtnClick = () => {
DialogUtility.confirm({
title: 'Delete file',
content: "Are you sure you want to permanently delete these items?",
width: '300px',
showCloseIcon: true,
closeOnEscape: true
});
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
<template>
<div class="predefinedDialogs">
<ejs-button id="confirmDlgBtn" v-on:click="confirmBtnClick" cssClass="e-success">Confirm</ejs-button>
</div>
</template>
<script>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
export default {
name: "App",
components: {
"ejs-button": ButtonComponent
},
data: function () {
return {};
},
methods: {
confirmBtnClick: function () {
DialogUtility.confirm({
title: 'Delete file',
content: "Are you sure you want to permanently delete these items?",
width: '300px',
showCloseIcon: true,
closeOnEscape: true
});
},
},
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
Prompt dialog close button
<template>
<div class="predefinedDialogs">
<ejs-button id="promptDlgBtn" v-on:click="promptBtnClick" :isPrimary="true">Prompt</ejs-button>
</div>
</template>
<script setup>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
const promptBtnClick = () => {
DialogUtility.confirm({
title: "Join chat group",
width: "300px",
content: '<p>Enter your name: </p><input id= "inputEle" type="text" name="Required" class="e-input" placeholder="Type here.." />',
showCloseIcon: true,
closeOnEscape: true
});
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
<template>
<div class="predefinedDialogs">
<ejs-button id="promptDlgBtn" v-on:click="promptBtnClick" :isPrimary="true">Prompt</ejs-button>
</div>
</template>
<script>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
export default {
name: "App",
components: {
"ejs-button": ButtonComponent
},
data: function () {
return {};
},
methods: {
promptBtnClick: function () {
DialogUtility.confirm({
title: "Join chat group",
width: "300px",
content: '<p>Enter your name: </p><input id= "inputEle" type="text" name="Required" class="e-input" placeholder="Type here.." />',
showCloseIcon: true,
closeOnEscape: true
});
},
},
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
Customize dialog content
You can load custom content in predefined dialogs using the content
property.
Use the following code to customize the dialog content to render the custom TextBox component inside the prompt dialog to get the username from the user.
<template>
<div class="predefinedDialogs">
<ejs-button id="confirmDlgBtn" v-on:click="confirmBtnClick" cssClass="e-success">Confirm </ejs-button>
</div>
</template>
<script setup>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
const confirmBtnClick = () => {
DialogUtility.confirm({
title: "Join chat group",
content: '<p>Enter your name: </p><input class="e-input"/>',
width: "350px",
});
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>
<template>
<div class="predefinedDialogs">
<ejs-button id="confirmDlgBtn" v-on:click="confirmBtnClick" cssClass="e-success">Confirm </ejs-button>
</div>
</template>
<script>
import { DialogUtility } from "@syncfusion/ej2-vue-popups";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
export default {
name: "App",
components: {
"ejs-button": ButtonComponent
},
data: function () {
return {};
},
methods: {
confirmBtnClick: function () {
DialogUtility.confirm({
title: "Join chat group",
content: '<p>Enter your name: </p><input class="e-input"/>',
width: "350px",
});
},
},
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material.css";
.predefinedDialogs {
height: 100%;
min-height: 350px;
}
</style>