Make Transitions in React with Material UI

Reading Time: 3 minutes

What are Transitions?

A transition is an animation usually used to move content in or out of view. Transitions help to make a UI expressive and easy to use and also MUI provides transitions that can introduce some basic motion to your applications.

React MUI Transitions

The transition component in React MUI allows you to define a change from one component state to another over time. Although it is most commonly used for mounting and unmounting animation components, it can also be used to portray in-place transition stages. It is up to you to give such states meaning and significance.

Components available in React MUI transition

1. Collapse: The “Collapse” component can be used to construct accordions, expanding sections, and also other UI components that require content to be shown and hidden.

Syntax:

 <Collapse in={checked} timeout={2000}>
      {icon}
 </Collapse>
collapse

2. Fade: Models, toasts, and other UI components that need to appear and disappear can be created with the “Fade” component. It employs a straightforward fade transition based on CSS opacity, also with the “timeout” prop, you may change the duration and easing of the transition.

Syntax:

 <Fade in={checked} timeout={2000}>
      {icon}
 </Fade>
fade

3. Grow:  The “Grow” component can be used to build expandable buttons or objects that must grow and also shrink. It employs a simple scale transition based on CSS transform, and also the duration and easing of the transition may be adjusted using the “timeout” attribute.

Syntax:

<Grow in={checked} timeout={2000}>
      {icon}
 </Grow>
grow

4. Slide: To design navigation drawers, modals, and other UI that must slide into and out utilise the “Slide” component. It makes use of a straightforward CSS transform-based slide transition and also, you may alter the transition’s direction, length, and ease by using the “direction,” “timeout,” and “easing” props.

Syntax:

 <Slide in={checked} direction='left' timeout={2000}>
      {icon}
 </Slide>
slide

5. Zoom: Modals, popovers, and also other UI that need zooming in and out can be created with the “Zoom” component. It employs a basic CSS transform-based zoom transition, and also you can adjust the transition’s length and easing using the “timeout” attribute.

Syntax:

 <Zoom in={checked} timeout={2000}>
      {icon}
 </Zoom>
zoom

CodeSandbox: https://codesandbox.io/s/react-mui-transition-qe7tv1?file=/demo.js

Reference: https://mui.com/material-ui/transitions/

Conclusion

So to apply transition in your code you just have to wrap the transition component with their required props and also can adjust the timeout or direction in your code.

Also, I have provided a CodeSandbox link where you can try and test different things.

For more updates on such topics, please follow our LinkedIn page- FrontEnd Studio.

Written by 

As a skilled web developer, I specialize in React and Angular frameworks, proficiently utilizing various JavaScript libraries to create dynamic and seamless online experiences. My dedication to staying abreast of industry trends ensures that I deliver innovative solutions. With a focus on optimal user interfaces and functionality, I thrive in collaborative environments, bringing creativity and efficiency to web development projects. My expertise lies in crafting engaging digital solutions that align with the evolving landscape of web technologies. Let's embark on a journey of creating remarkable and user-centric online platforms.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading