New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@rc-component/collapse

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rc-component/collapse

rc-collapse ui component for react

latest
Source
npmnpm
Version
1.3.0
Version published
Weekly downloads
2M
18.9%
Maintainers
5
Weekly downloads
 
Created
Source

@rc-component/collapse

Ant Design Part of the Ant Design ecosystem.

🪗 A flexible collapse and accordion component for React.

NPM version npm downloads build status Codecov bundle size dumi

English | 简体中文

Highlights

  • Supports accordion and multi-panel collapse modes.
  • Prefer the items API for declarative panel configuration.
  • Keeps Collapse.Panel for compatibility. It is deprecated and will be removed in v4.
  • Supports custom expand icons, semantic class names, semantic styles, and motion.

Install

npm install @rc-component/collapse

Usage

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

export default function App() {
  return (
    <Collapse
      defaultActiveKey="1"
      items={[
        {
          key: '1',
          label: 'First panel',
          children: 'First panel content',
        },
        {
          key: '2',
          label: 'Second panel',
          children: 'Second panel content',
        },
      ]}
    />
  );
}

Examples

Run the local dumi site:

npm install
npm start

Then open http://localhost:8000.

API

Collapse

PropertyDescriptionTypeDefault
accordionOnly one panel can be opened at a timebooleanfalse
activeKeyCurrent active panel keyReact.Key | React.Key[]-
classNameAdditional class namestring-
classNamesSemantic class namesPartial<Record<SemanticName, string>>-
collapsibleSpecify whether panel trigger area is collapsibleheader | icon | disabled-
defaultActiveKeyInitial active panel keyReact.Key | React.Key[]-
destroyOnHiddenDestroy inactive panel contentbooleanfalse
expandIconCustom expand icon(props: object) => React.ReactNode-
itemsCollapse items contentItemType[]-
openMotionCustom open motionCSSMotionProps-
prefixClsComponent class name prefixstringrc-collapse
styleInline styleobject-
stylesSemantic stylesPartial<Record<SemanticName, React.CSSProperties>>-
onChangeCallback when active panels change(key: React.Key[]) => void-

ItemType

PropertyDescriptionTypeDefault
keyPanel keyReact.Key-
labelPanel header contentReact.ReactNode-
refPanel DOM refReact.RefObject<HTMLDivElement>-
childrenPanel body contentReact.ReactNode-
classNameAdditional panel class namestring-
classNamesSemantic class namesPartial<Record<SemanticName, string>>-
collapsibleSpecify whether the panel is collapsibleheader | icon | disabled-
destroyOnHiddenDestroy inactive panel contentbooleanfalse
extraExtra content in the panel headerReact.ReactNode-
forceRenderRender panel content before it is openedbooleanfalse
showArrowShow arrow beside headerbooleantrue
styleInline panel styleobject-
stylesSemantic stylesPartial<Record<SemanticName, React.CSSProperties>>-
onItemClickCallback when this panel is clicked(panelKey: React.Key) => void-

Collapse.Panel

Collapse.Panel is deprecated. Use items instead.

Development

npm install
npm start

The dumi site runs at http://localhost:8000 by default.

npm test
npm run tsc
npm run lint
npm run compile
npm run build

Release

npm run prepublishOnly

The release flow is handled by @rc-component/np through the rc-np command after the package build.

License

@rc-component/collapse is released under the MIT license.

Keywords

react

FAQs

Package last updated on 02 Nov 2026

Related posts