StylishAccordion

fun StylishAccordion(items: List<StylishAccordionItem>, modifier: Modifier = Modifier, expandedIndex: Int? = null, onExpandedChange: (Int?) -> Unit? = null, spacing: Dp = StylishTheme.dimensions.connectedSpacing, shape: Shape = RoundedCornerShape(DefaultStylishDimensions.connectedCornerRadius), containerColor: Color = MaterialTheme.colorScheme.surfaceContainerHigh, contentColor: Color = MaterialTheme.colorScheme.onSurface, titleStyle: TextStyle = MaterialTheme.typography.titleMedium, titleMaxLines: Int = 1, titleOverflow: TextOverflow = TextOverflow.Ellipsis, enabled: Boolean = true)

A vertically stacked set of collapsible sections — the web "accordion" pattern from shadcn/ui, MUI, and Chakra UI.

At most one section is expanded at a time. The component is fully hoisted when onExpandedChange is provided; otherwise it manages the expanded index internally.

Parameters

items

The sections to display, in order.

modifier

Modifier applied to the root column.

expandedIndex

Index of the currently expanded section, or null to collapse all. When onExpandedChange is null, this is the initial value and the component manages its own state.

onExpandedChange

Optional callback invoked with the newly expanded index (or null when a section is collapsed). When null, the component manages its own expansion state.

spacing

Gap between adjacent sections. Defaults to StylishTheme.dimensions.connectedSpacing (3 dp), keeping the sections visually grouped.

shape

Corner shape of each section surface. Defaults to RoundedCornerShape with DefaultStylishDimensions.connectedCornerRadius.

containerColor

Background of each section. Defaults to MaterialTheme.colorScheme.surfaceContainerHigh.

contentColor

Foreground color of the section content.

titleStyle

Typography of the section headers. Defaults to MaterialTheme.typography.titleMedium.

titleMaxLines

Maximum lines for StylishAccordionItem.title.

titleOverflow

Overflow strategy for the title.

enabled

When false, no section can be toggled.