Skip to content

FaDrawer

Uses the same business lifecycle and footer conventions as FaDialog. Exposed open(function?) and close(function?) return a Promise; v-model only receives internal state updates. All four directions support edge resizing and retain slide-in/slide-out animations. The caller controls size at every breakpoint.

Drawer Basic

View code
Vue
<template>
	<ElButton type="primary" @click="drawerRef?.open(wait)">异步打开 Drawer</ElButton>
	<FaDrawer ref="drawerRef" title="项目详情" size="42%" :before-close="wait" @confirm-click="confirm">
		<template #default="{ loading }">
			<ElAlert :closable="false" :title="loading ? '正在执行业务钩子…' : '内容已就绪'" type="success" />
		</template>
	</FaDrawer>
</template>

<script setup lang="ts">
import { useTemplateRef } from "vue";

interface DrawerExpose {
	close: (callback?: () => void | Promise<void>) => Promise<void>;
	open: (callback?: () => void | Promise<void>) => Promise<void>;
}

const drawerRef = useTemplateRef<DrawerExpose>("drawerRef");
const wait = async (): Promise<void> => {
	await new Promise<void>((resolve) => {
		window.setTimeout(resolve, 600);
	});
};
const confirm = (): void => {
	drawerRef.value?.close(wait);
};
</script>

Drawer Directions

View code
Vue
<template>
	<div class="demo-row">
		<ElButton @click="open('ltr')">从左侧打开</ElButton>
		<ElButton type="primary" @click="open('rtl')">从右侧打开</ElButton>
		<ElButton @click="open('ttb')">从顶部打开</ElButton>
		<ElButton @click="open('btt')">从底部打开</ElButton>
	</div>
	<FaDrawer ref="drawerRef" :direction="direction" :size="direction === 'rtl' || direction === 'ltr' ? '42%' : '45%'" title="可拖动 Drawer">
		<div class="demo-stack">
			<ElAlert :closable="false" title="拖动内容边缘可改变 Drawer 尺寸" type="info" />
			<p>当前方向:{{ direction }}</p>
		</div>
	</FaDrawer>
</template>

<script setup lang="ts">
import { nextTick, ref, useTemplateRef } from "vue";
import type { DrawerProps } from "element-plus";

const drawerRef = useTemplateRef<{ open: () => Promise<void> }>("drawerRef");
const direction = ref<DrawerProps["direction"]>("rtl");

const open = async (value: DrawerProps["direction"]): Promise<void> => {
	direction.value = value;
	await nextTick();
	await drawerRef.value?.open();
};
</script>

FaDrawer Complete API

Props (46)

Fast and Element Plus 2.14.6 props are merged below. Fast changes appear first; native props that are not forwarded remain visible for compatibility review.

