Vue Popup - Getting Started

NOTE
Before you start the tutorial, ensure DevExtreme is installed in your application.

The Popup displays content in a window that overlays the current view.

This tutorial explains how to add a Popup to a page, define its content, and configure its core features. The following control demonstrates the result:

Each section in this tutorial covers a single configuration step. You can also find the full code in the GitHub repository.

View on GitHub

Create a Popup

Add DevExtreme to your Vue application and use the following code to create a Popup:

App.vue
  • <template>
  • <div id="app-container">
  • <DxPopup id="popup">
  • <!-- Configuration goes here -->
  • </DxPopup>
  • </div>
  • </template>
  •  
  • <script>
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { DxPopup } from 'devextreme-vue/popup';
  •  
  • export default {
  • components: {
  • DxPopup
  • }
  • }
  • </script>

Add Content to the Popup

You can define content in the Popup's markup or use the contentTemplate. We recommend that you use the second approach since it can reduce page startup time. Refer to the following help topic for more information: deferRendering.

App.vue
  • <template>
  • <div id="app-container">
  • <DxPopup
  • content-template="popup-content">
  • <template #popup-content>
  • <img src="./assets/dx-logo.png" alt="logo">
  • <p>
  • Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
  • Penatibus et magnis dis parturient. Eget dolor morbi non arcu risus. Tristique magna sit amet purus gravida quis blandit.
  • Auctor urna nunc id cursus metus aliquam eleifend mi in. Tellus orci ac auctor augue mauris augue neque gravida. Nullam vehicula ipsum a arcu.
  • Nullam ac tortor vitae purus faucibus ornare suspendisse sed nisi. Cursus in hac habitasse platea dictumst. Egestas dui id ornare arcu.
  • Dictumst vestibulum rhoncus est pellentesque elit ullamcorper dignissim.
  • </p>
  • <p>
  • Mauris rhoncus aenean vel elit scelerisque mauris pellentesque pulvinar. Neque volutpat ac tincidunt vitae semper quis lectus.
  • Sed sed risus pretium quam vulputate dignissim suspendisse in. Urna nec tincidunt praesent semper feugiat nibh sed pulvinar.
  • Ultricies lacus sed turpis tincidunt id aliquet risus feugiat. Amet cursus sit amet dictum sit amet justo donec enim.
  • Vestibulum rhoncus est pellentesque elit ullamcorper. Id aliquet risus feugiat in ante metus dictum at.
  • </p>
  • </template>
  • </DxPopup>
  • </div>
  • </template>
  •  
  • <script>
  • // ...
  •  
  • export default {
  • // ...
  • }
  • </script>

Show and Hide the Popup

Enable the visible property to show the Popup. In the code below, the value of this property is two-way bound to a variable. The togglePopup() method toggles the value between true and false when users click the Open Popup button.

Users can hide the Popup when they click outside its boundaries. To enable this functionality, set the hideOnOutsideClick property to true.

App.vue
  • <template>
  • <div id="app-container">
  • <DxPopup
  • v-model:visible="isPopupVisible"
  • :hide-on-outside-click="true">
  • <!-- ... -->
  • </DxPopup>
  • <DxButton
  • text="Open popup"
  • @click="togglePopup"
  • />
  • </div>
  • </template>
  •  
  • <script>
  • // ...
  • import { DxButton } from 'devextreme-vue/button';
  •  
  • export default {
  • components: {
  • // ...
  • DxButton,
  • },
  • }
  • </script>

Define the Title

Set the showTitle property to true to display the Popup's title bar and use the title property to define its text:

App.vue
  • <template>
  • <div id="app-container">
  • <DxPopup
  • :show-title="true"
  • title="Information">
  • <!-- ... -->
  • </DxPopup>
  • <!-- ... -->
  • </div>
  • </template>
  •  
  • <script>
  • // ...
  • </script>

Resize the Popup

Use the height and width properties to set the Popup's size. Set the resizeEnabled property to true to allow users to resize the Popup.

App.vue
  • <template>
  • <div id="app-container">
  • <DxPopup
  • :height="500"
  • :width="500"
  • :resize-enabled="true">
  • <!-- ... -->
  • </DxPopup>
  • <!-- ... -->
  • </div>
  • </template>
  •  
  • <script>
  • // ...
  • </script>

Position the Popup

Use the position property to position the Popup within the viewport. Users can also drag and drop the Popup to change its position. To enable this functionalty, set the dragEnabled property to true. Users drag the Popup by its title bar, so make sure that you have configured it.

App.vue
  • <template>
  • <div id="app-container">
  • <DxPopup...
  • :drag-enabled="true"
  • position="center">
  • <!-- ... -->
  • </DxPopup>
  • <!-- ... -->
  • </div>
  • </template>
  •  
  • <script>
  • // ...
  • </script>