Pular para o conteúdo

Collapse API

Documentação da API para o componente React Collapse . Aprenda sobre as propriedades disponíveis e a API CSS.

Demonstrações

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

Importação

import Collapse from '@mui/material/Collapse';
// ou
import { Collapse } from '@mui/material';
Você pode aprender sobre a diferença lendo este guia sobre como minimizar o tamanho do pacote.

The Collapse transition is used by the Vertical Stepper StepContent component. It uses react-transition-group internally.

Nome do componente

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

Propriedades

Propriedades do componente Transition também estão disponíveis.

NomeTipoPadrãoDescrição
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.
childrennode
The content node to be collapsed.
classesobject
Sobrescreve ou extende os estilos aplicados para o componente. Veja a API CSS abaixo para maiores detalhes.
collapsedSizenumber
| string
'0px'
The width (horizontal) or height (vertical) of the container when collapsed.
componentelement type
The component used for the root node. Either a string to use a HTML element or a component.
⚠️ Needs to be able to hold a ref.
easing{ enter?: string, exit?: string }
| string
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.
orientation'horizontal'
| 'vertical'
'vertical'
The collapse transition orientation.
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.
timeout'auto'
| number
| { appear?: number, enter?: number, exit?: number }
duration.standard
The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object.
Set to 'auto' to automatically calculate transition time based on height.

O ref é encaminhado para o elemento raiz.

Herança

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

CSS

Nome da regraClasse globalDescrição
root.MuiCollapse-rootEstilos aplicados ao elemento raiz.
horizontal.MuiCollapse-horizontalPseudo-class aplicada a o elemento raiz se orientation="horizontal".
entered.MuiCollapse-enteredStyles applied to o elemento raiz when the transition has entered.
hidden.MuiCollapse-hiddenStyles applied to o elemento raiz when the transition has exited and collapsedSize = 0px.
wrapper.MuiCollapse-wrapperEstilos aplicados a the outer wrapper element.
wrapperInner.MuiCollapse-wrapperInnerEstilos aplicados a the inner wrapper element.

Você pode sobrescrever o estilo do componente usando uma dessas opções de customização: