Saltar al contenido

SwipeableDrawer API

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

Import

import SwipeableDrawer from '@material-ui/core/SwipeableDrawer';
// o
import { SwipeableDrawer } from '@material-ui/core';
You can learn about the difference by reading this guide on minimizing bundle size.

Props

NombreTipoPor defectoDescripción
onClose*funcCallback fired when the component requests to be closed.

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

Signature:
function(event: object) => void
event: The event source of the callback.
open*boolfalseControl the popup` open state.
childrennodeThe content of the component.
disableBackdropTransitionboolfalseDisable the backdrop transition. This can improve the FPS on low-end devices.
disableDiscoveryboolfalseIf 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.
disableSwipeToOpenbooltypeof 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.
hysteresisnumber0.52Affects how far the drawer must be opened/closed to change his state. Specified as percent (0-1) of the width of the drawer
minFlingVelocitynumber450Defines, from which (average) velocity on, the swipe is defined as complete although hysteresis isn't reached. Good threshold is between 250 - 1000 px/s
SwipeAreaPropsobjectThe element is used to intercept the touch events on the edge.
swipeAreaWidthnumber20The width of the left most (or right most) area in px that the drawer can be swiped open from.
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.

The ref is forwarded to the root element.
Any other props supplied will be provided to the root element (Drawer).

Inheritance

While not explicitly documented above, the props of the Drawer component are also available on SwipeableDrawer. You can take advantage of this to target nested components.

Demos