npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-component-transition

v2.2.0

Published

Easy animations between react component transitions.

Readme

react-component-transition

Easy to use react component to apply animations between component transitions, by using Web Animations API.

Demo

https://dgpedro.github.io/react-component-transition/

Install

npm install react-component-transition --save

Typescript

Types are included in the package.

Goal

The main goal is to provide an easy and fast way to apply simple animations when transitioning from one component to another - without losing too much time testing, adjusting, styling, etc... In just a couple of lines it's possible to make any react page much more interactive and user friendly.

Polyfills

Depending on the browser to support, some polyfills might be needed:

Usage

ComponentTransition

import { ComponentTransition, AnimationTypes } from "react-component-transition";
const Component = () => {

    // ...

    return (
        <ComponentTransition
            enterAnimation={AnimationTypes.scale.enter}
            exitAnimation={AnimationTypes.fade.exit}
        >
            {showDetails ? <Details /> : <Summary />}
        </ComponentTransition>
    );
};

Presets

Presets are components that have enterAnimation and exitAnimation already set, for an easier and cleaner usage.

import { Presets } from "react-component-transition";
const Component = () => {
    
    // ...

    return (
        <Presets.TransitionFade>
            {show && <Details />}
        </Presets.TransitionFade>
    );
};

There's a preset available for each AnimationTypes.

ComponentTransitionList

To be used with lists. Simply return a ComponentTransition or any preset in your map function and wrap it all with a ComponentTransitionList.

import { ComponentTransitionList, Presets } from "react-component-transition";
const Component = () => {
    
    // ...

    return (
        <ComponentTransitionList>
            {list.map((listItem, index) =>
                <Presets.TransitionScale key={index}>
                    <ListItem {...listItem} />
                </Presets.TransitionScale>
            )}
        </ComponentTransitionList>
    );
};

With react-router

import { useLocation } from "react-router-dom";
const AppRoutes = () => {
    const location = useLocation();
    return (
        <ComponentTransition
            enterAnimation={AnimationTypes.slideUp.enter}
            exitAnimation={AnimationTypes.slideDown.exit}
        >
            <Switch key={location.key} location={location}>
                <Route ... />
                <Route ... />
                <Route ... />
            </Switch>
        </ComponentTransition>
    );
};
import { BrowserRouter } from "react-router-dom";
const App = () => (
    <BrowserRouter>
        <AppRoutes />
    </BrowserRouter>
);

Custom animation

import { ComponentTransition, AnimationTypes } from "react-component-transition";
const Component = () => {

    // ...

    return (
        <ComponentTransition
            enterAnimation={[
                AnimationTypes.slideUp.enter,
                AnimationTypes.fade.enter,
            ]}
            exitAnimation={[{
                keyframes: [
                    { transform: "translate3d(0,0,0)" },
                    { transform: "translate3d(0,50%,0)" },
                    { transform: "translate3d(0,80%,0)" },
                    { transform: "translate3d(0,90%,0)" },
                    { transform: "translate3d(0,100%,0)" },
                ],
                options: {
                    duration: 500,
                    easing: "cubic-bezier(0.83, 0, 0.17, 1)",
                }
            },
            {
                keyframes: [
                    { opacity: 1 },
                    { opacity: 0.3 },
                    { opacity: 0.1 },
                    { opacity: 0 },
                ],
                options: {
                    duration: 300,
                }
            }]
            }
        >
            <Details key={selectedTab} />
        </ComponentTransition>
    );
};

API

AnimationTypes

AnimationTypes are a set of animations already defined that can be used in enterAnimation and/or exitAnimation props. Availabe ones are:

collapse.(horizontal|vertical)
expand.(horizontal|vertical)
fade.(enter|exit)
rotate.(enter|exit)
rotateX.(enter|exit)
rotateY.(enter|exit)
scale.(enter|exit)
slideDown.(enter|exit)
slideLeft.(enter|exit)
slideRight.(enter|exit)
slideUp.(enter|exit)

For each type of AnimationTypes there's a respective preset.

props

All presets and the ComponentTransition will wrap their children in a div element. This div is the element that will animate when children are unmounting or mounting (it is referenced here as "container").

Name | Type | Default | Description -----|------|---------|------------ animateContainer | boolean | false | if true the container will also animate from the exit component size to the enter component sizeNOTE: All presets have this prop set to true by default animateContainerDuration | number | 300 | Duration in milliseconds of the container animation animateContainerEasing | string | "ease" | Easing of container animation animateOnMount | boolean | false | if true, applies enterAnimation when component mounts in the initial render className | string | undefined | CSS class to set in the container element classNameEnter | string | undefined | CSS class to set in the container element during enterAnimation classNameExit | string | undefined | CSS class to set in the container element during exitAnimation disabled | boolean | false | disable all animations enterAnimation | AnimationSettings | AnimationSettings[] | undefined | Web Animations API parameters to be applied when new component mounts exitAnimation | AnimationSettings | AnimationSettings[] | undefined | Web Animations API parameters to be applied when current component will unmount lazy | boolean | false | Will apply enterAnimation and exitAnimation if the component is visible in the viewport by using the Intersection Observer API. If true container element will always be in the DOM lazyOptions | IntersectionOptions | undefined | Intersection Observer options onEnterFinished | () => void | undefined | Callback when enterAnimation finishes onExitFinished | () => void | undefined | Callback when exitAnimation finishes style | React.CSSProperties | undefined | Inline styles to set in the container element

Examples

Clone the repo first and then:

npm install
npm start