Kwik Accordion Group
AccordionGroup component that manages a group of accordions. Can be configured to allow multiple accordions to be expanded at once or only one at a time.
Parameters
: If true, multiple accordions can be expanded at once. If false, only one accordion can be expanded at a time.
: List of indices that should be expanded initially.
: List of items to create accordions for.
: Function to extract the title from an item.
: Function to extract the header icon from an item (optional).
: The color of the accordion containers.
: The elevation of the accordions.
: The color of the titles.
: Function to determine if an item should display an error (optional).
: Function to extract the error icon from an item (optional).
: Function to provide the content for each accordion.
Example usage:
val items = listOf(
AccordionItem("First Item", "Content for first item"),
AccordionItem("Second Item", "Content for second item", true),
AccordionItem("Third Item", "Content for third item")
)
KwikAccordionGroup(
allowMultipleExpanded = false,
initialExpandedIndices = listOf(0),
items = items,
titleProvider = { it.title },
containerColor = Color.White,
elevation = 8,
headerTextColor = Color.Black,
errorProvider = { it.hasError },
errorIcon = R.drawable.error_icon
) { item ->
Text(text = item.content, modifier = Modifier.padding(16.dp))
}