Drawer

Drawer is a panel that slides out from the edge of the screen which containing supplementary content.

Basic

Basic usage of Drawer

Placement

Set the placement prop to 'top', 'right', 'bottom', or 'left' to arrange where the Drawer slide out from.

Width & Height

We can adjust Drawer via with height & width prop.

Custom Style

Drawer allow us to set extra class via headerClass, bodyClass & footerClass

Closable

Set closeable to false will hide Drawer close icon.

API

Drawer
PropDescriptionTypeDefault
placementDrawer placement'top' | 'right' | 'bottom' | 'left' 'right'
widthDrawer width, (only available when placement is 'left' or 'right'string | number400
heightDrawer height, (only available when placement is 'top' or 'bottom'string | number400
titleTitle of Drawerstring | ReactNode-
footerFooter of Drawerstring | ReactNode-
headerClassExtra class for Drawer header (! modifier recommended for tailwind css overiding)string-
bodyClassExtra class for Drawer body (! modifier recommended for tailwind css overiding)string-
footerClassExtra class for Drawer footer (! modifier recommended for tailwind css overiding)string-
showBackdropWhether the display Drawer backdropbooleantrue
lockScrollWhether to disable window scrolling when Drawer is openbooleantrue
isOpenWhether to display Drawerbooleanfalse
styleStyle for Drawer & backdropobject: { content: object, overlay: object }-
portalClassNameClass name that append to Drawer portalstring-
bodyOpenClassNameClass name that append to body while Drawer is openstring-
htmlOpenClassNameClass name that append to html while Drawer is openstring-
overlayClassNameClass name for Drawer backdropstring-
appElementSetting external node to Drawer contentSafeHTMLElement | SafeHTMLCollection | SafeNodeList | SafeHTMLElement[]-
onAfterOpenCallback function after Drawer open(overlayElement: HTMLElement, contentElement: HTMLElement) => void-
closableWhether show Drawer close iconbooleantrue
onCloseCallback function after click on Drawer close icon(event: Event) => void-
onRequestCloseCallback function after Drawer close(event: Event) => void-
closeTimeoutMSTimeout speed during Drawer close(event: Event) => void300
shouldFocusAfterRenderBoolean indicating if the Drawer should be focused after renderbooleantrue
shouldReturnFocusAfterCloseBoolean indicating if the Drawer should restore focus to the element that had focus prior to its displaybooleantrue
preventScrollBoolean indicating if the Drawer should use the preventScroll flag when restoring focus to the element that had focus prior to its displaybooleanfalse
shouldCloseOnOverlayClickWhether to close Drawer when the backdrop is clickedbooleantrue
shouldCloseOnEscWhether to close Drawer when esc key pressedbooleantrue
parentSelectorFunction that will be called to get the parent element that the Drawer will be attached to() => document.body() => document.body
overlayRefDrawer backdrop ref(node: Node) => void-
contentRefDrawer content ref(node: Node) => void-