React-Accordion
An unstyled, accessible accordion library for building React apps and design systems.
Examples and Docs
Features
- Unstyled React accordion components
- Headless UI React hooks
- WAI-ARIA compliant
- Keyborad navigable
- Support animation
- Can be controlled or uncontrolled
- Level 3 support of React 18 concurrent rendering
- Tree-shakable and bundle size optimised
- Support server-side rendering
- Strongly typed API with TypeScript
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.