Socket
Socket
Sign inDemoInstall

rc-collapse

Package Overview
Dependencies
12
Maintainers
6
Versions
81
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rc-collapse

rc-collapse ui component for react


Version published
Weekly downloads
1.2M
increased by5.79%
Maintainers
6
Install size
608 kB
Created
Weekly downloads
 

Package description

What is rc-collapse?

The rc-collapse npm package is a React component for creating collapsible panels. It allows developers to create sections of content that can be expanded or collapsed by the user, making it useful for FAQs, menus, and more. It supports accordion mode, where only one panel can be open at a time.

What are rc-collapse's main functionalities?

Basic Collapse

This code sample demonstrates how to create a basic collapsible component with two panels. Each panel has its own header and content.

import Collapse from 'rc-collapse';
import 'rc-collapse/assets/index.css';

const Panel = Collapse.Panel;

const App = () => (
  <Collapse>
    <Panel header="This is panel header 1" key="1">
      <p>Content of panel 1</p>
    </Panel>
    <Panel header="This is panel header 2" key="2">
      <p>Content of panel 2</p>
    </Panel>
  </Collapse>
);

Accordion Mode

This example shows how to enable accordion mode, where opening one panel will close the others, ensuring only one panel is open at a time.

import Collapse from 'rc-collapse';
import 'rc-collapse/assets/index.css';

const Panel = Collapse.Panel;

const App = () => (
  <Collapse accordion>
    <Panel header="This is panel header 1" key="1">
      <p>Content of panel 1</p>
    </Panel>
    <Panel header="This is panel header 2" key="2">
      <p>Content of panel 2</p>
    </Panel>
  </Collapse>
);

Other packages similar to rc-collapse

Readme

Source

rc-collapse


rc-collapse ui component for react

NPM version build status Test coverage npm download Dependencies DevDependencies

Development

npm install
npm start

Example

http://localhost:8000/examples/

online example: http://react-component.github.io/collapse/

Features

  • support ie8,ie8+,chrome,firefox,safari

Install

rc-collapse

Usage

var Collapse = require('rc-collapse');
var Panel = Collapse.Panel;
var React = require('react');
var ReactDOM = require('react-dom');
require('rc-collapse/assets/index.css');

var collapse = (
  <Collapse accordion={true}>
    <Panel header="hello" headerClass="my-header-class">this is panel content</Panel>
    <Panel header="title2">this is panel content2 or other</Panel>
  </Collapse>
);
ReactDOM.render(collapse, container);

API

Collapse

props:
nametypedefaultdescription
activeKeyString|ArrayThe first panel keycurrent active Panel key
classNameString or objectcustom className to apply
defaultActiveKeyString|Arraynulldefault active key
destroyInactivePanelBooleanfalseIf destroy the panel which not active, default false.
accordionBooleanfalseaccordion mode, default is null, is collapse mode
onChangeFunction(key)noopcalled when collapse Panel is changed
expandIcon(props: PanelProps) => ReactNodespecific the custom expand icon.
collapsible'header' | 'disabled'-specify whether the panel of children is collapsible or the area of collapsible.

If accordion is null or false, every panel can open. Opening another panel will not close any of the other panels. activeKey should be an string, if passing an array (the first item in the array will be used).

If accordion is true, only one panel can be open. Opening another panel will cause the previously opened panel to close. activeKey should be an string, if passing an array (the first item in the array will be used).

Collapse.Panel

props
nametypedefaultdescription
headerString or nodeheader content of Panel
headerClassString' 'custom className to apply to header
showArrowbooleantrueshow arrow beside header
classNameString or objectcustom className to apply
styleobjectcustom style
openMotionobjectset the animation of open behavior, [more](https://github.com/react-component/motion). Different with v2, closed pane use a `rc-collapse-content-hidden` class to set `display: none` for hidden.
forceRenderbooleanfalseforced render of content in panel, not lazy render after clicking on header
extraString | ReactNodeContent to render in the right of the panel header
collapsible'header' | 'disabled'-specify whether the panel be collapsible or the area of collapsible.

disabled is removed since 3.0.0, please use collapsible=disabled replace it.

key

If key is not provided, the panel's index will be used instead.

Test Case

npm test
npm run chrome-test

Coverage

npm run coverage

open coverage/ dir

License

rc-collapse is released under the MIT license.

Keywords

FAQs

Last updated on 27 May 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc