Skip to content

Drawer

The floating layer panel that slides out from the screen edge.

Methods

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

  • Local import:in this case you should call TuDrawerBox(options). We have also registered methods for TuDrawerBox, e.g. TuDrawerBox.open(options).

  • Use component:use tu-drawer component.

Basic usage

Click the trigger button to slide out the drawer from the right, click the mask area to close.

Position

Customize the position and click the trigger button to slide out the drawer from the corresponding position.



Custom node

Customize the content by slot, or set the appropriate properties to control whether it is shown or hidden.



Nested

Open a new drawer in the drawer.

You can use popup-container to set the mount position of the pop-up layer node.

Sizes

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



Drawer API

Drawer Attributes

NameDescriptionTypeDefault
v-modelWhether the drawer is visibleBooleanfalse
default-visibleWhether the drawer is visible by default (uncontrolled mode)Booleanfalse
placementWhere the drawer is placedStringright
titleThe title of drawerString-
maskWhether to show the maskBooleantrue
mask-closableClick on the mask layer to be able to closeBooleantrue
closableWhether to show the close buttonBooleantrue
ok-textThe content of the ok buttonString-
cancel-textThe content of the cancel buttonString-
ok-loadingEhether the ok button is in the loading stateBooleanfalse
ok-button-propsProps of confirm buttonButtonProps-
cancel-button-propsProps of cancel buttonButtonProps-
unmount-on-closeWhether to uninstall the node when closeBooleanfalse
widthThe width of the drawer (only available when placement is right, left)Number String250
heightThe height of the drawer (only available when placement is top, bottom)Number String250
popup-containerMount container for popupString HTMLElementbody
drawer-styleDrawer 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 asynchronouslyFunction-
on-before-cancelThe callback function before the cancel event is triggered. If it returns false, no subsequent events will be triggeredFunction-
esc-to-closeWhether to support the ESC key to close the dialogBooleantrue
render-to-bodyWhether the drawer is mounted under the body elementBooleantrue
headerWhether to display high-quality contentBooleantrue
footerWhether to display the bottom contentBooleantrue
hide-cancelWhether to hide the cancel buttonBooleanfalse

Drawer Events

NameDescriptionType
okTriggered when the OK button is clicked.Function
cancelTriggered when the cancel or close button is clicked.Function
openTriggered after the drawer is opened (the animation ends)-
closeTriggered when the drawer is closed (the animation ends)-
before-openTriggered before drawer is opened-
before-closeTriggered before drawer is closed-
NameDescription
headerHeader
titleTitle
footerFooter