JetpackToggleOptions

fun JetpackToggleOptions(options: List<ToggleOption>, selectedIndex: Int, onSelectionChange: (Int) -> Unit, modifier: Modifier = Modifier)

A row of toggle options that can be selected. Displays a segmented button-style selector with animated transitions between states.

This component is useful for mutually exclusive choices like theme selection (Light/Dark/System), view modes (List/Grid), or any other set of 2-4 options.

Usage example:

val themeOptions = listOf(
ToggleOption(text = R.string.light, icon = Icons.Default.LightMode),
ToggleOption(text = R.string.dark, icon = Icons.Default.DarkMode),
ToggleOption(text = R.string.system, icon = Icons.Default.SettingsBrightness),
)
var selectedTheme by remember { mutableIntStateOf(2) } // System

JetpackToggleOptions(
options = themeOptions,
selectedIndex = selectedTheme,
onSelectionChange = { selectedTheme = it },
)

Parameters

options

The list of options to display. Recommended 2-4 options for best UX.

selectedIndex

The zero-based index of the selected option.

onSelectionChange

The callback to invoke when the selected option changes.

modifier

The modifier to apply to the row.