Accordion

Accordion

A collapsible content panel that organizes information into expandable sections.


Import

jsx
import { Accordion } from "asheeui";

Usage

tsx
import { Accordion } from "asheeui";
export default function Basic() {
const items = [
{ id: "1", title: "Section 1", content: "Content for section 1" },
{ id: "2", title: "Section 2", content: "Content for section 2" },
];
return <Accordion items={items} />;
}

Examples

Variant

Bordered

Content for section 1
Content for section 2

Separated

Content for section 1
Content for section 2

Flush

Content for section 1
Content for section 2

Ghost

Content for section 1
Content for section 2

Size

Small

Content for section 1
Content for section 2

Medium

Content for section 1
Content for section 2

Large

Content for section 1
Content for section 2

Radius

None

Content for section 1
Content for section 2

Extra Small

Content for section 1
Content for section 2

Small

Content for section 1
Content for section 2

Medium

Content for section 1
Content for section 2

Large

Content for section 1
Content for section 2

Extra Large

Content for section 1
Content for section 2

Full

Content for section 1
Content for section 2

Allow multiple open

Content for section 1
Content for section 2
Content for section 3

Controlled

Content for section 1
Content for section 2

Currently open: 1

With icons

Configure your preferences here
Profile content here

Custom expand icon

Content for section 1
Content for section 2

Disabled item

Content for section 1
Content for section 2
Content for section 3

Without animation

Content for section 1
Content for section 2

Props

PropTypeDefaultDescription
itemsAccordionItem[][]Array of accordion sections to render
variant"bordered" | "separated" | "ghost" | "flush""separated"*Visual style of accordion container
size"sm" | "md" | "lg""md"Size scale for header and content
radius"none" | "xs" | "sm" | "md" | "lg" | "xl" | "full""md"*Corner rounding for container
allowMultiplebooleanfalseAllows multiple sections to be open simultaneously
defaultValuestring | string[]NoneInitial open item(s) for uncontrolled usage
valuestring | string[]NoneControlled open item(s)
onValueChange(value: string[]) => voidNoneCallback when open item(s) change
expandIconReactNodeChevronDownIconCustom expand/collapse indicator
disableAnimationbooleanfalseDisables expand/collapse animations
itemClassNamestringNoneExtra classes applied to each item container
headerClassNamestringNoneExtra classes applied to each header button
contentClassNamestringNoneExtra classes applied to each content panel
classNamestringNoneExtra classes, merged with internal styles

* Falls back through Global Configuration if not set. See below.

AccordionItem

PropTypeDescription
idstringUnique identifier for the item
titleReactNodeHeader content
contentReactNodeExpandable content
subtitleReactNodeOptional subtext shown below title
iconReactNodeOptional icon shown before title
disabledbooleanPrevents item from being toggled

Global Configuration

Accordion reads defaults from four places, in this order of precedence:

  1. Instance prop: set directly on <Accordion />
  2. Component config: components.accordion in your ashee.config
  3. Theme default: defaultVariant / defaultRadius in your ashee.config
  4. Built-in fallback: component's internal default values

Component config

ts
// ashee.config.ts
import type { ExternalConfig } from "asheeui";
export const config: ExternalConfig = {
components: {
accordion: {
variant: "bordered",
size: "md",
radius: "md",
allowMultiple: false,
},
},
};

Built-in fallbacks

ts
{
size: "md",
variant: "separated",
radius: "md",
allowMultiple: false,
}

Accessibility

  • Renders a native <button> element for each header with proper type="button"
  • Uses aria-expanded and aria-controls to indicate state and associate headers with content panels
  • disabled items set disabled attribute on the trigger button
  • Implements focus-visible ring for keyboard navigation
  • Uses pointer-events-none on closed content panels to prevent focus trapping
  • Active item state exposed via data-state="open"/"closed" on content panels

Notes

  • Item IDs: Each item should have a unique id. If not provided, it will use the array index, which may cause issues with reordering.
  • Controlled vs Uncontrolled: Use value/onValueChange for controlled usage, or defaultValue for uncontrolled.
  • Animation: Uses CSS Grid for smooth height transitions. Can be disabled with disableAnimation.
  • Radius Application: ghost and flush variants don't apply radius to the container, while separated and ghost apply radius to individual items. This is by design for visual consistency.
Previous

← CLI Reference

Next

Autocomplete →