跳转到内容

Slide API

想要学习更多组件属性和 CSS API,可以查阅 React Slide 组件的 API 文档。

导入

import Slide from '@mui/material/Slide';
// 或
import { Slide } from '@mui/material';
You can learn about the difference by reading this guide on minimizing bundle size.

The Slide transition is used by the Drawer component. It uses react-transition-group internally.

属性

Transition 组件的属性也是可用的。

名称类型默认值描述
children*element
A single child content element.
⚠️ Needs to be able to hold a ref.
addEndListenerfunc
Add a custom transition end trigger. Called with the transitioning DOM node and a done callback. Allows for more fine grained transition end logic. Note: Timeouts are still used as a fallback if provided.
appearbooltrue
Perform the enter transition when it first mounts if in is also true. Set this to false to disable this behavior.
containerHTML element
| func
An HTML element, or a function that returns one. It's used to set the container the Slide is transitioning from.
direction'down'
| 'left'
| 'right'
| 'up'
'down'
Direction the child node will enter from.
easing{ enter?: string, exit?: string }
| string
{ enter: theme.transitions.easing.easeOut, exit: theme.transitions.easing.sharp, }
The transition timing function. You may specify a single easing or a object containing enter and exit values.
inboolfalse
If true, the component will transition in.
timeoutnumber
| { 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.

ref 则会被传递到根元素中。

继承

While not explicitly documented above, the props of the Transition component来自 react-transition-group are also available on Slide. You can take advantage of this to target nested components.

演示项目