Skip to content

Drawer Component ​

Drawer Component

Drawer component is a floating panel that slides out from the edge of the screen, used to display temporary content or operation areas. It's commonly used for side navigation, settings panels, detail viewing and other scenarios, suitable for content display that needs quick access without interrupting the main page browsing.

Basic Usage ​

Basic drawer component usage, slides out from the left by default, including title, content, and bottom button areas.

Show CodeArrow
CopyGitHub

Slide Direction ​

Drawer component supports sliding out from four directions: left, right, top, bottom, adapting to different interaction scenarios.

Show CodeArrow
CopyGitHub

Size and Style ​

You can customize the drawer's size, padding, shadow, offset and other style properties.

Size Settings

Padding

Offset Settings

Show CodeArrow
CopyGitHub

Button Configuration ​

You can customize the text, type, alignment of bottom buttons, or completely hide the bottom button area and close icon.

Show CodeArrow
CopyGitHub

Interaction Configuration ​

Drawer component provides various interaction configuration options, such as whether to show mask layer, whether to close when clicking mask, whether to close when pressing ESC, whether to limit maximum height, etc.

Interaction Configuration Options

Control whether the drawer background shows a modal overlay
Control whether clicking the modal overlay can close the drawer
Control whether pressing ESC key can close the drawer
Control whether to limit the maximum height of the drawer (applies to left/right directions)
Show CodeArrow
CopyGitHub

Custom Content ​

Through slots, you can customize the drawer's title, content, and bottom areas to achieve more flexible layouts and styles.

Show CodeArrow
CopyGitHub

Event Handling ​

Drawer component provides a series of events for monitoring the drawer's opening, closing, and interaction states.

Show CodeArrow
CopyGitHub

Drawer API ​

TDrawer Attributes ​

AttributeDescriptionTypeAccepted ValuesDefault
modelValueWhether to show drawer (two-way binding)boolean—false
titleDrawer titlestring——
positionDrawer slide directionstringleft/right/top/bottomleft
sizeDrawer sizestring—600px
iconTitle iconstring—inspiration
paddingPaddingarray/number—[12, 16, 12, 16]
box-shadowShadow settingsarray——
is-modalWhether to show mask layerboolean—true
close-on-press-modelWhether to close drawer when clicking maskboolean—true
close-on-press-escapeWhether to close drawer when pressing ESCboolean—true
is-close-iconWhether to show close iconboolean—true
is-footWhether to show bottom buttonsboolean—true
is-set-max-heightWhether to set maximum heightboolean—true
confirm-textConfirm button textstring—Confirm
cancel-textCancel button textstring—Cancel
confirm-typeConfirm button typestringprimary/success/warning/danger/infoprimary
cancel-typeCancel button typestringprimary/success/warning/danger/infodefault
btn-alignButton alignmentstringflex-start/center/flex-endflex-end
offsetOffset positionobject—{ x: 0, y: 0 }

Events ​

Event NameDescriptionParameters
openTriggered when drawer opens—
closeTriggered when drawer closes—
confirmTriggered when confirm button is clicked—
cancelTriggered when cancel button is clicked—

Slots ​

Slot NameDescriptionScope Parameters
defaultDrawer content—
titleCustom title area content—
footerDrawer bottom operation area content—

Style Variables ​

Variable NameDescription
$drawer-bg-colorDrawer background color
$drawer-border-radiusDrawer border radius
$drawer-header-heightDrawer header height
$drawer-header-colorDrawer header text color
$drawer-content-colorDrawer content text color
$drawer-footer-heightDrawer footer area height
$drawer-shadowDrawer shadow
</rewritten_file>

Released under the MIT License