Tab

fun RowScope.Tab(selected: Boolean, modifier: Modifier = Modifier, enabled: Boolean = true, onClick: () -> Unit, text: @Composable () -> Unit? = null, icon: @Composable () -> Unit? = null, shape: Shape = RoundedCornerShape(16.dp), selectedContentColor: Color = LocalContentColor.current, unselectedContentColor: Color = selectedContentColor.copy(alpha = ContentAlpha.medium))

Tab without ripple

Tabs organize content across different screens, data sets, and other interactions.

A Tab represents a single page of content using a text label and/or icon. It represents its selected state by tinting the text label and/or image with selectedContentColor.

This should typically be used inside a TabRow, see the corresponding documentation for example usage.

This Tab has slots for text and/or icon - see the other Tab overload for a generic Tab that is not opinionated about its content.

Tab(
selected = index == pagerState.currentPage,
text = {
Text(text = text, color = tabTextColor)
},
onClick = {
coroutineScope.launch {
pagerState.animateScrollToPage(index)
}
}
)

Parameters

selected

whether this tab is selected or not

modifier

optional Modifier for this tab

enabled

controls the enabled state of this tab. When false, this tab will not be clickable and will appear disabled to accessibility services.

onClick

the callback to be invoked when this tab is selected

text

the text label displayed in this tab

icon

the icon displayed in this tab

shape

Defines the tab's shape.

selectedContentColor

the color for the content of this tab when selected, and the color of the ripple.

unselectedContentColor

the color for the content of this tab when not selected

See also


fun RowScope.Tab(selected: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier, shape: Shape = RoundedCornerShape(16.dp), enabled: Boolean = true, selectedContentColor: Color = LocalContentColor.current, unselectedContentColor: Color = selectedContentColor.copy(alpha = ContentAlpha.medium), content: @Composable ColumnScope.() -> Unit)

Tab without ripple

Tabs organize content across different screens, data sets, and other interactions.

Generic Tab overload that is not opinionated about content / color. See the other overload for a Tab that has specific slots for text and / or an icon, as well as providing the correct colors for selected / unselected states.

A custom tab using this API may look like:

Tab(
selected = index == pagerState.currentPage,
onClick = {
// on click
}
) {
// Content
}

Parameters

selected

whether this tab is selected or not

onClick

the callback to be invoked when this tab is selected

modifier

optional Modifier for this tab

shape

Defines the tab's shape.

enabled

controls the enabled state of this tab. When false, this tab will not.

selectedContentColor

the color for the content of this tab when selected, and the color of the ripple.

unselectedContentColor

the color for the content of this tab when not selected.

content

the content of this tab