react-accordion-comp
React package
Install
npm install --save react-accordion-comp
Usage
Import styles to application.
import in a SCSS file.
@import "~react-accordion-comp/dist/styles.css";
or in JSX file
import "react-accordion-comp/dist/styles.css";
Import component to application.
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>
}
props
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 |
Demo gif
License
MIT © binodswain