React Accordion Box
Accordion component for React.
Install module
> npm i react-accordion-new
Usage
import React from 'react';
import ReactAccordion from 'react-accordion-new';
class Example extends React.Component {
constructor(props) {
super(props);
}
render() {
const elements = [
{title:'test 1', content:'<h1>Heading 1</h1>'},
{title:'test 2', content:'gaurav 2'},
{title:'test 3', content:'gaurav'}
];
return (
<div>
<ReactAccordion elements={elements} />
</div>
)
}
}
Options/Props
The ReactAccordion
component accepts the following props:
{
elements: [],
default: false
}
-
Elements
- Required Prop
- Each entry refers to children of the accordion
- Array of Objects with following keys:-
- title : Text for the title of the child
- content : Content string of the child
-
default
- Optional Prop
- Default to false
- If true then first child is expanded by default