GithubHelp home page GithubHelp logo

szhsin / react-accordion Goto Github PK

View Code? Open in Web Editor NEW
167.0 1.0 9.0 6.48 MB

The complete accordion solution for React

Home Page: https://szhsin.github.io/react-accordion/

License: MIT License

JavaScript 7.27% TypeScript 71.43% CSS 4.98% HTML 0.72% Shell 0.54% MDX 15.07%
accessibility accordion component design-system headless-ui hook react unstyled wai-aria

react-accordion's Introduction

React-Accordion

An unstyled, accessible accordion library for React apps and design systems.

Examples and Docs

NPM NPM

Features

  • Unstyled React accordion components
  • React hooks for Headless usage
  • WAI-ARIA compliant
  • Keyboard navigable
  • Support animation
  • Can be controlled or uncontrolled
  • Control to expand/collapse specific item or all items
  • Level 3 support of React 18 concurrent rendering
  • Support server-side rendering
  • Small and tree-shakable (~3kB)
  • Strongly typed API with TypeScript

react accordion

Install

with npm

npm install @szhsin/react-accordion

or with Yarn

yarn add @szhsin/react-accordion

Usage

import { Accordion, AccordionItem } from '@szhsin/react-accordion';

export default function Example() {
  return (
    <Accordion>
      <AccordionItem header="What is Lorem Ipsum?">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
        do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      </AccordionItem>

      <AccordionItem header="Where does it come from?">
        Quisque eget luctus mi, vehicula mollis lorem. Proin fringilla
        vel erat quis sodales. Nam ex enim, eleifend venenatis lectus
        vitae, accumsan auctor mi.
      </AccordionItem>

      <AccordionItem header="Why do we use it?">
        Suspendisse massa risus, pretium id interdum in, dictum sit
        amet ante. Fusce vulputate purus sed tempus feugiat.
      </AccordionItem>
    </Accordion>
  );
}

Edit on CodeSandbox

Visit more examples and docs

License

MIT Licensed.

react-accordion's People

Contributors

dependabot[bot] avatar giordanooneteam avatar ochoav avatar stuart-drennan-instil avatar szhsin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

react-accordion's Issues

can't modify the header

I want absolute control of everything. I can't access the h3 and button elements in the header component. It's necessary for me.

Automatically Scroll to Content when opened on mobile

Hi, is there a way to have it automatically scroll to the top of content when an accordion is open on mobile. currently the user has to scroll back up tot see the opened accordion. this is similar to the issue explained here with gif - oblador/react-native-collapsible#86

Or Another possible solution is to not have the previously opened accordion not collapse when new one is opened. (on mobile) so that there is no shift in where the accordion gets opened.

Feature Idea: Preset Accordion Styling

Hi! I love this package! It makes setting up high quality accordions super convenient. One suggestion is it would be great to get some preset styling so that we don't have to write our own styling before pushing code to production.

Is it possible to toggle accordion only on click on arrow icon?

Hi there,

I hope you are doing well, first of all thanks for the package. I have a bit different scenario for my use case. What I want to achieve is that I only want to open accordion on click on arrow icon. I will really appreciate it if you please guide on how to do this.

Regards,

Shehzad Asif
Front-end Developer

Chevron not appearing

The chevron isn't loading in (not found in inspector) when installed using yarn add @szhsin/react-accordion. Otherwise, the accordion is working as expected.

<Accordion allowMultiple>
  <AccordionItem header={<li></li>}>
    <div class="content"></div>
  </AccordionItem>
</Accordion>

Multiple Accordion Triggers?

Hi there, thanks for the library! I was wondering if there was a way to have multiple accordion triggers besides the header. So something like a button below an accordion that would open up the accordion too. To build something like:

Screenshot 2023-05-08 at 12 33 46 PM

Any ideas how this would be possible, would be greatly appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.