Skip to Content
Nextra 4.0 is released 🎉
DocumentationComponentsAccordion

Accordion

The Accordion component is a pixel-art styled expandable sections control.
It supports single or multiple open panels, configurable default state, disabled items, and custom styling — ideal for organizing content in collapsible sections with a retro aesthetic.


🚀 Usage

Basic Example


Content for section 1
Content for section 2
Content for section 3
import { Accordion } from "pixelartui-react"; <Accordion items={[ { title: "Section 1", content: "Content for section 1" }, { title: "Section 2", content: "Content for section 2" }, { title: "Section 3", content: "Content for section 3" }, ]} onChange={(openIndexes) => console.log(openIndexes)} />

Default Open


Content for section 1
Content for section 2
Content for section 3
<Accordion items={[ { title: "Section 1", content: "Content for section 1" }, { title: "Section 2", content: "Content for section 2" }, { title: "Section 3", content: "Content for section 3" }, ]} defaultOpenIndexes={[0]} onChange={(openIndexes) => console.log(openIndexes)} />

Allow Multiple


Content for section 1
Content for section 2
Content for section 3
<Accordion items={[ { title: "Section 1", content: "Content for section 1" }, { title: "Section 2", content: "Content for section 2" }, { title: "Section 3", content: "Content for section 3" }, ]} allowMultiple defaultOpenIndexes={[0, 2]} onChange={(openIndexes) => console.log(openIndexes)} />

With Disabled Item


Content for section 1
Content for section 2
Content for section 3
<Accordion items={[ { title: "Section 1", content: "Content for section 1" }, { title: "Section 2 (Disabled)", content: "Content for section 2", disabled: true }, { title: "Section 3", content: "Content for section 3" }, ]} onChange={(openIndexes) => console.log(openIndexes)} />

Custom Background


Content for section 1
Content for section 2
Content for section 3
<Accordion items={[ { title: "Section 1", content: "Content for section 1" }, { title: "Section 2", content: "Content for section 2" }, { title: "Section 3", content: "Content for section 3" }, ]} backgroundColor="#05EB57" onChange={(openIndexes) => console.log(openIndexes)} />

Styles


Content for section 1
Content for section 2
Content for section 3
Content for section 1
Content for section 2
Content for section 3
<Accordion items={items} accordionStyle="dark" onChange={(openIndexes) => console.log(openIndexes)} /> <Accordion items={items} accordionStyle="light" onChange={(openIndexes) => console.log(openIndexes)} />

🔧 Props

PropTypeDefaultDescription
itemsAccordionItem[]Array of accordion items, each with title, content, and optional disabled.
allowMultiplebooleanfalseAllows multiple sections to be open simultaneously.
defaultOpenIndexesnumber[]undefinedIndices of sections that should be open by default.
accordionStyle"dark" | "light"undefinedApplies a light or dark theme to the component.
backgroundColorstringundefinedOverrides the default background color with a custom value.
classNamestringundefinedAdds additional CSS classes for custom styling.
onChange(openIndexes: number[]) => voidundefinedCallback fired when the set of open sections changes.
Last updated on