PropertySourceDescriptionTypeDefault
draggableFast overrideAllow dragging.BooleanFasttrueELfalse
appendToBodyFast overrideAppend to body.BooleanFasttrueELfalse
beforeCloseFast overrideCallback before closing.FunctionFastEL
destroyOnCloseFast overrideDestroy overlay content after closing.BooleanFasttrueELfalse
modelValueFast overridev-model value.BooleanFastfalseELfalse
resizableFast overrideAllow drawer resizing.BooleanFastfalseELfalse
showRefreshFast additionShow refresh button.Booleantrue
showFullscreenFast additionShow fullscreen button.Booleantrue
showCloseButtonFast additionShow footer close button.Booleantrue
showConfirmButtonFast additionShow footer confirm button.Booleantrue
disabledConfirmButtonFast additionDisable the Fast footer confirm button.Booleanfalse
closeButtonTextFast additionFooter close-button label.String取消
confirmButtonTextFast additionFooter confirm-button label.String确认
hideFooterFast additionHide footer actions.Booleanfalse
showBeforeCloseFast additionShow the team confirmation before closing.Booleanfalse
afterOpenFast additionFast opening hook; supports async functions.Function
centerEL nativeHorizontally center dialog header/footer content.Booleanfalse
alignCenterEL nativeVertically center the dialog.Booleanfalse
closeIconEL nativeClose-button icon.String / Object / Function
overflowEL nativeAllow dragging the dialog beyond the viewport.Booleanfalse
fullscreenEL nativeFill the viewport with the dialog.Booleanfalse
headerClassEL nativecustom class names for header wrapperString / Array / Object / Booleanfalse
bodyClassEL nativecustom class names for body wrapperString / Array / Object / Booleanfalse
footerClassEL nativecustom class names for footer wrapperString / Array / Object / Booleanfalse
showCloseEL nativeShould show close button at the top right of DrawerBooleantrue
titleEL nativeComponent title.String""
ariaLevelEL nativeOverlay heading level in the accessibility tree.String2
appendToEL nativeOverlay mount target.String / Objectbody
closeOnClickModalEL nativewhether the Drawer can be closed by clicking the maskBooleantrue
closeOnPressEscapeEL nativeIndicates whether Drawer can be closed by pressing ESCBooleantrue
lockScrollEL nativewhether scroll of body is disabled while Drawer is displayedBooleantrue
modalEL nativeShould show shadowing layerBooleantrue
modalPenetrableEL nativewhether the mask is penetrable. The modal attribute must be false.Booleanfalse
openDelayEL nativeTime(milliseconds) before openNumber0
closeDelayEL nativeTime(milliseconds) before closeNumber0
topEL nativeDialog offset from the page top.String
modalClassEL nativeExtra class names for shadowing layerString / Array / Object / Booleanfalse
widthEL nativeComponent width.String / Number
zIndexEL nativeset z-indexNumber
trapFocusEL nativeTrap keyboard focus inside the open overlay.Booleanfalse
headerAriaLevelEL nativeheader's aria-level attributeString2
transitionEL nativeOverlay opening/closing transition name.String / Object
directionEL nativeDrawer's opening directionStringrtl
sizeEL nativeComponent size.String / Number30%
withHeaderEL nativeFlag that controls the header section's existence, default to true, when withHeader set to false, both title attribute and title slot won't workBooleantrue
modalFadeEL nativeFade the drawer overlay.Booleantrue
Events(11)
NameSourceDescriptionParameters / type
openEL nativeFast opening business flow completes.
openedEL nativeOpening animation completes.
closeEL nativeClosing flow completes.
closedEL nativeClosing animation completes.
update:modelValueEL nativeUpdates v-model.
openAutoFocusEL nativeOverlay opens and autofocus completes.
closeAutoFocusEL nativeOverlay closes and focus restoration completes.
resize-startEL nativeDrawer resizing starts.
resizeEL nativeContinuously emitted while drawer size changes during dragging.
resize-endEL nativeDrawer resizing ends.
confirmClickFast additionFast confirm-button click.
Slots(4)
NameSourceDescriptionParameters / type
default({ loading })EL nativeDefault component content.({ loading })
header({ loading, close })EL nativeCustom header or table-header business content.({ loading, close })
titleEL nativeCustom dialog/drawer title.
footer({ loading, close })EL nativeCustom footer actions; overlays provide loading and close.({ loading, close })
Expose(7)
NameSourceDescriptionParameters / type
handleCloseEL nativeInvokes Element Plus internal closing behavior.
loadingFast additionFast business loading state.
visibleFast additionCurrent overlay/context-menu visibility.
openFast additionRuns the Fast asynchronous opening flow.
closeFast additionRuns the Fast asynchronous closing flow.
refreshFast additionRepeats the data request or refreshes business content.
doLoadingFast additionRuns a sync/async function with shared loading and overlay state.

FaDrawer instance methods

handleClose Close

Closes the drawer, invoking the supplied before-close hook.

Signature

ts
handleClose(): void;

Example

vue
<template>
	<FaDrawer ref="componentRef" />
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaDrawer } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaDrawer>>();
componentRef.value?.handleClose();
</script>

Input

This method has no input parameters.

Returns

ValueTypeDescription
resultvoidNo return value.

open Open

Opens the dialog.

Signature

ts
open(openFunction?: () => void | Promise<void>): Promise<void>;

Example

vue
<template>
	<FaDrawer ref="componentRef" />
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaDrawer } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaDrawer>>();
const saveData = async () => Promise.resolve();
const result = await componentRef.value?.open(async () => saveData());
</script>

Input

InputTypeRequired / defaultDescription
openFunction(() => void | Promise<void>) | undefinedOptionalOptional synchronous/asynchronous task before the opening animation.

Returns

ValueTypeDescription
resultPromise<void>Asynchronous result; callers handle Promise rejection.

close Close

Closes the dialog.

Signature

ts
close(closeFunction?: () => void | Promise<void>): Promise<void>;

Example

vue
<template>
	<FaDrawer ref="componentRef" />
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaDrawer } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaDrawer>>();
const saveData = async () => Promise.resolve();
const result = await componentRef.value?.close(async () => saveData());
</script>

Input

InputTypeRequired / defaultDescription
closeFunction(() => void | Promise<void>) | undefinedOptionalOptional synchronous/asynchronous task before the closing animation.

Returns

ValueTypeDescription
resultPromise<void>Asynchronous result; callers handle Promise rejection.

refresh Refresh

Refreshes the dialog.

Signature

ts
refresh(): Promise<void>;

Example

vue
<template>
	<FaDrawer ref="componentRef" />
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaDrawer } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaDrawer>>();
const result = await componentRef.value?.refresh();
</script>

Input

This method has no input parameters.

Returns

ValueTypeDescription
resultPromise<void>Asynchronous result; callers handle Promise rejection.

doLoading Loading

Runs a task with dialog loading state.

Signature

ts
doLoading(loadingFunction: () => void | Promise<void>): Promise<void>;

Example

vue
<template>
	<FaDrawer ref="componentRef" />
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaDrawer } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaDrawer>>();
const saveData = async () => Promise.resolve();
const result = await componentRef.value?.doLoading(async () => saveData());
</script>

Input

InputTypeRequired / defaultDescription
loadingFunction() => void | Promise<void>RequiredSynchronous or asynchronous task to run while loading.

Returns

ValueTypeDescription
resultPromise<void>Asynchronous result; callers handle Promise rejection.