跳转到内容

🎉 v5 beta is out! Head to the v5 documentation to get started.

SwipeableDrawer API

The API documentation of the SwipeableDrawer React component. Learn more about the props and the CSS customization points.

Import

import SwipeableDrawer from '@material-ui/core/SwipeableDrawer';
// or
import { SwipeableDrawer } from '@material-ui/core';

You can learn more about the difference by reading this guide.

Props

Name Type Default Description
children node The content of the component.
disableBackdropTransition bool false Disable the backdrop transition. This can improve the FPS on low-end devices.
disableDiscovery bool false If true, touching the screen near the edge of the drawer will not slide in the drawer a bit to promote accidental discovery of the swipe gesture.
disableSwipeToOpen bool typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent) If true, swipe to open is disabled. This is useful in browsers where swiping triggers navigation actions. Swipe to open is disabled on iOS browsers by default.
hysteresis number 0.52 Affects how far the drawer must be opened/closed to change his state. Specified as percent (0-1) of the width of the drawer
minFlingVelocity number 450 Defines, from which (average) velocity on, the swipe is defined as complete although hysteresis isn't reached. Good threshold is between 250 - 1000 px/s
onClose* func Callback fired when the component requests to be closed.

Signature:
function(event: object) => void
event: The event source of the callback.
onOpen* func Callback fired when the component requests to be opened.

Signature:
function(event: object) => void
event: The event source of the callback.
open* bool If true, the drawer is open.
SwipeAreaProps object The element is used to intercept the touch events on the edge.
swipeAreaWidth number 20 The width of the left most (or right most) area in pixels where the drawer can be swiped open from.
transitionDuration 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.

The ref is forwarded to the root element.

Any other props supplied will be provided to the root element (Drawer).

Inheritance

The props of the Drawer component are also available. You can take advantage of this behavior to target nested components.

Demos