JGuang

Drawer

Drawer · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

Drawer

A floating layer that slides in from the edge of the screen.

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Basic: Basic usage of Drawer. Click the trigger button to slide out the drawer from the right, click the mask area to close.
  • Customize popup position: Use placement to customize the position where the drawer will slide out from.
  • Custom node: The content can be customized through title and footer. When set to null, the corresponding dom node won't be rendered.
  • Form in drawer: Use form in drawer.
  • Nested drawer: Nested drawer.
  • Information preview drawer: Used for quick preview of the information. Click the mask area to close.
  • Popup Container: Use getPopupContainer to specify the parent node where the drawer should mount to.

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

Drawer

PropertyDescriptionTypeDefaultValueVersion
autoFocusWhether to focus on the first focusable element by default. Only works when focusLock is turned on.booleantrue2.13.0
closableWhether to show the close button on top-right of the drawer dialogbooleantrue-
confirmLoadingWhether the OK button is in loading stateboolean--
escToExitWhether to enable pressing ESC to close the drawer.booleantrue2.10.0
focusLockWhether to lock the focus in the drawer box.booleantrue2.13.0
maskWhether to show maskbooleantrue-
maskClosableWhether to close the drawer when the mask is clickedbooleantrue-
mountOnEnterWhether to render the drawer component only when it is opened initially.booleantrue-
unmountOnExitWhether to unmount component when hiddenboolean--
visibleVisibility of the drawerboolean--
zIndexSet the zIndex of the drawernumber-2.42.0
placementThe placement of the drawer: top right bottom left'top' | 'right' | 'bottom' | 'left'right-
cancelTextText of the Cancel buttonReactNode--
closeIconCustom the close button on top-right of the drawer dialogReactNode-2.49.0
footerThe footer element. Drawer will not render the footer element when footer is nullReactNode--
okTextText of the OK buttonReactNode--
titleThe title element. Drawer will not render the title element when title is nullReactNode--
bodyStyleThe additional css style for contentCSSProperties-2.9.0
cancelButtonPropsThe props of cancel buttonButtonProps-2.26.0
classNameAdditional css classstring | string[]--
headerStyleThe additional css style for headerCSSProperties-2.9.0
heightThe height of the drawer dialog. Only works when placement is top or bottomstring | number250-
maskStyleStyle of the drawer maskCSSProperties--
okButtonPropsThe props of ok buttonButtonProps-2.26.0
styleAdditional styleCSSProperties--
widthThe width of the drawer dialog. Only works when placement is left or rightstring | number250-
wrapClassNameThe additional class name of the container of the drawer dialogstring | string[]--
afterCloseCallback when drawer is closed() => void--
afterOpenCallback when drawer is opened() => void--
getChildrenPopupContainerSet the mount node for popup such as Select, Tooltip, etc. Default to the drawer dialog.(node: HTMLElement) => Element--
getPopupContainerParent node which the drawer should be rendered to.() => Element() => document.body-
onCancelCallback when the Cancel button is clicked(e: MouseEvent | Event) => void--
onOkCallback when the OK button is clicked(e: Event) => void--