androidx.compose.material3

SecondaryScrollableTabRow

Composable function

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

Secondary tabs that scroll sideways when they do not fit.

Secondary tabs that scroll
Secondary tabs that scroll
var selected by remember { mutableIntStateOf(0) }
val titles = listOf("Overview", "Specifications", "Reviews", "Questions", "Related")
SecondaryScrollableTabRow(selectedTabIndex = selected, modifier = Modifier.width(360.dp)) {
    titles.forEachIndexed { index, title ->
        Tab(selected = selected == index, onClick = { selected = index }, text = { Text(title) })
    }
}

Parameters

@Composable
fun SecondaryScrollableTabRow(
    selectedTabIndex: Int,
    modifier: Modifier = Modifier,
    scrollState: ScrollState = rememberScrollState(),
    containerColor: Color = TabRowDefaults.secondaryContainerColor,
    contentColor: Color = TabRowDefaults.secondaryContentColor,
    edgePadding: Dp = TabRowDefaults.ScrollableTabRowEdgeStartPadding,
    indicator: @Composable TabIndicatorScope.() -> Unit = @Composable { TabRowDefaults.SecondaryIndicator(Modifier.tabIndicatorOffset(selectedTabIndex, matchContentSize = false)) },
    divider: @Composable () -> Unit = @Composable { HorizontalDivider() },
    minTabWidth: Dp = TabRowDefaults.ScrollableTabRowMinTabWidth,
    tabs: @Composable () -> Unit,
)

scrollState: ScrollStateOptional

Default: rememberScrollState()

Controls scrolling of a scrollable row.

edgePadding: DpOptional

Default: TabRowDefaults.ScrollableTabRowEdgeStartPadding

Space before the first tab and after the last tab of a scrollable row.

minTabWidth: DpOptionalSince 1.9

Default: TabRowDefaults.ScrollableTabRowMinTabWidth

The narrowest a tab can be in a scrollable row.

Defaults that differ from PrimaryTabRow:

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

Tab types