Tabs

Organize related content at one level of hierarchy and switch between views.

When to use

Primary tabs sit at the top of a screen and switch its main content areas. Secondary tabs divide content inside a region of a screen. Use the scrollable variants when there are more tabs than fit.

Playground

The interactive page has a playground with live property controls for this component and generated code.

Examples

Primary tabs

var selected by rememberSaveable { mutableIntStateOf(0) }
val titles = listOf("Overview", "Specs", "Reviews")

PrimaryTabRow(selectedTabIndex = selected) {
    titles.forEachIndexed { index, title ->
        Tab(
            selected = selected == index,
            onClick = { selected = index },
            text = { Text(title) },
        )
    }
}

Parameters

NameTypeDefaultDescription
selectedTabIndexIntIndex of the active tab.
indicator@Composable TabIndicatorScope.() -> UnitPrimaryIndicator / SecondaryIndicatorCustom selection indicator.
Tab.text / icon@Composable (() -> Unit)?nullProvide text, an icon or both.

Guidelines

Do:

Don't:

Accessibility

Related components