React package📦 to render accordion component. view demo
npm install --save react-accordion-comp
import in a SCSS file.
@import "~react-accordion-comp/dist/styles.css";
or in JSX file
import "react-accordion-comp/dist/styles.css";
import React, { useState } from 'react';
import Accordion from "react-accordion-comp";
function App() {
const [flag, setFlag] = useState(false);
return (
<div className="container">
<button onClick={()=>setFlag(!flag)}>
toggle content
</button>
<Accordion isOpen={flag}>
<div className="red">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In sed tempor sem. Aenean vel turpis feugiat,
ultricies metus at, consequat velit. Curabitur est nibh,
varius in tellus nec, mattis pulvinar metus.
In maximus cursus lorem, nec laoreet velit eleifend vel.
Ut aliquet mauris tortor, sed egestas libero interdum vitae.
Fusce sed commodo purus, at tempus turpis.
</p>
</div>
</Accordion>
</div>
}
The props passed to react-accordion-comp.
attribute | type | optional | defaultVal | details |
---|---|---|---|---|
isOpen | boolean | false | false |
flag to toggle the component |
duration | string | true | 0.3s |
duration of transition |
timingFunc | string | true | ease |
timing-function of transition |
MIT © binodswain