Introducing PrimeReact v11-alpha 🎉Discover Now

Drawer

An unstyled slide-in panel component with built-in focus trap, scroll lock, and dismissable backdrop.

Build fully custom slide-in panels with complete control over layout and styling.

basic-demo

Pre-styled Versions

Choose a pre-styled library to use Drawer with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Compound component API with sub-components: Root, Trigger, Portal, Backdrop, Popup, Header, Title, Close, Content, Footer
  • Five position modes: left, right, top, bottom, full
  • Integrated focus trap with automatic focus management on open and close
  • Dismissable Backdrop with click-outside detection
  • Scroll lock support via blockScroll

Usage#

import { Drawer } from 'primereact/drawer';
<Drawer.Root>
    <Drawer.Trigger></Drawer.Trigger>
    <Drawer.Portal>
        <Drawer.Backdrop />
        <Drawer.Popup>
            <Drawer.Header>
                <Drawer.Title></Drawer.Title>
                <Drawer.Close></Drawer.Close>
            </Drawer.Header>
            <Drawer.Content></Drawer.Content>
            <Drawer.Footer></Drawer.Footer>
        </Drawer.Popup>
    </Drawer.Portal>
</Drawer.Root>

Behavior#

Motion Animation#

<Drawer.Popup motionProps={{ name: 'p-drawer', appear: true }}>...</Drawer.Popup>

See Motion for animation phases, CSS variables, and hide strategies.

Polymorphic Rendering#

Use as on any sub-component to change the rendered HTML element.

<Drawer.Trigger as="div">...</Drawer.Trigger>

Render Function Children#

Sub-components accept a render function as children, providing access to the component instance.

<Drawer.Content>{(instance) => <div>{instance.drawer?.state.open ? 'Open' : 'Closed'}</div>}</Drawer.Content>

Pass Through#

Some parts may not be visible in the preview depending on the component's current state.

Loading...
/* Select a part to see its CSS selector for custom styling */

API#

DrawerRoot#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DrawerRootInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DrawerRootInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDrawerRootInstance—
The instance to pass to the component.
ptSafeRecord<DrawerRootPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DrawerRootInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
openboolean—
Specifies the visibility of the drawer.
defaultOpenboolean—
Specifies the default visibility of the drawer.
blockScrollbooleanfalse
Whether to block scrolling when the drawer is open.
dismissablebooleantrue
Whether clicking outside closes the drawer.
baseZIndexnumber0
Base zIndex value to use in layering.
autoZIndexbooleantrue
Whether to automatically manage layering.
trappedbooleantrue
When enabled, focus is trapped within the drawer (modal behavior).
position"top" | "bottom" | "left" | "right" | "full"left
Position of the drawer.
onOpenChange(event: DrawerRootChangeEvent) => void—
Callback function that is called when the trigger is clicked.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-openPresent when the drawer is open
data-closedPresent when the drawer is closed
data-position"left" | "right" | "top" | "bottom" | "full"

Defines passthrough(pt) options of Drawer component.

labeltypedescription
rootDrawerRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.
backdropDrawerRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the backdrop's DOM element.
triggerDrawerRootPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the trigger's DOM element.
headerDrawerRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the header's DOM element.
titleDrawerRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the title's DOM element.
closeDrawerRootPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the close's DOM element.
contentDrawerRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the content's DOM element.
footerDrawerRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the footer's DOM element.

DrawerTrigger#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DrawerTriggerInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DrawerTriggerInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDrawerTriggerInstance—
The instance to pass to the component.
ptSafeRecord<DrawerTriggerPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DrawerTriggerInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of DrawerTrigger component.

labeltypedescription
rootDrawerTriggerPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

DrawerPortal#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DrawerPortalInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DrawerPortalInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDrawerPortalInstance—
The instance to pass to the component.
ptSafeRecord<DrawerPortalPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DrawerPortalInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of DrawerPortal component.

labeltypedescription
rootDrawerPortalPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

DrawerBackdrop#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DrawerBackdropInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DrawerBackdropInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDrawerBackdropInstance—
The instance to pass to the component.
ptSafeRecord<DrawerBackdropPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DrawerBackdropInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Uses the Backdrop component internally for animated overlay rendering.

Defines passthrough(pt) options of DrawerBackdrop component.

labeltypedescription
rootDrawerBackdropPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

DrawerPopup#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DrawerPopupInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DrawerPopupInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDrawerPopupInstance—
The instance to pass to the component.
ptSafeRecord<DrawerPopupPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DrawerPopupInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-openPresent when the drawer is open
data-position"left" | "right" | "top" | "bottom" | "full"

Uses VisuallyHidden elements internally for focus trap boundaries.

Defines passthrough(pt) options of DrawerPopup component.

labeltypedescription
rootDrawerPopupPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

DrawerHeader#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DrawerHeaderInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DrawerHeaderInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDrawerHeaderInstance—
The instance to pass to the component.
ptSafeRecord<DrawerHeaderPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DrawerHeaderInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of DrawerHeader component.

labeltypedescription
rootDrawerHeaderPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

DrawerTitle#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DrawerTitleInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DrawerTitleInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDrawerTitleInstance—
The instance to pass to the component.
ptSafeRecord<DrawerTitlePassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DrawerTitleInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of DrawerTitle component.

labeltypedescription
rootDrawerTitlePassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

DrawerClose#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DrawerCloseInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DrawerCloseInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDrawerCloseInstance—
The instance to pass to the component.
ptSafeRecord<DrawerClosePassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DrawerCloseInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
iconOnlybooleantrue
Whether to show the DrawerClose with a borderless style.
severitystring & {} | "secondary" | "info" | "success" | "warn" | "danger" | "contrast" | "help"'secondary'
Severity type of the DrawerClose.
variant"link" | "text" | "outlined"'text'
Variant of the DrawerClose.
roundedbooleantrue
Whether to show the DrawerClose with a rounded style.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of DrawerClose component.

labeltypedescription
rootDrawerClosePassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

DrawerContent#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DrawerContentInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DrawerContentInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDrawerContentInstance—
The instance to pass to the component.
ptSafeRecord<DrawerContentPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DrawerContentInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of DrawerContent component.

labeltypedescription
rootDrawerContentPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

DrawerFooter#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: DrawerFooterInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: DrawerFooterInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceDrawerFooterInstance—
The instance to pass to the component.
ptSafeRecord<DrawerFooterPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: DrawerFooterInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of DrawerFooter component.

labeltypedescription
rootDrawerFooterPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

Drawer component uses complementary role by default, since any attribute is passed to the root element aria role can be changed depending on the use case and additional attributes like aria-labelledby can be added. In addition aria-modal is added since focus is kept within the drawer when opened.

Trigger element also has aria-expanded and aria-controls to indicate the drawer state.

Overlay Keyboard Support#

KeyFunction
tabMoves focus to the next the focusable element within the drawer.
shift + tabMoves focus to the previous the focusable element within the drawer.
escapeCloses the drawer.

Close Button Keyboard Support#

KeyFunction
enterCloses the drawer.
spaceCloses the drawer.