androidx.compose.material3

SecondaryTabRow

Composable function

One of the tab types. It works like PrimaryTabRow. Only the parameters that differ are described here.

Tabs inside a part of the screen, under primary tabs or in a card. The indicator is a thin line across the whole tab.

Secondary tabs
Secondary tabs
var selected by remember { mutableIntStateOf(1) }
val titles = listOf("Overview", "Specs", "Reviews")
SecondaryTabRow(selectedTabIndex = selected, modifier = Modifier.width(360.dp)) {
    titles.forEachIndexed { index, title ->
        Tab(selected = selected == index, onClick = { selected = index }, text = { Text(title) })
    }
}

Parameters

@Composable
fun SecondaryTabRow(
    selectedTabIndex: Int,
    modifier: Modifier = Modifier,
    containerColor: Color = TabRowDefaults.secondaryContainerColor,
    contentColor: Color = TabRowDefaults.secondaryContentColor,
    indicator: @Composable TabIndicatorScope.() -> Unit = @Composable { TabRowDefaults.SecondaryIndicator(Modifier.tabIndicatorOffset(selectedTabIndex, matchContentSize = false)) },
    divider: @Composable () -> Unit = @Composable { HorizontalDivider() },
    tabs: @Composable () -> Unit,
)

Defaults that differ from PrimaryTabRow:

Same as in PrimaryTabRow: selectedTabIndex, modifier, containerColor, contentColor, indicator, divider, tabs.

Tab types