StylishConnectedToggleRow

fun StylishConnectedToggleRow(items: List<String>, selectedIndex: Int?, onSelectedChange: (Int) -> Unit, modifier: Modifier = Modifier, cornerRadius: Dp = StylishTheme.dimensions.connectedCornerRadius, spacing: Dp = StylishTheme.dimensions.connectedSpacing, contentPadding: PaddingValues = PaddingValues(horizontal = 12.dp, vertical = 12.dp), selectedContainerColor: Color = MaterialTheme.colorScheme.primaryContainer, selectedContentColor: Color = MaterialTheme.colorScheme.onPrimaryContainer, unselectedContainerColor: Color = MaterialTheme.stylishComponentColors.groupedContainer, unselectedContentColor: Color = MaterialTheme.colorScheme.onSurface)

A horizontally connected row of toggle buttons for mutually exclusive selection among a small set of string-labeled options.

This is the Finish-layer component: it supplies the Stylish toggle rendering to the headless Structure layout ConnectedToggleRow, which owns arrangement and connection geometry. Each item occupies an equal weight within the row and stretches to the tallest sibling. Outline edges and corner radii are computed automatically from each item's index. The selected item is highlighted with selectedContainerColor and selectedContentColor; unselected items use unselectedContainerColor and unselectedContentColor. Selection changes trigger haptic feedback and smooth color animation.

Use this component for day-of-week pickers, view-mode switches, or any inline multi-option selection where exactly one option is active at a time.

Parameters

items

The list of string labels for each toggle segment.

selectedIndex

The index of the currently selected item, or null if no item is selected.

onSelectedChange

Callback invoked with the index of the tapped item.

modifier

The modifier applied to the root layout.

cornerRadius

The radius applied to the outer corners of the first and last items. Defaults to StylishTheme.dimensions.connectedCornerRadius (12 dp).

spacing

The horizontal gap between adjacent items. Defaults to StylishTheme.dimensions.connectedSpacing (3 dp).

contentPadding

The inner padding of each toggle button. Defaults to 12 dp horizontal and 12 dp vertical.

selectedContainerColor

The container color for the selected item. Defaults to MaterialTheme.colorScheme.primaryContainer.

selectedContentColor

The content color for the selected item. Defaults to MaterialTheme.colorScheme.onPrimaryContainer.

unselectedContainerColor

The container color for unselected items. Defaults to MaterialTheme.stylishComponentColors.groupedContainer.

unselectedContentColor

The content color for unselected items. Defaults to MaterialTheme.colorScheme.onSurface.

See also