androidx.compose.material3
LeadingIconTab
Composable function
A part of PrimaryTabRow. See that page for an overview and examples.
Parameters
@Composable
fun LeadingIconTab(
selected: Boolean,
onClick: () -> Unit,
text: @Composable () -> Unit,
icon: @Composable () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
selectedContentColor: Color = LocalContentColor.current,
unselectedContentColor: Color = selectedContentColor,
interactionSource: MutableInteractionSource? = null,
)
selected: BooleanRequired
selected: BooleanRequiredWhether this tab is selected. Usually index == selectedIndex.
onClick: () -> UnitRequired
onClick: () -> UnitRequiredCalled when the tab is clicked. Set your selected index here.
text: @Composable () -> UnitRequired
text: @Composable () -> UnitRequiredThe name of the tab. Keep it short.
icon: @Composable () -> UnitRequired
icon: @Composable () -> UnitRequiredAn icon above the text, or alone.

var selected by remember { mutableIntStateOf(0) }
val tabs = listOf("Home" to Icons.Filled.Home, "Favorites" to Icons.Filled.Favorite, "Settings" to Icons.Filled.Settings)
PrimaryTabRow(selectedTabIndex = selected, modifier = Modifier.width(360.dp)) {
tabs.forEachIndexed { index, (title, icon) ->
Tab(
selected = selected == index,
onClick = { selected = index },
text = { Text(title) },
icon = { Icon(icon, contentDescription = null) },
)
}
}
enabled: BooleanOptional
enabled: BooleanOptionalDefault: true
Set to false to make the tab gray and not clickable.
selectedContentColor: ColorOptional
selectedContentColor: ColorOptionalDefault: LocalContentColor.current
The text and icon color of the selected tab.
unselectedContentColor: ColorOptional
unselectedContentColor: ColorOptionalDefault: selectedContentColor
The text and icon color of the other tabs.
interactionSource: MutableInteractionSource?Optional
interactionSource: MutableInteractionSource?OptionalDefault: null
Lets you observe or control press, hover and focus states. Leave it null unless your code must react to them. See InteractionSource.
Same as in PrimaryTabRow: modifier.