跳转到内容

Drawer API

API documentation for the React Drawer component. Learn about the available props, and the CSS API.

Import

import Drawer from '@material-ui/core/Drawer';
// 或
import { Drawer } from '@material-ui/core';
You can 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.

Component name

The name MuiDrawer can be used when providing default props or style overrides in the theme.

属性

名称类型默认值描述
anchor'bottom'
| 'left'
| 'right'
| 'top'
'left'Side from which the drawer will appear.
childrennodeThe content of the component.
classesobjectOverride or extend the styles applied to the component. See CSS API below for more details.
elevationnumber16The elevation of the drawer.
ModalPropsobject{}Props applied to the Modal element.
onClosefuncCallback fired when the component requests to be closed.

Signature:
function(event: object) => void
event: The event source of the callback.
openboolfalseControl the popup` open state.
PaperPropsobject{}Props applied to the Paper element.
SlidePropsobjectProps applied to the Slide element.
transitionDurationnumber
| { appear?: number, enter?: number, exit?: number }
{ enter: duration.enteringScreen, exit: 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.

ref 则会被传递到根元素中。
Any other props supplied will be provided to the root element (native element).

CSS

Rule nameGlobal class描述
root.MuiDrawer-rootStyles applied to the root element.
docked.MuiDrawer-dockedStyles applied to the root element if variant="permanent or persistent".
paper.MuiDrawer-paperStyles applied to the Paper component.
paperAnchorLeft.MuiDrawer-paperAnchorLeftStyles applied to the Paper component if anchor="left".
paperAnchorRight.MuiDrawer-paperAnchorRightStyles applied to the Paper component if anchor="right".
paperAnchorTop.MuiDrawer-paperAnchorTopStyles applied to the Paper component if anchor="top".
paperAnchorBottom.MuiDrawer-paperAnchorBottomStyles applied to the Paper component if anchor="bottom".
paperAnchorDockedLeft.MuiDrawer-paperAnchorDockedLeftStyles applied to the Paper component if anchor="left" and variant is not "temporary".
paperAnchorDockedTop.MuiDrawer-paperAnchorDockedTopStyles applied to the Paper component if anchor="top" and variant is not "temporary".
paperAnchorDockedRight.MuiDrawer-paperAnchorDockedRightStyles applied to the Paper component if anchor="right" and variant is not "temporary".
paperAnchorDockedBottom.MuiDrawer-paperAnchorDockedBottomStyles applied to the Paper component if anchor="bottom" and variant is not "temporary".
modal.MuiDrawer-modalStyles applied to the Modal component.

You can override the style of the component using one of these customization options: If that isn't sufficient, you can check the implementation of the component for more detail.

Demos