npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-responsive-accordion

v1.0.0

Published

React accordion component which is 100% responsive.

Downloads

2,075

Readme

React Responsive Accordion Component

React component to wrap content in Accordion element.

Alt text

This component is dependent on React Collapsible

Installation

Installation can be achieved via NPM.

npm install react-responsive-accordion

Alternatively just download the Accordion.js file form the src folder and include it in your project in your chosen way.

Usage

Collapsible can receive any HTML elements or React component as it's children. Collapsible will wrap the contents, as well as generate a trigger element which will control showing and hiding.

ES6 Example

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

var App = React.createClass({


  render: function() {
    return(
      <div>

        <Accordion>
          <div data-trigger="A nifty React accordion component">
            <p>So this is an Accordion component that used the <a href="https://github.com/glennflanagan/react-collapsible">react-collapsible</a> component. How handy.</p>
          </div>

          <div data-trigger="What the difference?" data-trigger-when-open="THAT is the difference!">
            <p>An Accordion is different to a Collapsible in the sense that only one "tray" will be open at any one time.</p>
          </div>

          <div data-trigger="I'm responsive and I have a little secret. Look inside.">
            <p>And this Accordion component is also completely repsonsive. Hurrah for mobile users!</p>
          </div>
        </Accordion>

      </div>
    );
  }

});

export default App;

With a little CSS becomes

Alt text

Children Properties

The Accordion expects to wrap its children's content in the React Collapsible compoenent. In order to set the text on these compoenents then the Accordion children are able to take the following properties.

data-trigger | string | required

The text to appear in the trigger link.

data-trigger-when-open | string

Optional trigger text to change to when the Collapsible is open.

data-trigger-Disabled | boolean

Optional flag to disable triggers programatically.

Accordion Properties (Options)

startPosition | number | default: 0

The zero based position you wish the Accordion to start open at.

transitionTime | number | default: 400

The number of milliseconds for the open/close transition to take.

easing | string | default: 'liner'

The CSS easing method you wish to apply to the open/close transition. This string can be any valid value of CSS transition-timing-function. For reference view the MDN documentation.

classParentString | string | default: Collapsible

Use this to overwrite the parent CSS class for the Collapsible component parts. Read more in the CSS section below.

CSS Styles

The CSS styles for this Accordion adopt the same structure as the React Collapsible component.

In theory you don't need any CSS to get this to work, but let's face it, it'd be pretty rubbish without it.

By default the parent CSS class name is .Collapsible but this can be changed by setting the classParentString property on the Accordion component.

The CSS class names follow a type of BEM pattern of CSS naming. Below is a list of the CSS classes available on the component.

.Collapsible

The parent element for the components.

.Collapsible__trigger

The trigger link that controls the opening and closing of the component. The state of the component is also reflected on this element with the modifier classes;

  • is-closed | Closed state
  • is-open | Open setState

.Collapsible__contentOuter

The outer container that hides the content. This is set to overflow: hidden within the javascript but everything else about it is for you to change.

.Collapsible__contentInner

This is a container for the content passed into the compoenent. This keeps everything nice and neat and allows the component to do all it's whizzy calculations.

Example

An example of the component in action is available in the example folder. To see it in action you can run npm install and then run gulp. This will compile all the JSX into JS and open the example page using BrowserSync.

Licence

React Responsive Collapsible Section Component is MIT licensed