Color Generator

Generate and export Tailwind color patterns.

Brand Colors

primary
secondary

State Colors

info
success
warning
error

Color Picker

Accordion

Detailed documentation for the Accordion and AccordionItem components in the PixelBlockUI library.

The Accordion component provides a flexible and interactive way to display collapsible content sections. It consists of the Accordion container and AccordionItem elements.

Installation

You can install the Accordion component using the PixelBlock CLI tool.

npx pixelblock-cli add Accordion

Usage

Basic Usage

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.


Interactive Accordion with Dynamic Content

You can also create an interactive accordion with dynamic content and state management.

Dynamic content for item 1

Dynamic content for item 2

Dynamic content for item 3


Single-Open Mode

When singleOpen is enabled, only one item can be open at a time. Opening a new item will automatically close the previously open item.

This item is in single-open mode. When you open this item, the other items will close.

You can only open one item at a time in this mode.

The other items will be closed automatically when a new one is opened.


Multi-Open Mode

When singleOpen is set to false (or not provided), multiple items can be opened at the same time. Each item can be toggled independently.

This item is in multi-open mode. You can open multiple items at once.

Each item can be opened independently without closing others.

All items can be expanded simultaneously.


Props

Accordion Props

PropTypeDefaultDescription
childrenReactNodeNested AccordionItem components.
singleOpenbooleantrueDetermines if only one item can be open at a time.

AccordionItem Props

PropTypeDefaultDescription
titlestringThe title of the accordion item.
childrenReactNodeThe content to be displayed within the item.
isOpenbooleanfalseControls the open/close state programmatically.
onTogglefunctionCallback for toggling the open/close state.
openIconReactNodeCustom icon to display when the item is closed.
closeIconReactNodeCustom icon to display when the item is open.

Conclusion

The Accordion and AccordionItem components offer a simple and effective way to display collapsible sections of content. By utilizing Tailwind CSS, these components are easy to style and integrate into your React or Next.js projects.

For more information and detailed usage instructions, refer to the PixelBlockUI Documentation.