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-panel

v20.5.0

Published

A panel to collapse and expand your content.

Readme

CollapsiblePanel

Description

A panel to collapse and expand your content.

The component can be used in a controlled or uncontrolled manner. Please refer to the React documentation if you are unsure what either or entails.

Please have a look at the Component Best Practices to ensure that you are using the component as intended from a development and UX perspective.

Installation

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

Additionally install the peer dependencies (if not present)

yarn add react
npm --save install react

Usage

import CollapsiblePanel from '@commercetools-uikit/collapsible-panel';
import Spacings from '@commercetools-uikit/spacings';
import Text from '@commercetools-uikit/text';

const Example = () => (
  <Spacings.Stack>
    {/* 1. Uncontrolled. The `CollapsiblePanel` controls its own state. You do not pass handlers or state related props. */}
    <CollapsiblePanel header="Lorem">
      <Text.Detail>Hello World</Text.Detail>
    </CollapsiblePanel>;{/* 2. Controlled. You control the `CollapsiblePanel`. You do pass handlers or state related props.
    Assume the parent rendering the `CollapsiblePanel` has `isPanelOpen` as state and a `togglePanel` as a handler. */}
    <CollapsiblePanel
      isClosed={this.state.isPanelOpen}
      onToggle={this.togglePanel}
      header="Lorem"
    >
      <Text.Detail>Hello World</Text.Detail>
    </CollapsiblePanel>
    ;
  </Spacings.Stack>
);

export default Example;

Properties

| Props | Type | Required | Default | Description | | ------------------------- | -------------------------------------------------------------------------------------------- | :------: | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | id | string | | | An unique id for the panel header, which will also be used to generate a prefixed id for the panel content section. Read about getPanelContentId below for more about this. | | header | unionPossible values:ReactElement<{ isCondensed?: boolean }> , ReactNode | ✅ | | The title being rendered at top left of the panel | | secondaryHeader | ReactNode | | | A secondary header for the panel (only pass if needed) | | description | string | | | If passed will be shown below the title as more information regarding the panel | | className | string | | | Allow to override the styles by passing a className prop. Custom styles can also be passed using the css prop from emotion. | | isSticky | boolean | | | Makes the panel's header sticky in regards to the page's scroll | | headerControls | ReactNode | | | Controls at the top right part of the panel | | isDisabled | boolean | | false | Disables the panel and all interactions with it | | children | ReactNode | | | The actual content rendered inside the panel | | tone | unionPossible values:'urgent' , 'primary' | | | Indicates the color scheme of the panel. | | theme | unionPossible values:'dark' , 'light' | | 'dark' | Determines the background color of the panel. | | condensed | boolean | | false | Whenever true the headers and content itself will consume less space in that to the borders are smaller and everything has less padding | | hideExpansionControls | boolean | | | Controls the visibility of the expansion controls on the left | | headerControlsAlignment | unionPossible values:'left' , 'right' | | 'right' | Indicates the position of the control elements in the header component. | | isDefaultClosed | boolean | | | Indicates if the panel's content should be collapsed or shown by default. Updates to this value are not respected. Only used for uncontrolled mode (when noonToggle is passed.) | | isClosed | boolean | | | Indicates if the panel's content should be collapsed or shown. Component becomes *controlled when this is passed. | | onToggle | FunctionSee signature. | | | function to be triggered whenever the user clicks the top area to collapse the panel's content Becomes required when isClosed is passed. | | horizontalConstraint | unionPossible values:, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto' | | 'scale' | Horizontal size limit of the panel. |

Signatures

Signature onToggle

() => void

Where to use

Whenever some content on a given page should be concealed and/or expandible. This often holds true for instance for detailed but hidden information of some entity to save space.

Header

The header of this component should follow our design and UX conventions so it looks the same across the application. It accepts a node to accompany the two scenarios:

  1. Given the CollapsiblePanel is condensed

Whenever the component is configured to be condensed all content pased via the header will be wrapped in a <Text.Detail />. For this use case please ensure that no combinations of components are passed via the header.

import CollapsiblePanel from '@commercetools-uikit/collapsible-panel';

<CollapsiblePanel condensed={true} header={'My title'}>
  <YourComponentAsContentOfThePanel />
</CollapsiblePanel>;
  1. Given the CollapsiblePanel is not condensed

For this use case you will need to explicitly pass the header wrapped by the <CollapsiblePanel.Header /> component to automatically ensure it follows our designs (enforced by the <CollapsiblePanel.Header />).

import CollapsiblePanel from '@commercetools-uikit/collapsible-panel';

<CollapsiblePanel
  header={
    <CollapsiblePanel.Header>
      <FormattedMessage {...messages.title} />
    </CollapsiblePanel.Header>
  }
>
  <YourComponentAsContentOfThePanel />
</CollapsiblePanel>;
  1. Passing a combination of components (e.g. label and input)

Rendering any input(s) inside the header is allowed, but there are certain contraints that need to be taken into account:

  • You can only render a maximum amount of 3 components inside the header.
  • Given a combination of label and input
    • Then the input's label should be bold and the input only a <TextInput />
  • All has to be vertically aligned in the header container.

Theme

The component supports themes (dark and light) to enable nesting of collapsible panels inside one another.

  • Given the background of the parent is dark
    • Then the child needs to be light for better accessibility and visibility

Condensed

There are a some restrictions given using condensed={true}

  1. Nothing complex is passed as the header
  • Nor button or inputs or anything that is not within title itself
  1. The title should be only (if possible) be a string or a combination or text components
  • Everything is automatically wrapped within a <Text.Detail />

SecondaryHeader

The secondaryHeader allow rendering some secondary information in addition to the title.

It accepts a node but with few restrictions:

  1. Bold text is allowed while the text component is <Text.Detail />
  2. Text size should not exceed the font size of <Text.Detail />

headerControls

The headerControls allows rendering a component which should only contain buttons or links. Apart from that there is one more limitation:

  1. You can only render a maximum amount of 3 button inside the headerControls

Static methods

CollapsiblePanel.getPanelContentId

Returns the generated id used for the wrapper of the panel content section. It is used for setting the aria-controls attribute on the header and can also be useful for finding the child element when testing.

CollapsiblePanel.getPanelContentId('example'); // -> panel-content-example