GitHub release GitHub issues GitHub last commit Build Status npm npm Analytics

React Accordion

An accordion widget for React applications written in Typescript.

Install

npm i react-accordion-ts

# or

yarn add react-accordion-ts

Usage

import React from 'react';
import Accordion from 'react-accordion-ts';

const news = [
	{
		date: '12-10-2018',
		title: 'Awesome title',
		content: 'Fantastic content'
	},
	{
		date: '13-10-2018',
		title: 'Awesome title',
		content: 'Fantastic content'
	},
	{
		date: '13-10-2018',
		title: 'Awesome title',
		content: 'Fantastic content'
	}
];

const items = news.map(({ date, title, content }) => ({
	title: <h2>{date + ' - ' + title}</h2>,
	content: <p>{content}</p>
}));

export const MyComponent = () => <Accordion items={items} duration={300} multiple={true} />;

Props

  1. items: Array of objects with the following properties:

    • title [Required] - React Node
    • content [Required] - React Node
  2. Duration [Required] - Number (Duration of the toggling transition)

  3. Multiple [Required] - Boolean (If false, only one panel can be opened at any time)

LICENSE

MIT