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 🙏

© 2025 – Pkg Stats / Ryan Hefner

preact-transitioning

v1.5.3

Published

Preact components for easily implementing basic CSS animations and transitions

Readme

preact-transitioning

npm GitHub

A library that provides components for managing animations and transitions with ease. It allows seamless transitions for both individual components and groups of elements. Lightweight and has no dependencies. Inspired by react-transition-group and has almost the same API.

<FadeTransition in={visible}>
  <div>Fading element</div>
</FadeTransition>

Installation

To install preact-transitioning, run the following command in your project:

npm install preact-transitioning
# or
yarn add preact-transitioning

Documentation

For more detailed information and usage examples, check out the Docs.

Quick Review

Transition Component

The Transition component allows you to control the mounting and unmounting of an element with transitions.

import { Transition } from 'preact-transitioning'

...

<Transition in={!hidden} appear exit={false}>
  {(transitionState) => (
    <pre>{JSON.stringify(transitionState)}</pre>
  )}
</Transition>

CSSTransition Component

The CSSTransition component applies CSS classes based on the current transition state.

import { CSSTransition } from 'preact-transitioning'

...

<CSSTransition in={!hidden} classNames="fade">
  <div>Animated element</div>
</CSSTransition>

StyleTransition Component

The StyleTransition component applies inline styles based on the current transition state. This is useful for customizing transitions without external CSS.

import { StyleTransition } from 'preact-transitioning'

...

<StyleTransition 
  in={!hidden} 
  duration={300} 
  styles={{
    enter: { opacity: 0 },
    enterActive: { opacity: 1 },
  }}
>
  <div style={{ transition: 'opacity 300ms' }}>Animated element</div>
</StyleTransition>

TransitionGroup Component

The TransitionGroup component handles a set of elements, animating them as they are added or removed from the DOM.

import { TransitionGroup } from 'preact-transitioning'

...

<TransitionGroup duration={300}>
  {items.map((item) => (
    <CSSTransition key={item.key} classNames="fade">
      <div>{item.label}</div>
    </CSSTransition>
  ))}
</TransitionGroup>

Component Props

TransitionProps

type TransitionProps = {
  children: (transitionState: TransitionState, activePhase: Phase) => ComponentChildren;
  in?: boolean;
  appear?: boolean;
  enter?: boolean;
  exit?: boolean;
  duration?: number;
  alwaysMounted?: boolean;
  addEndListener?: (node: Element | Text, done: () => void) => void;
  onEnter: () => void;
  onEntering: () => void;
  onEntered: () => void;
  onExit: () => void;
  onExiting: () => void;
  onExited: () => void;
}

The TransitionState passed to the children function has the following structure:

type TransitionState = {
  appear: boolean;
  appearActive: boolean;
  appearDone: boolean;
  enter: boolean;
  enterActive: boolean;
  enterDone: boolean;
  exit: boolean;
  exitActive: boolean;
  exitDone: boolean;
}

CSSTransitionProps

type CSSTransitionProps = Omit<TransitionProps, 'children'> & {
  children: VNode<{ class?: any; }>;
  classNames: string | {
    appear?: string;
    appearActive?: string;
    appearDone?: string;
    enter?: string;
    enterActive?: string;
    enterDone?: string;
    exit?: string;
    exitActive?: string;
    exitDone?: string;
  };
}

if classNames is a string, then the computed className will be suffixed based on the current transition state. For example, when classNames is "fade", the fade-appear-active class will be applied during the appearActive phase.

If classNames is an object, the final className will be taken from that object based on the current transition state.

StyleTransitionProps

type StyleTransitionProps = Omit<TransitionProps, 'children'> & {
  children: VNode<{ style?: any; }>;
  styles: {
    appear?: object;
    appearActive?: object;
    appearDone?: object;
    enter?: object;
    enterActive?: object;
    enterDone?: object;
    exit?: object;
    exitActive?: object;
    exitDone?: object;
  };
}

The styles prop allows you to define inline styles based on the current transition state. For example, when the element enters, the enterActive styles will be applied.

TransitionGroupProps

type TransitionGroupProps = {
  children: ComponentChildren;
  appear?: boolean;
  enter?: boolean;
  exit?: boolean;
  duration?: number;
}

License

MIT