0.2.1 • Published 2 years ago

react-performant-collapsible v0.2.1

Weekly downloads
21
License
MIT
Repository
github
Last release
2 years ago

react-performant-collapsible

A performant React.js Collapsible component.

Demo

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

Installation

npm i react-performant-collapsible

or

yarn add react-performant-collapsible

or

pnpm i react-performant-collapsible

Props

Prop NameTypeRequiredNote
classNameStringfalseclassName for the wrapper element
styleObjectfalsestyle for the wrapper element
horizontalBooleanfalseif it is horizontal. default: false
maskColorStringfalsebackground color for the mask element
animationDurationStringfalsehow long does the collapse/expand animation take. format is like 1s or 400ms, same as CSS property transition-duration
animationTimingFunctionStringfalseformat is like linear or cubic-bezier(.29, 1.01, 1, -0.68), same as CSS property transition-timing-function
collapsibleBooleantrueis currently collapsed or not
childrenReact Nodetrue

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.

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