The Quasar Modal component is a UI overlay, which offers extended screen space to allow the user to get more work done. Modals are used for such things as login or signup dialogs, for message composition windows or extended option selections, like offering a list of users to be friends with.
Installation
Edit /quasar.conf.js:
framework: { components: ['QModal'],
// optional if you want to use // directive `v-close-overlay` directives: ['CloseOverlay'] }
Modals are responsive to the width of the window (see demo on a desktop and resize browser window). Sometimes you need to always have a Modal maximized or minimized regardless of window width, so to do this, Quasar offers the minimized and maximized props:
<q-modalmaximized> ... </q-modal>
Vue Properties
Property
Type
Description
minimized
Boolean
Always minimized regardless of screen width.
maximized
Boolean
Always maximized regardless of screen width.
no-route-dismiss
Boolean
By default, when route changes, the modal gets closed. This prop inhibits the behavior.
no-esc-dismiss
Boolean
Disable Modal dismissal by hitting Escape key.
no-backdrop-dismiss
Boolean
Disable Modal dismissal by clicking/tapping on backdrop.
content-css
Object/Array/String
Applies CSS style to Modal container. Use Object or Array of Object when also specifying position prop.
content-classes
Object/Array/String
Classes to apply to Modal inner content.
position
String
Stick Modal to one of the screen edges (top, right, bottom, left).
position-classes
String
Space delimited CSS classes that overwrite the default ‘items-center justify-center’ classes. Gets overridden by position if present.
transition
String
Vue transition to use. Quasar comes with a q-modal transition out of the box. But you can write your own Vue transitions using CSS and use them.
enter-class
String
enter transition class name
leave-class
String
leave transition class name
Vue Methods
Method
Description
show
Open Modal. Takes one optional Function parameter to trigger after Modal is opened.
hide
Close Modal. Takes one optional Function parameter to trigger after Modal is closed.
toggle
Toggle open/close Modal state. Takes one optional Function parameter to trigger after Modal is toggled.
Vue Events
Event Name
Description
@show
Triggered right after Modal is opened.
@hide
Triggered right after Modal is closed.
@escape-key
Triggered if the Modal is dismissed with the Escape key on desktops.
When making layout inside a modal, Quasar has a special component called QModalLayout (described in next section), which takes care of any needed structure.
Do NOT use QLayout inside a QModal. Instead, use the simplified QModalLayout.