Skip to content

A lightweight and accessible React accordion component with smooth animations.

License

Notifications You must be signed in to change notification settings

vuhuuu11/react-accordion

Repository files navigation

# 🎉 React Accordion

A lightweight and accessible React accordion component with smooth animations. This library provides an easy way to add collapsible content sections to your applications.

![React Accordion](https://source.unsplash.com/featured/?accordion)

## Table of Contents

- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Customization](#customization)
- [Examples](#examples)
- [Accessibility](#accessibility)
- [Contributing](#contributing)
- [License](#license)
- [Releases](#releases)

## Features

- Lightweight: Minimal footprint for quick load times.
- Accessible: Follows best practices for accessibility.
- Smooth Animations: Adds a polished look to your UI.
- Easy to Customize: Adjust styles easily with TailwindCSS or custom CSS.
- Responsive: Works well on all devices.

## Installation

To install the React Accordion component, run the following command:

```bash
npm install react-accordion

Usage

To use the component, import it into your React application. Here is a basic example:

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

function App() {
    return (
        <Accordion>
            <Accordion.Item title="Section 1">
                <p>This is the content of section 1.</p>
            </Accordion.Item>
            <Accordion.Item title="Section 2">
                <p>This is the content of section 2.</p>
            </Accordion.Item>
        </Accordion>
    );
}

export default App;

Customization

You can customize the Accordion component by passing props for styles, animations, and more. Here’s how to use TailwindCSS for styling:

<Accordion.Item className="bg-gray-200 p-4 rounded-lg">
    <h2 className="text-xl font-bold">Custom Title</h2>
    <p className="text-gray-700">Custom content here.</p>
</Accordion.Item>

Examples

You can find more detailed examples in the Examples directory. Here are a few scenarios:

Basic Accordion

This shows how to implement a simple accordion.

Nested Accordions

Learn how to create nested accordion items for more complex layouts.

Themed Accordion

See how to style the accordion according to your brand guidelines.

Accessibility

This component adheres to WAI-ARIA guidelines, ensuring all users can interact with it effectively. Keyboard navigation is fully supported.

Contributing

We welcome contributions! To contribute:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes.
  4. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Releases

To download and check the latest releases, visit the Releases section.

GitHub Releases

Topics

  • accordion
  • animated
  • collapsible
  • component
  • customization
  • library
  • lightweight
  • motion
  • npm
  • react
  • tailwindcss
  • ui

Thank you for checking out the React Accordion! We hope you find it useful in your projects.