VOOZH about

URL: https://mui.com/material-ui/api/drawer/

⇱ Drawer API - Material UI


Skip to contentSkip to content

Drawer API

API reference docs for the React Drawer component. Learn about the props, CSS, and other APIs of this exported module.

Demos

For examples and details on the usage of this React component, visit the component demo pages:

Import

import Drawer from '@mui/material/Drawer';
// or
import { Drawer } from '@mui/material';

Learn about the difference by reading this guide on minimizing bundle size.



The props of the Modal component are available when variant="temporary" is set.

Props of the native component are also available.

NameTypeDefaultDescription
anchor'bottom'
| 'left'
| 'right'
| 'top'
'left'

Side from which the drawer will appear.

childrennode-

The content of the component.

classesobject-

Override or extend the styles applied to the component.

See CSS classes API below for more details.

elevationinteger16

The elevation of the drawer.

hideBackdropboolfalse

If true, the backdrop is not rendered.

ModalPropsobject{}

Props applied to the Modal element.

onClosefunc-

Callback fired when the component requests to be closed. The reason parameter can optionally be used to control the response to onClose.

Signature:function(event: object, reason: string) => void
  • event The event source of the callback.
  • reason Can be: "escapeKeyDown", "backdropClick".
openboolfalse

If true, the component is shown.

PaperPropsobject{}

Props applied to the Paper element.

Deprecateduse the slotProps.paper prop instead. This prop will be removed in a future major release. See Migrating from deprecated APIs for more details.
SlidePropsobject-

Props applied to the Slide element.

Deprecateduse the slotProps.transition prop instead. This prop will be removed in a future major release. See Migrating from deprecated APIs for more details.
slotProps{ backdrop?: func
| object, docked?: func
| object, paper?: func
| object, root?: func
| object, transition?: func
| object }
{}

The props used for each slot inside.

slots{ backdrop?: elementType, docked?: elementType, paper?: elementType, root?: elementType, transition?: elementType }{}

The components used for each slot inside.

sxArray<func
| object
| bool>
| func
| object
-

The system prop that allows defining system overrides as well as additional CSS styles.

See the `sx` page for more details.

transitionDurationnumber
| { appear?: number, enter?: number, exit?: number }
{ enter: theme.transitions.duration.enteringScreen, exit: theme.transitions.duration.leavingScreen, }

The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object.

variant'permanent'
| 'persistent'
| 'temporary'
'temporary'

The variant to use.

The ref is forwarded to the root element.

Theme default props

You can use MuiDrawer to change the default props of this component with the theme.

Slot nameClass nameDefault componentDescription
root.MuiDrawer-rootModalThe component used for the root when the variant is temporary.
backdropBackdropThe component used for the Modal backdrop.
docked.MuiDrawer-dockeddivThe component used for the root element when the variant is permanent or persistent.
paper.MuiDrawer-paperPaperThe component used for the paper.
transitionSlideThe component used for the transition. Follow this guide to learn more about the requirements for this component.

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

Class nameRule nameDescription
.MuiDrawer-anchorBottomanchorBottomStyles applied to the root element if anchor="bottom".
.MuiDrawer-anchorLeftanchorLeftStyles applied to the root element if anchor="left".
.MuiDrawer-anchorRightanchorRightStyles applied to the root element if anchor="right".
.MuiDrawer-anchorTopanchorTopStyles applied to the root element if anchor="top".
.MuiDrawer-modalmodalStyles applied to the Modal component.
.MuiDrawer-paperAnchorBottompaperAnchorBottomStyles applied to the Paper component if anchor="bottom".
DeprecatedCombine the .MuiDrawer-anchorBottom and .MuiDrawer-paper classes instead. How to migrate
.MuiDrawer-paperAnchorDockedBottompaperAnchorDockedBottomStyles applied to the Paper component if anchor="bottom" and variant is not "temporary".
DeprecatedCombine the .MuiDrawer-anchorBottom, .MuiDrawer-docked and .MuiDrawer-paper classes instead. How to migrate
.MuiDrawer-paperAnchorDockedLeftpaperAnchorDockedLeftStyles applied to the Paper component if anchor="left" and variant is not "temporary".
DeprecatedCombine the .MuiDrawer-anchorLeft, .MuiDrawer-docked and .MuiDrawer-paper classes instead. How to migrate
.MuiDrawer-paperAnchorDockedRightpaperAnchorDockedRightStyles applied to the Paper component if anchor="right" and variant is not "temporary".
DeprecatedCombine the .MuiDrawer-anchorRight, .MuiDrawer-docked and .MuiDrawer-paper classes instead. How to migrate
.MuiDrawer-paperAnchorDockedToppaperAnchorDockedTopStyles applied to the Paper component if anchor="top" and variant is not "temporary".
DeprecatedCombine the .MuiDrawer-anchorTop, .MuiDrawer-docked and .MuiDrawer-paper classes instead. How to migrate
.MuiDrawer-paperAnchorLeftpaperAnchorLeftStyles applied to the Paper component if anchor="left".
DeprecatedCombine the .MuiDrawer-anchorLeft and .MuiDrawer-paper classes instead. How to migrate
.MuiDrawer-paperAnchorRightpaperAnchorRightStyles applied to the Paper component if anchor="right".
DeprecatedCombine the .MuiDrawer-anchorRight and .MuiDrawer-paper classes instead. How to migrate
.MuiDrawer-paperAnchorToppaperAnchorTopStyles applied to the Paper component if anchor="top".
DeprecatedCombine the .MuiDrawer-anchorTop and .MuiDrawer-paper classes instead. How to migrate

You can override the style of the component using one of these customization options:

Source code

If you did not find the information in this page, consider having a look at the implementation of the component for more detail.