Skip to content

Drawer

A panel that slides out from the edge of the screen.

Basic Usage

The simplest usage, sliding out from the right side.

Custom Direction

Supports top, right, bottom, and left directions.

Custom Size

The width or height can be controlled via the size attribute.

Glassmorphism (Acrylic)

Enabled via the glass attribute for a flagship visual experience.

Resizable

Enable the resizable attribute to allow users to adjust the drawer size by dragging the edge.

Add action buttons via show-footer and the footer slot.

Nested Drawers

The Drawer component supports multi-level nesting, automatically managing z-index to ensure inner drawers always overlay outer ones.

Local Container Reveal (Inner Mode)

Enabled via the inner attribute, the drawer will render using absolute positioning within the nearest relative parent container. Supports all four directions and automatically disables Teleport to ensure correct layering.

Custom Close Icon

You can fully customize the top-right close trigger area via the close-icon slot.

Disable Corners (Square Style)

Rounded corners (flagship aesthetic) are enabled by default, and can be quickly switched to a hardcore square style via the round attribute.

Mask Layer (Modal)

The background mask layer can be enabled or disabled via the modal attribute.

Use in Nuxt

API

Props

PropDescriptionTypeDefault
modelValue / v-modelWhether to show the drawerbooleanfalse
titleTitlestring | (() => VNode) | Component-
placementDrawer position'top' | 'right' | 'bottom' | 'left''right'
sizeDrawer size (width or height)string | number'30%'
modalWhether to show mask layerbooleantrue
closeOnClickModalWhether to close on clicking maskbooleantrue
closeOnPressEscapeWhether to close on pressing ESCbooleantrue
showCloseWhether to show close buttonbooleantrue
closeIconCustom close icon namestring'close'
showHeaderWhether to show headerbooleantrue
showFooterWhether to show footerbooleanfalse
lockScrollWhether to lock viewport scrollbooleantrue
glassWhether to enable glassmorphism (Acrylic) modebooleanfalse
resizableWhether size is adjustablebooleanfalse
minSizeMinimum size (px)number150
maxSizeMaximum size (px)number1000
destroyOnCloseWhether to destroy content on closebooleanfalse
zIndexManually set z-index levelnumber-
teleportToMount nodestring | HTMLElement'body'
beforeCloseHook before close, execute done to close(done: () => void) => void-
roundWhether to show rounded corners (flagship aesthetic)booleantrue
innerWhether to pop up in a specified container (enables absolute positioning)booleanfalse
customClassAdditional class name for drawer containerstring-
modalClassAdditional class name for mask layerstring-
titleStyleCustom style for header titleCSSProperties | string-
contentStyleCustom style for body contentCSSProperties | string-
footerStyleCustom style for footerCSSProperties | string-
drawerStyleCustom style for drawer panel overallCSSProperties | string-

Events

Event NameDescriptionCallback Parameters
openTriggered when panel opens-
openedTriggered when opening animation finishes-
closeTriggered when panel closes-
closedTriggered when closing animation finishes-
resizeTriggered when size is adjusted(size: number)
update:modelValuev-model update event(value: boolean)

Slots

Slot NameDescription
defaultCore content area of the drawer
headerCustomizes the entire header area (overrides title and close button)
titleCustomizes only the title text portion
footerCustomizes the footer content area
close-iconCustomizes the icon inside the close button

Expose

Prop NameDescriptionType
drawerRefDOM element reference of drawer containerHTMLElement | null
handleCloseManually triggers the close process (supports beforeClose hook)(isClickModal?: boolean) => void

Theme Variables

The component is deeply integrated with the YH-UI design system, and all color variables are interfaced with the global theme system, automatically supporting dark mode:

VariableDescriptionDefault
--yh-drawer-bg-colorDrawer panel background colorvar(--yh-bg-color-overlay)
--yh-drawer-shadowDrawer shadow intensityvar(--yh-shadow-lg)
--yh-drawer-title-colorTitle text colorvar(--yh-text-color-primary)
--yh-drawer-border-colorSplit line/border colorvar(--yh-border-color-lighter)
--yh-drawer-header-heightHeader height56px
--yh-drawer-footer-heightFooter height60px
--yh-drawer-paddingContent area padding20px
--yh-drawer-radiusCorner radius sizevar(--yh-radius-xl)
--yh-drawer-transitionAnimation durationvar(--yh-transition-duration)

Released under the MIT License.