Skip to content

Modal ​

Informs users while preserving the current page state.

Methods ​

  • Global method:Tu View Plus has added a global method $modal for app.config.globalProperties. So in a vue instance you can call Modal like what we did in this page.

  • Local import:in this case you should call TuMessage(options). We have also registered methods for different types, e.g. TuMessage.success(options). You can call TuMessage.closeAll() to manually close all the instances.

  • Use component:use tu-modal component.

Basic usage ​

The basic usage of the modal.

Types ​

There are four types of notice: info, success, warning, error, and only a confirmation button is provided to close the notice. The message defaults to enable simple and hideCancel by default, if you want to cancel, you can set it again.

Nested ​

Open a new modal in the modal.

Async close ​

Asynchronous shutdown can be implemented more concisely through on-before-ok

Set width is auto to make the dialog box adapt to the width

Draggable ​

Enables the draggable property, which allows the user to drag the dialog.

Fullscreen ​

Enable the fullscreen property to make the dialog fill the entire container.

Sizes ​

Besides default size, tu-modal component provides three additional sizes for you to choose among different scenarios. Use attribute size to set additional sizes with mini, small, large.


NameDescriptionTypeDefault
visible(v-model)Whether the modal is visibleBoolean-
default-visibleWhether the modal is visible by default (uncontrolled state)Booleanfalse
widthThe width of the dialog box, if not set, the width value in the style will be usedNumber String-
topThe height from the top of the dialog box. It does not take effect when the center display is turned on.Number String-
maskWhether to show the maskBooleantrue
titleTitleString-
title-alignHorizontal alignment of the titleStringcenter
align-centerWhether the dialog box is displayed in the centerBooleantrue
unmount-on-closeWhether to uninstall the node when closeBooleanfalse
mask-closableWhether to close the modal when click the maskBooleantrue
hide-cancelWhether to hide the cancel buttonBooleanfalse
simpleWhether to enable simple modeBooleanfalse
closableWhether to show the close buttonBooleantrue
ok-textThe content of the confirm buttonString-
cancel-textThe content of the cancel buttonString-
ok-loadingWhether the confirm button is in the loading stateBooleanfalse
ok-button-propsProps of confirm buttonButtonProps-
cancel-button-propsProps of cancel buttonButtonProps-
footerWhether to show the footerBooleantrue
render-to-bodyWhether the modal is mounted under the body elementBooleantrue
popup-containerMount container for modalString HTMLElementbody
mask-styleMask styleString Object-
modal-classThe classname of the modalString Array-
modal-styleModal styleString Object-
on-before-okThe callback function before the ok event is triggered. If false is returned, subsequent events will not be triggered, and done can also be used to close asynchronously.Function-
on-before-cancelThe callback function before the cancel event is triggered. If it returns false, no subsequent events will be triggered.Function-
esc-to-closeWhether to support the ESC key to close the dialogBooleantrue
draggableWhether to support dragBooleanfalse
fullscreenWhether to enable full screenBooleanfalse
mask-animation-nameMask layer animation nameString-
modal-animation-nameModal animation nameString-
body-classThe classname of the modalString Array-
body-styleModal styleString Object-
NameDescriptionType
okTriggered when the OK button is clickedFunction
cancelTriggered when the cancel/close button is clickedFunction
openTriggered after the modal is opened (the animation ends)-
closeTriggered after the modal is closed (the animation ends)-
before-openTriggered before dialog is opened-
before-closeTriggered before dialog is closed-
NameDescription
titleTitle
footerFooter