This Is The Truth Behind How To Build An Animated Dialog Like Netflix’s

Oscar Bastos
2 min readMay 3, 2021

--

Using React, Styled Components and React Spring Animations.

cool animated dialog

Have you ever pondered the creation of an animated modal, similar to the one on Netflix when you select a movie? It seamlessly opens and closes from the same position of the chosen card on the carousel.

Effortlessly achieve this effect using the ‘useTransition’ hook from the ‘react-spring’ library.

Examine the concise code I’ve composed to construct the ‘AnimatedDialog’ component utilizing React, ‘styled-components’, and animations from ‘react-spring’. Achieve a visually stunning animated dialog with minimal effort through just a few lines of code.

animated dialog component

The key is to manipulate the ‘translateX’, ‘translateY’, and ‘scale’ CSS properties of the ‘ModalContainer’ when mounting the ‘Dialog’ component. This creates the illusion that it originates from the position of the card, expands and concludes at the top of the page. Additionally, ensure to adjust the ‘transform-origin’ to ‘center top’ to give the appearance of expansion as it moves upward. The process is similar in reverse when closing, as the dialog seamlessly merges back with the carousel card.

Increase scale, change translateX = 0 and translateY = top of the page

Examine the final outcome of my Proof of Concept:

the animated dialog pops out and returns to the same position of the selected card.

With this explanation, I believe it is an ideal time for you to attempt crafting this animated dialog and incorporate high-quality components into your web application, akin to those utilized in the premier UIs around the world

--

--