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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mukhindev/react-accordion

v1.0.4

Published

Accordion-component for React

Readme

react-accordion

Minimalistic accordion for React. Without styles and prepared elements. Create what you need using JSX and returned data.

Demo

Accordion component for React

https://mukhindev.github.io/react-accordion/

What new?

  • v1.0.4
    • fix image in readme.md
  • v1.0.3
    • headerProps and bodyProps now return group index (for example you can style the first or last elements)
    • bodyProps now return onToggle (for example can be used for auto-close)
  • v1.0.2
  • v1.0.1
  • v1.0.0

How to use

Install

npm i @mukhindev/react-accordion

Props

<Accordion
  className="" // custom class, optional (default: 'accordion')
  data={ data } // data array
  keyField="groupId" // unique key field in the data array
  Header={ (headerProps) => (
    // any JSX for header
  ) }
  Body={ (bodyProps) => (
    // any JSX for body
  ) }
  duration={ 0.25 } // transition duration in s / optional (default: 0.25)
  single // automatic closing for other groups / optional (default: false)
  onOpen={ () => {} } // group opening hook, returns the group key
  onClose={ () => {} } // group closing hook, returns the group key (not if 'single')
/>

Returned Props

<Accordion
  Header={ (headerProps) => () }
  Body={ (bodyProps) => () }
/>

headerProps and bodyProps contain the same data:

{
  ...data // data item from data array
  onToggle // function —> open/close
  isOpen // bool, сurrent open/close state
  index // group index
}

Example-1

import Accordion from '@mukhindev/react-accordion';

const data = [
  {
    id: '1',
    header: 'Card-1',
    body: 'Body-1'
  },
  {
    id: '2',
    header: 'Card-2',
    body: 'Body-2'
  }
];

const Example1 = () => {
  return {
    <Accordion
      data={ data }
      keyField="id"
      Header={ (headerProps) => (
        <button onClick={ headerProps.onToggle } >
          { headerProps.header }
        </button>
      ) }
      Body={ (bodyProps) => (
        <div>
          { bodyProps.body }
        </div>
      ) }
    />
  }
};

export default Example1;
----------
Card-1 ↓
----------
Body-1 
----------
Card-2 →
----------

Example-2

import Accordion from '@mukhindev/react-accordion';

const data = [
  {
    groupId: 'g1',
    groupName: 'Group-1',
    groupData: [
      {
        id: 'g1-1',
        value: 'Value-1'
      },
      {
        id: 'g1-2',
        value: 'Value-2'
      }
    ]
  },
  {
    groupId: 'g2',
    groupName: 'Group-2',
    groupData: [
      {
        id: 'g2-1',
        value: 'Value-3'
      }
    ]
  }
];

const Example2 = () => {
  return {
    <Accordion
      data={ data }
      keyField="groupId"
      Header={ (headerProps) => (
        <button onClick={ headerProps.onToggle } >
          { headerProps.groupName }
        </button>
      ) }
      Body={ (bodyProps) => (
        <div>
          { bodyProps.groupData.map((el) => (
            <div key={ el.id }>{ el.value }</div>
          )) }
        </div>
      ) }
    />
  }
};

export default Example2;
----------
Group-1 ↓
----------
Value-1 
Value-2
----------
Group-2 →
----------

Todo:

  • [x] v1
  • [x] Publish to npm
  • [x] return props onOpen()
  • [x] return props onClose()
  • [x] return props group index
  • [ ] Auto-close
  • [ ] Footer
  • [ ] remove overflow: hidden; after transition