androidx.compose.material3

LabelExperimental

Composable function

One of the helpers on this page. It works like ProvideTextStyle. Only the parameters that differ are described here.

Shows a short label above its content on hover or long press. Lighter than a tooltip.

A label that is always shownExpressive theme
A label that is always shown
Box(Modifier.size(160.dp, 100.dp), contentAlignment = Alignment.BottomCenter) {
    Label(
        label = { PlainTooltip { Text("Favorite") } },
        // Always shown. Without it, the label shows on hover or long press.
        isPersistent = true,
    ) {
        Icon(Icons.Filled.Favorite, contentDescription = "Favorite")
    }
}

ParametersExperimental

@Composable
fun Label(
    label: @Composable TooltipScope.() -> Unit,
    modifier: Modifier = Modifier,
    interactionSource: MutableInteractionSource? = null,
    isPersistent: Boolean = false,
    content: @Composable () -> Unit,
)

label: @Composable TooltipScope.() -> UnitRequired

The text of the label, shown on hover or long press.

modifier: ModifierOptional

Default: Modifier

Changes size, padding, or position. See the Modifier guide.

interactionSource: MutableInteractionSource?Optional

Default: null

Lets you observe or control press, hover and focus states. Leave it null unless your code must react to them. See InteractionSource.

isPersistent: BooleanOptional

Default: false

Set to true to always show the label, not only on hover or long press.

Same as in ProvideTextStyle: content.

Helpers on this page