CSS,  React

react route transition css: css-transitioner

css-transitioner is a small footprint React wrapper component to enable react route transition (i.e. perform transition when changing route page). It works with client side routing to switch between pages. It all started out when we wanted to add transition to our page routing, instead of switching pages in a flash. However, we couldn’t find an easy way to make react-transition-group to work with redux-little-router. We had to build a custom component to make it work and ended up with a little library to perform transition using css.

Check out a simple DEMO in action. Demo code is available at github.


npm install --save css-tranistioner

or in your package.json, add the following package:

"css-transitioner": "0.1.2"


There is no dependencies other than React and React-dom.


active: show the component when set to true, and hide the component when set to false

transitionStyle: css class name used for the transition. You can have different style for showing and hiding.

sample css definitions:

There are 4 transition states. Each with a corresponding css class to define the desire transition effect:

appeared: when the transition finishes and the component is shown.

disappeared: when the transition finishes and the component is hidden.

appearing: when the component becomes active and transitions from state ‘disappeared‘ to ‘appeared‘.

disappearing: when the component becomes inactive and transitions from state ‘appeared‘ to ‘disappeared‘.

There are several transition examples (zoom in/out, fade in/out, slide in/out) available at Transitions.css.

How it works with multiple route pages:

One Transitioner per route page (a react component), only shows 1 (active) component at a time. When the property page is changed (through link click or route change), the corresponding Transitioner will perform the transitions and gracefully switch between different pages.

Scroll positions:

Transitioner remembers scroll positions by default. So yes, it will transition with current scroll position of the page. If you don’t want scroll position, add property ignoreScroll={true} to Transitioner.

Does it work with TransitionGroup from react-transition-group?

Yes. While Transitioner does not make use of CssTransition, with Transitioner_TG (a simple wrapper provided), it works with  TransitionGroup:

Note that when working with TransitionGroup, you need the property id if you like to retain scroll positions.

Library code for react route transition: css-transitioner is available at github.

More read

Leave a Reply

Your email address will not be published. Required fields are marked *