API
To show or hide the Popup programmatically, bind the visible property of Popup to a component property. After that, change the latter property, and the Popup will appear or disappear.
- <template>
- <div>
- <DxPopup
- title="Popup Title"
- v-model:visible="isPopupVisible">
- <template #content>
- <p>Popup content</p>
- </template>
- </DxPopup>
- <DxButton
- text="Show the Popup"
- @click="showPopup"
- />
- <DxButton
- text="Hide the Popup"
- @click="hidePopup"
- />
- </div>
- </template>
- <script>
- import 'devextreme/dist/css/dx.fluent.blue.light.css';
- import { DxPopup } from 'devextreme-vue/popup';
- import { DxButton } from 'devextreme-vue/button';
- export default {
- components: {
- DxPopup,
- DxButton
- },
- data() {
- return {
- isPopupVisible: false
- }
- },
- methods: {
- showPopup() {
- this.isPopupVisible = true;
- },
- hidePopup() {
- this.isPopupVisible = false;
- }
- }
- }
- </script>
User Interaction
Enable the showCloseButton property to allow a user to hide the Popup component by clicking the Close button.
- <template>
- <DxPopup
- :show-title="true"
- :show-close-button:"true"
- />
- </template>
- <script>
- import 'devextreme/dist/css/dx.fluent.blue.light.css';
- import { DxPopup } from 'devextreme-vue/popup';
- export default {
- components: {
- DxPopup
- }
- }
- </script>
The Popup can also be hidden when a user clicks outside of it. To control this Popup behavior, use the hideOnOutsideClick property.
- <template>
- <DxPopup
- v-model:visible="isPopupVisible"
- :hide-on-outside-click="true"
- title="Popup Title"
- />
- </template>
- <script>
- import 'devextreme/dist/css/dx.fluent.blue.light.css';
- import { DxPopup } from 'devextreme-vue/popup';
- export default {
- components: {
- DxPopup
- },
- data() {
- return {
- isPopupVisible: true
- };
- }
- }
- </script>
You can also implement a custom Close button inside the Popup. Refer to the following demo for more information:
Events
To execute certain commands before or after the Popup was shown/hidden, handle the showing, shown, hiding or hidden event. If the event handling function is not going to be changed during the lifetime of the UI component, assign it to the corresponding onEventName property when you configure the UI component.
- <template>
- <DxPopup ...
- @showing="onShowing"
- @shown="onShown"
- @hiding="onHiding"
- @hidden="onHidden"
- />
- </template>
- <script>
- import 'devextreme/dist/css/dx.fluent.blue.light.css';
- import { DxPopup } from 'devextreme-vue/popup';
- export default {
- components: {
- DxPopup
- },
- methods: {
- onShowing(e) {
- // Handler of the 'showing' event
- },
- onShown(e) {
- // Handler of the 'shown' event
- },
- onHiding(e) {
- // Handler of the 'hiding' event
- },
- onHidden(e) {
- // Handler of the 'hidden' event
- }
- }
- }
- </script>