androidx.compose.material3
TooltipBox
Composable function
A tooltip explains an element, usually an icon button. It shows on hover with a mouse, or on long press on touch screens.
Wrap the element in a TooltipBox, and put a PlainTooltip or RichTooltip in its tooltip slot.

Box(Modifier.size(200.dp, 120.dp), contentAlignment = Alignment.BottomCenter) {
TooltipBox(
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(TooltipAnchorPosition.Above),
tooltip = { PlainTooltip { Text("Add to favorites") } },
// Visible right away only for this picture. Normally: rememberTooltipState()
state = rememberTooltipState(initialIsVisible = true, isPersistent = true),
) {
IconButton(onClick = {}) { Icon(Icons.Filled.Favorite, "Favorite") }
}
}
A rich tooltip has a title, more text and an action. Use it to explain a feature.

Box(Modifier.size(320.dp, 240.dp), contentAlignment = Alignment.BottomCenter) {
TooltipBox(
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(TooltipAnchorPosition.Above),
tooltip = {
RichTooltip(
title = { Text("Smart search") },
action = { TextButton(onClick = {}) { Text("Learn more") } },
) {
Text("Search finds text inside your photos too.")
}
},
state = rememberTooltipState(initialIsVisible = true, isPersistent = true),
) {
IconButton(onClick = {}) { Icon(Icons.Filled.Info, "About search") }
}
}
Parameters
@Composable
fun TooltipBox(
positionProvider: PopupPositionProvider,
tooltip: @Composable TooltipScope.() -> Unit,
state: TooltipState,
modifier: Modifier = Modifier,
onDismissRequest: (() -> Unit)? = null,
focusable: Boolean = false,
enableUserInput: Boolean = true,
hasAction: Boolean = false,
content: @Composable () -> Unit,
)
positionProvider: PopupPositionProviderRequired
positionProvider: PopupPositionProviderRequiredWhere the tooltip shows. Use TooltipDefaults.rememberTooltipPositionProvider(TooltipAnchorPosition.Above).
tooltip: @Composable TooltipScope.() -> UnitRequired
tooltip: @Composable TooltipScope.() -> UnitRequiredThe tooltip. A PlainTooltip or a RichTooltip.
state: TooltipStateRequired
state: TooltipStateRequiredWhether the tooltip is visible. Create it with rememberTooltipState().
Set isPersistent = true for rich tooltips with an action, so they stay until dismissed.
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
onDismissRequest: (() -> Unit)?OptionalSince 1.9
onDismissRequest: (() -> Unit)?OptionalSince 1.9Default: null
Called when the user taps outside a visible tooltip.
focusable: BooleanOptional
focusable: BooleanOptionalDefault: false
Set to true if the tooltip has buttons the user should reach with the keyboard.
enableUserInput: BooleanOptional
enableUserInput: BooleanOptionalDefault: true
Set to false to show the tooltip only from code, not on hover or long press.
hasAction: BooleanOptionalSince 1.9
hasAction: BooleanOptionalSince 1.9Default: false
Set to true when the tooltip has an action. It then stays visible longer.
content: @Composable () -> UnitRequired
content: @Composable () -> UnitRequiredThe element the tooltip explains. Usually an IconButton.
Parts
TooltipBoxPlainTooltipRichTooltip