Skip to main content

Accordion

The Accordion component is a vertically stacked set of interactive headings that each reveal an associated section of content.

Basic Usage​

import { Accordion, ThemeProvider } from "@carton-org/react-neumorphism";

const items = [
{
title: "Getting Started",
content: "Learn how to get started with our product",
initiallyOpen: true,
icon: <CubeIcon />,
iconStyle: "default",
},
{
title: "Installation",
content: "Step by step installation guide",
icon: <CubeIcon />,
},
{
title: "Configuration",
content: "How to configure the component",
icon: <CubeIcon />,
},
];

<Accordion items={items} enableUniqueOpen={true} size="md" />;

Live Example​

Getting Started
Learn how to get started with our product
Installation
Step by step installation guide
Configuration
How to configure the component

Accordion Props​

NameTypeDescriptionRequiredDefault Value
itemsArray<AccordionItem>Array of accordion items. Each item should have title, content, and optionally initiallyOpen, icon, and iconStyle propertiesYes-
borderbooleanWhether to show a border around the accordionNofalse
enableUniqueOpenbooleanIf true, only one accordion item can be open at a timeNofalse
size"xs" | "sm" | "md" | "lg" | "xl"Size of the accordionNo"md"
accordionStyleReact.CSSPropertiesCustom styles for the main accordion containerNo-
accordionItemTitleStyleReact.CSSPropertiesCustom styles for the accordion item titleNo-
accordionItemContentStyleReact.CSSPropertiesCustom styles for the accordion item contentNo-
accordionItemContainerStyleReact.CSSPropertiesCustom styles for the accordion item containerNo-

Accordion Item Props​

NameTypeDescriptionRequiredDefault Value
iconReact.ReactNodeIcon to display next to the accordion item titleNo-
titlestringThe title text of the accordion itemYes-
contentstringThe content text to display when the accordion item is expandedYes-
initiallyOpenbooleanWhether the accordion item should be open by defaultNofalse
iconStyle"inset" | "default" | "outline"The style of the icon. Can be one of: inset, default, or outlineNo"default"

Examples​

Different Sizes​

Small Size

Small Accordion
This is a small sized accordion

Medium Size

Medium Accordion
This is a medium sized accordion

Large Size

Large Accordion
This is a large sized accordion

Icon Styles​

Default Icon Style

Default Style
Icon with default style

Inset Icon Style

Inset Style
Icon with inset style

Outline Icon Style

Outline Style
Icon with outline style

With Border​

Bordered Accordion
This accordion has a border