SegmentedContent

fun SegmentedContent(items: List<SegmentedItem>, modifier: Modifier = Modifier, initialSelectedIndex: Int = 0, indicator: SegmentSelectionIndicator = SegmentSelectionIndicator.PILL, fitMode: SegmentFitMode = SegmentFitMode.EVEN_WHEN_FITS, widthMode: SegmentWidthMode = SegmentWidthMode.FILL, density: SegmentDensity = SegmentDensity.REGULAR, backgroundColor: Color = MaterialTheme.colorScheme.surfaceVariant, unselectedSegmentColor: Color = Color.Transparent, onSelectionChanged: (Int) -> Unit? = null, segmentTitle: @Composable (index: Int, item: SegmentedItem, isSelected: Boolean) -> Unit = { _, item, isSelected -> DefaultSegmentTitle(item.title, isSelected, indicator) }, segmentContent: @Composable (index: Int, item: SegmentedItem) -> Unit)

A tab-style segment bar above caller-supplied content that crossfades when the selection changes. When the titles overflow, the bar scrolls, keeps the selected segment in view, and fades the edge that has more segments. This overload keeps the selection itself (saved across recreation).

Parameters

unselectedSegmentColor

fill behind unselected segments; transparent lets backgroundColor show through.


fun SegmentedContent(items: List<SegmentedItem>, selectedIndex: Int, onSelectionChanged: (Int) -> Unit, modifier: Modifier = Modifier, indicator: SegmentSelectionIndicator = SegmentSelectionIndicator.PILL, fitMode: SegmentFitMode = SegmentFitMode.EVEN_WHEN_FITS, widthMode: SegmentWidthMode = SegmentWidthMode.FILL, density: SegmentDensity = SegmentDensity.REGULAR, backgroundColor: Color = MaterialTheme.colorScheme.surfaceVariant, unselectedSegmentColor: Color = Color.Transparent, segmentTitle: @Composable (index: Int, item: SegmentedItem, isSelected: Boolean) -> Unit = { _, item, isSelected -> DefaultSegmentTitle(item.title, isSelected, indicator) }, segmentContent: @Composable (index: Int, item: SegmentedItem) -> Unit)

SegmentedContent whose selection the caller owns through selectedIndex. Outgoing content keeps its item until the crossfade ends, including when that item is removed from items.