Accordion
A collapsible content panel that organizes information into expandable sections.
Import
Usage
Examples
Variant
Bordered
Separated
Flush
Ghost
Size
Small
Medium
Large
Radius
None
Extra Small
Small
Medium
Large
Extra Large
Full
Allow multiple open
Controlled
Currently open: 1
With icons
Custom expand icon
Disabled item
Without animation
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | AccordionItem[] | [] | 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 |
allowMultiple | boolean | false | Allows multiple sections to be open simultaneously |
defaultValue | string | string[] | None | Initial open item(s) for uncontrolled usage |
value | string | string[] | None | Controlled open item(s) |
onValueChange | (value: string[]) => void | None | Callback when open item(s) change |
expandIcon | ReactNode | ChevronDownIcon | Custom expand/collapse indicator |
disableAnimation | boolean | false | Disables expand/collapse animations |
itemClassName | string | None | Extra classes applied to each item container |
headerClassName | string | None | Extra classes applied to each header button |
contentClassName | string | None | Extra classes applied to each content panel |
className | string | None | Extra classes, merged with internal styles |
* Falls back through Global Configuration if not set. See below.
AccordionItem
| Prop | Type | Description |
|---|---|---|
id | string | Unique identifier for the item |
title | ReactNode | Header content |
content | ReactNode | Expandable content |
subtitle | ReactNode | Optional subtext shown below title |
icon | ReactNode | Optional icon shown before title |
disabled | boolean | Prevents item from being toggled |
Global Configuration
Accordion reads defaults from four places, in this order of precedence:
- Instance prop: set directly on
<Accordion /> - Component config:
components.accordionin yourashee.config - Theme default:
defaultVariant/defaultRadiusin yourashee.config - Built-in fallback: component's internal default values
Component config
Built-in fallbacks
Accessibility
- Renders a native
<button>element for each header with propertype="button" - Uses
aria-expandedandaria-controlsto indicate state and associate headers with content panels disableditems setdisabledattribute on the trigger button- Implements
focus-visiblering for keyboard navigation - Uses
pointer-events-noneon 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/onValueChangefor controlled usage, ordefaultValuefor uncontrolled. - Animation: Uses CSS Grid for smooth height transitions. Can be disabled with
disableAnimation. - Radius Application:
ghostandflushvariants don't apply radius to the container, whileseparatedandghostapply radius to individual items. This is by design for visual consistency.