# react-performant-collapsible

> A performant React.js Collapsible component

Latest version **0.2.1** (published 2021-12-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-performant-collapsible
pnpm add react-performant-collapsible
yarn add react-performant-collapsible
bun add react-performant-collapsible
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2021-12-04 |
| First published | 2021-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 39.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | foisonocean |
| Maintainers | foisonocean |
| Keywords | react, collapsible, expand, performant, typescript |

## Links

- npm: https://www.npmjs.com/package/react-performant-collapsible
- Repository: https://github.com/foisonocean/react-performant-collapsible
- Homepage: https://github.com/foisonocean/react-performant-collapsible#readme
- Issues: https://github.com/foisonocean/react-performant-collapsible/issues
- npm.io page: https://npm.io/package/react-performant-collapsible

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2021-12-04
- 0.2.0 — 2021-12-04
- 0.1.2 — 2021-02-12
- 0.1.1 — 2021-02-12
- 0.1.0 — 2021-02-12

## README

# react-performant-collapsible
A performant React.js Collapsible component.

![Demo](./doc-images/demo.gif)

## Why it's performant?

It doesn't repaint at all during the collapse/expand animation (It only repaint once at the beginning of the animation and once at the end of the animation):
![Doesn't Repaint](./doc-images/repaint.gif)

## Installation

```sh
npm i react-performant-collapsible
```

or

```sh
yarn add react-performant-collapsible
```

or

```sh
pnpm i react-performant-collapsible
```

## Props

|               Prop Name |    Type    | Required |                                                                                                 Note                                                                                                 |
|------------------------:|:----------:|:--------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|               className |   String   |   false  | className for the wrapper element                                                                                                                                                                    |
|                   style |   Object   |   false  | style for the wrapper element                                                                                                                                                                        |
|              horizontal |   Boolean  |   false  | if it is horizontal. default: `false`                                                                                                                                                                |
|               maskColor |   String   |   false  | background color for the mask element                                                                                                                                                                |
|       animationDuration |   String   |   false  | how long does the collapse/expand animation take. format is like `1s` or `400ms`, same as [CSS property `transition-duration`](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-duration) |
| animationTimingFunction |   String   |   false  | format is like `linear` or `cubic-bezier(.29, 1.01, 1, -0.68)`, same as [CSS property `transition-timing-function`](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function )    |
|             collapsible |   Boolean  |   true   | is currently collapsed or not                                                                                                                                                                        |
|                children | React Node |   true   |                                                                                                                                                                                                      |

## What is props `maskColor` used for?

Sometimes if the background color is not white, you need to set the `maskColor` to match the background color, e.g.

```jsx
<div style={{background: 'red'}}>
  <Collapsible collapsible={state.collapsible} maskColor="red">
    { someChildren }
  </Collapsible>
</div>
```

---
_Source: https://npm.io/package/react-performant-collapsible · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
