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

@tenaspace/react-headless-accordion

v1.0.15

Published

This is an unstyled React component that helps you to easily make the Accordion UI with your style.

Downloads

112

Readme

@tenaspace/react-headless-accordion

This is an unstyled React component that helps you to easily make the Accordion UI with your style.

Demo

See the DEMO

Installation

yarn add @tenaspace/react-headless-accordion

or via npm

npm install @tenaspace/react-headless-accordion

Usage

Example with Tailwind CSS (Recommend)

import { HeadlessAccordion } from '@tenaspace/react-headless-accordion'

const list = [
  {
    title: 'item 1',
    content:
      'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Suscipit atque id accusamus nesciunt illo inventore placeat vitae unde aspernatur, officiis, exercitationem dolorem! Sint sed libero perspiciatis beatae, natus quasi quisquam.',
  },
  {
    title: 'item 2',
    content:
      'Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eligendi quidem nam delectus neque consectetur impedit laudantium atque saepe enim maiores corrupti nemo beatae aliquam, expedita dolore esse. Ipsam, quaerat?',
  },
  {
    title: 'item 3',
    content:
      'Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quia est, deleniti ex veniam voluptatibus ullam saepe. Quia, id dignissimos tenetur numquam velit magni inventore aperiam ducimus perferendis deleniti laborum dicta!',
  },
]

const App = () => {
  return (
    <>
      <HeadlessAccordion defaultActiveKey={[`0`]} className={`border border-black`}>
        {list.map((item, key) => (
          <HeadlessAccordion.Item key={key} eventKey={`${key}`} className={`border border-black`}>
            {({ open }) => {
              return (
                <>
                  <HeadlessAccordion.Button
                    as={`button`}
                    className={`block w-full px-8 py-4 text-left transition-colors duration-300 ${
                      open ? `bg-black text-white` : ``
                    }`}
                  >
                    <span className={`-mx-2 flex flex-nowrap items-center justify-between`}>
                      <span className={`flex-[1_0_0%] px-2`}>{item.title}</span>
                      <span className={`w-auto flex-[0_0_auto] px-2`}>{open ? `-` : `+`}</span>
                    </span>
                  </HeadlessAccordion.Button>
                  <HeadlessAccordion.Panel className={`transition-[max-height] duration-300`}>
                    <div className={`p-8`}>{item.content}</div>
                  </HeadlessAccordion.Panel>
                </>
              )
            }}
          </HeadlessAccordion.Item>
        ))}
      </HeadlessAccordion>
    </>
  )
}

export default App

Example with Style inline

import { HeadlessAccordion } from '@tenaspace/react-headless-accordion'

const list = [
  {
    title: 'item 1',
    content:
      'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Suscipit atque id accusamus nesciunt illo inventore placeat vitae unde aspernatur, officiis, exercitationem dolorem! Sint sed libero perspiciatis beatae, natus quasi quisquam.',
  },
  {
    title: 'item 2',
    content:
      'Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel, eligendi quidem nam delectus neque consectetur impedit laudantium atque saepe enim maiores corrupti nemo beatae aliquam, expedita dolore esse. Ipsam, quaerat?',
  },
  {
    title: 'item 3',
    content:
      'Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quia est, deleniti ex veniam voluptatibus ullam saepe. Quia, id dignissimos tenetur numquam velit magni inventore aperiam ducimus perferendis deleniti laborum dicta!',
  },
]

const App = () => {
  return (
    <>
      <HeadlessAccordion defaultActiveKey={[`0`]} style={{ border: `1px solid black` }}>
        {list.map((item, key) => (
          <HeadlessAccordion.Item key={key} eventKey={`${key}`} style={{ border: `1px solid black` }}>
            {({ open }) => {
              return (
                <>
                  <HeadlessAccordion.Button
                    as={`button`}
                    style={{
                      cursor: `pointer`,
                      display: `block`,
                      width: `100%`,
                      backgroundColor: open ? `black` : ``,
                      padding: `16px 32px`,
                      textAlign: `left`,
                      color: open ? `white` : ``,
                      transitionProperty: `color`,
                      transitionDuration: `0.3s`,
                    }}
                  >
                    <span
                      style={{
                        margin: `0 -8px`,
                        display: `flex`,
                        flexWrap: `nowrap`,
                        alignItems: `center`,
                        justifyContent: `space-between`,
                      }}
                    >
                      <span
                        style={{
                          flex: `1 0 0%`,
                          padding: `0 8px`,
                        }}
                      >
                        {item.title}
                      </span>
                      <span
                        style={{
                          width: `auto`,
                          flex: `0 0 auto`,
                          padding: `0 8px`,
                        }}
                      >
                        {open ? `-` : `+`}
                      </span>
                    </span>
                  </HeadlessAccordion.Button>
                  <HeadlessAccordion.Panel
                    style={{
                      transitionProperty: `max-height`,
                      transitionDuration: `0.3s`,
                    }}
                  >
                    <div
                      style={{
                        padding: `32px`,
                      }}
                    >
                      {item.content}
                    </div>
                  </HeadlessAccordion.Panel>
                </>
              )
            }}
          </HeadlessAccordion.Item>
        ))}
      </HeadlessAccordion>
    </>
  )
}

export default App

Props

| Name | Mandatory | Type | Default value | Component | Note | | ---------------- | --------- | ------------------- | ------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | defaultActiveKey | optional | string[] | [] | HeadlessAccordion | Make the item you want open by default in the first load. Ex: ['0', '1'] => Item 1 and Item 2 will be opend in the first load. (The value must match with the eventKey of the HeadlessAccordion.Item) | | multipleOpen | optional | boolean | false | HeadlessAccordion | Set it true if you want to open multiple the Item | | eventKey | required | string | | HeadlessAccordion.Item | The key ID of the Item | | as | optional | React.ElementType | div | All | Set the tag HTML like whatever you want | | className | optional | string | null | All | | | style | optional | React.CSSProperties | {} | All | |