Drawer
An Element Plus drawer with asynchronous confirmation, cancellation, custom footer and vertical tabs. Supports Chalk/OEM themes.
Basic usage
Loading example…
Basic usage
Custom title
Loading example…
Custom title
Custom footer
Loading example…
Custom footer
Custom tabs
Loading example…
Custom tabs
Hide footer buttons
Loading example…
Hide footer buttons
Installation
ts
import NfDrawer from '@94ai-plus/nf-drawer'
import 'element-plus/dist/index.css'
import '@94ai-plus/nf-theme-chalk/nf-drawer.css'
app.use(NfDrawer)Props
| Attribute | Description | Type | Accepted values | Default |
|---|---|---|---|---|
| showConfirmButton | Whether to show the confirm button | boolean | — | true |
| showCancelButton | Whether to show the cancel button | boolean | — | true |
| cancelButtonText | Cancel button text | string | — | Current locale |
| confirmButtonText | Confirm button text | string | — | Current locale |
| currentTab | Current tab name; supports v-model:current-tab; invalid values fall back to the first tab | string | — | undefined |
| tabs | Tab data: name is the tab name, slot names its content slot | ITabItem[] / DrawerTabItem[] | — | undefined |
| modelValue | Visibility with v-model; takes precedence over visible | boolean | — | false |
| visible | Visibility with v-model:visible | boolean | — | false |
| title | Title | string | — | '' |
| customClass | Custom class name | string | — | '' |
| wrapperClosable | Whether clicking the backdrop closes Drawer | boolean | — | false |
| closeOnClickModal | Backdrop closing; when explicit, overrides wrapperClosable | boolean | — | wrapperClosable |
| closeOnPressEscape | Whether Escape closes Drawer | boolean | — | false |
| direction | Drawer opening direction | string | rtl / ltr / ttb / btt | rtl |
| size | Drawer size: width for horizontal, height for vertical | string / number | — | 30% |
| beforeClose | Before-close callback; done() continues closing; successful confirmation bypasses it | (done: (cancel?: boolean) => void) => void | — | — |
| withHeader / showClose / appendTo / appendToBody / destroyOnClose / resizable / modal / lockScroll / openDelay / closeDelay / zIndex / headerClass / bodyClass / footerClass | Forwards the same Element Plus Drawer properties, defaults and behavior | Element Plus Drawer | — | Element Plus Drawer |
Events
| Event | Description | Payload |
|---|---|---|
| cancel | Drawer cancel button callback | event: MouseEvent |
| confirm | Drawer confirm callback; done() closes, error() only stops loading | done: () => void, error: () => void |
| changeTab | Tab change callback, receiving the current tab name | name: string |
| update:modelValue | Emitted when visibility changes | value: boolean |
| update:visible | Emitted when visibility changes | value: boolean |
| update:currentTab | Synchronizes the active tab; undefined for an empty list | value: string / undefined |
| open / opened / close / closed / openAutoFocus / closeAutoFocus | Forwards Element Plus Drawer opening, closing and autofocus events | — |
| resize-start / resize / resize-end | Emitted when resizing starts, moves and ends | event: MouseEvent, size: number |
Slots
| Slot | Description | Payload |
|---|---|---|
| default | Drawer content | — |
| title | Drawer title content | close, titleId, titleClass |
| header | Drawer header content; takes precedence over the title slot | close, titleId, titleClass |
| footer | Drawer footer content; hidden when both buttons are hidden | — |
| tabs[].slot | Tab content named by tabs[].slot | — |
Types
ts
import type { DrawerProps, DrawerTabItem, ITabItem, DrawerInstance } from '@94ai-plus/nf-drawer'
// DrawerTabItem: { name: string; slot: string }; ITabItem = DrawerTabItem
// DrawerInstance: closeDrawer(), handleClose(); both run beforeCloseMigration
Replace Vue 2 :visible.sync with v-model:visible. wrapperClosable maps to closeOnClickModal (the latter wins); customClass is merged onto the panel. The legacy title slot maps to header; otherwise the title prop renders normally. Hiding both buttons hides the entire footer, including custom content. Confirmation callbacks are single-use and invalidated on close/reopen/unmount. SSR renders a placeholder until mounted.
