Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-collapse

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-collapse

Component-wrapper for collapse animation for elements with variable (and dynamic) height

  • 5.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
151K
increased by5.38%
Maintainers
1
Weekly downloads
 
Created

What is react-collapse?

The react-collapse package is a simple component for creating collapsible elements in React applications. It allows you to easily show and hide content with smooth animations.

What are react-collapse's main functionalities?

Basic Collapse

This example demonstrates a basic usage of the react-collapse package. It includes a button that toggles the visibility of the content inside the Collapse component.

```jsx
import React, { useState } from 'react';
import { Collapse } from 'react-collapse';

const BasicCollapse = () => {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <div>
      <button onClick={() => setIsOpen(!isOpen)}>
        Toggle Collapse
      </button>
      <Collapse isOpened={isOpen}>
        <div>
          This content will collapse and expand.
        </div>
      </Collapse>
    </div>
  );
};

export default BasicCollapse;
```

Nested Collapse

This example shows how to use nested Collapse components. The outer Collapse contains another Collapse component, demonstrating how collapsible elements can be nested within each other.

```jsx
import React, { useState } from 'react';
import { Collapse } from 'react-collapse';

const NestedCollapse = () => {
  const [isOuterOpen, setIsOuterOpen] = useState(false);
  const [isInnerOpen, setIsInnerOpen] = useState(false);

  return (
    <div>
      <button onClick={() => setIsOuterOpen(!isOuterOpen)}>
        Toggle Outer Collapse
      </button>
      <Collapse isOpened={isOuterOpen}>
        <div>
          Outer content.
          <button onClick={() => setIsInnerOpen(!isInnerOpen)}>
            Toggle Inner Collapse
          </button>
          <Collapse isOpened={isInnerOpen}>
            <div>
              Inner content.
            </div>
          </Collapse>
        </div>
      </Collapse>
    </div>
  );
};

export default NestedCollapse;
```

Other packages similar to react-collapse

Keywords

FAQs

Package last updated on 23 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc