State of Compose 2023 results are in! Click here to learn more

← Back to Material 3 Compose

LeadingIconTab

Component
in
Material 3
. Since 1.0.0

Overview

Code Examples

<a href="https://m3.material.io/components/tabs/overview" class="external" target="_blank">Material Design tab.</a>

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

A LeadingIconTab represents a single page of content using a text label and an icon in front of the label. It represents its selected state by tinting the text label and icon with selectedContentColor.

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

@param selected whether this tab is selected or not @param onClick called when this tab is clicked @param text the text label displayed in this tab @param icon the icon displayed in this tab @param modifier the Modifier to be applied to this tab @param enabled controls the enabled state of this tab. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services. @param selectedContentColor the color for the content of this tab when selected, and the color of the ripple. @param unselectedContentColor the color for the content of this tab when not selected @param interactionSource the MutableInteractionSource representing the stream of Interactions for this tab. You can create and pass in your own remembered instance to observe Interactions and customize the appearance / behavior of this tab in different states.

@see Tab

Overloads

LeadingIconTab

@Composable
fun LeadingIconTab(
    selected: Boolean,
    onClick: () -> Unit,
    text: @Composable () -> Unit,
    icon: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    selectedContentColor: Color = LocalContentColor.current,
    unselectedContentColor: Color = selectedContentColor,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }
)

Parameters

NameDescription
selectedwhether this tab is selected or not
onClickcalled when this tab is clicked
textthe text label displayed in this tab
iconthe icon displayed in this tab
modifierthe Modifier to be applied to this tab
enabledcontrols the enabled state of this tab. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services.
selectedContentColorthe color for the content of this tab when selected, and the color of the ripple.
unselectedContentColorthe color for the content of this tab when not selected
interactionSourcethe MutableInteractionSource representing the stream of Interactions for this tab. You can create and pass in your own remembered instance to observe Interactions and customize the appearance / behavior of this tab in different states. @see Ta