PrimaryTabRow

@Composable
fun PrimaryTabRow(selectedTabIndex: Int, modifier: Modifier = Modifier, containerColor: Color = TabRowDefaults.primaryContainerColor, contentColor: Color = TabRowDefaults.primaryContentColor, indicator: @Composable TabIndicatorScope.() -> Unit = { TabRowDefaults.PrimaryIndicator( modifier = Modifier.tabIndicatorOffset(selectedTabIndex, matchContentSize = true), width = Dp.Unspecified, ) }, divider: @Composable () -> Unit = @Composable { HorizontalDivider() }, tabs: @Composable () -> Unit)

Material Design Fixed Primary tabs

Primary tabs are placed at the top of the content pane under a top app bar. They display the main content destinations. Fixed tabs display all tabs in a set simultaneously. They are best for switching between related content quickly, such as between transportation methods in a map. To navigate between fixed tabs, tap an individual tab, or swipe left or right in the content area.

A TabRow contains a row of Tabs, and displays an indicator underneath the currently selected tab. A TabRow places its tabs evenly spaced along the entire row, with each tab taking up an equal amount of space. See PrimaryScrollableTabRow for a tab row that does not enforce equal size, and allows scrolling to tabs that do not fit on screen.

A simple example with text tabs looks like:

Parameters

selectedTabIndex

the index of the currently selected tab

modifier

the Modifier to be applied to this tab row

containerColor

the color used for the background of this tab row. Use Color.Transparent to have no color.

contentColor

the preferred color for content inside this tab row. Defaults to either the matching content color for containerColor, or to the current LocalContentColor if containerColor is not a color from the theme.

indicator

the indicator that represents which tab is currently selected. By default this will be a TabRowDefaults.PrimaryIndicator, using a TabRowDefaults.tabIndicatorOffset modifier to animate its position.

divider

the divider displayed at the bottom of the tab row. This provides a layer of separation between the tab row and the content displayed underneath.

tabs

the tabs inside this tab row. Typically this will be multiple Tabs. Each element inside this lambda will be measured and placed evenly across the row, each taking up equal space.

Samples

androidx.compose.material3.samples.PrimaryTextTabsandroidx.compose.material3.samples.FancyTabsandroidx.compose.material3.samples.FancyTabandroidx.compose.material3.samples.FancyIndicatorandroidx.compose.material3.samples.FancyIndicatorTabsandroidx.compose.material3.samples.FancyAnimatedIndicatorWithModifierandroidx.compose.material3.samples.FancyIndicatorContainerTabs