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

@commercetools-uikit/collapsible-motion

v20.4.0

Published

A component which allows building collapsible elements with an arbitrary height.

Downloads

18,872

Readme

CollapsibleMotion

Description

A component which allows building collapsible elements with an arbitrary height. The component can be controlled or uncontrolled, depending if the isClosed props is defined or not. A controlled component requires the onToggle prop additionally.

Details

Animating a div from height: 0 to height: auto is something the browser will refuse to do out of the box, because calculations of this animation would be expensive. There are many existing workaround which all have their different tradeoffs.

CollapsibleMotion uses a nice workaround which allows the browser to run this animation. CollapsibleMotion measures the resulting since and then animates between height: 0 and the resulting size (at 99% of the animation). At the end of the animation, it sets the height back to auto.

This component also supports passing in a minHeight prop. By default this is 0.

Technically, we need to dynamically create the keyframes for this animation.

Installation

yarn add @commercetools-uikit/collapsible-motion
npm --save install @commercetools-uikit/collapsible-motion

Additionally install the peer dependencies (if not present)

yarn add react
npm --save install react

Usage

import CollapsibleMotion from '@commercetools-uikit/collapsible-motion';

const Example = () => (
  <CollapsibleMotion>
    {({ isOpen, toggle, containerStyles, registerContentNode }) => (
      <div>
        <button data-testid="button" onClick={toggle}>
          {isOpen ? 'Close' : 'Open'}
        </button>
        <div data-testid="container-node" style={containerStyles}>
          <div data-testid="content-node" ref={registerContentNode}>
            Content
          </div>
        </div>
      </div>
    )}
  </CollapsibleMotion>
);

export default Example;

Properties

| Props | Type | Required | Default | Description | | ----------------- | ---------------------------------------------------- | :------: | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | children | FunctionSee signature. | ✅ | | A render function, called with the following named arguments: isOpen (boolean), toggle (function), containerStyles (css-in-js object), registerContentNode (React reference to be used on the animated container). Siganture: ({ isOpen, containerStyles, toggle, registerContentNode }) => React.node | | isClosed | boolean | | | | | onToggle | FunctionSee signature. | | | A callback function called when the toggle function is called. This prop is required when the component is controlled. | | minHeight | number | | | The minimal height of the container being animated. | | isDefaultClosed | boolean | | | The initial value to the internal toggle state isOpen. |

Signatures

Signature children

(options: TRenderFunctionOptions) => ReactNode;

Signature onToggle

() => void