API reference

Tooltip Composable

Shows a tooltip positioned against the content tracked by anchor.
Create anchor with UiSetAnchor.Companion.rememberAnchor and attach it to arbitrary content with Modifier.anchor(anchor). This call can be emitted elsewhere in the composition because popup positioning follows the tracked window-space bounds rather than its layout call site.
The tooltip is shown for as long as this composable is in the composition, so the caller owns the trigger: wrap the call in a condition driven by hover, focus, long press, or an explicit request. Nothing is drawn until anchor has been positioned.
placement and dimensions' popup gap configure the tooltip position relative to the tracked anchor bounds.

Signature

@Composable
fun Tooltip(
    title: String,
    anchor: UiSetAnchor,
    modifier: Modifier = Modifier,
    subtitle: String? = null,
    icon: @Composable () -> Unit? = null,
    placement: TooltipPlacement = TooltipPlacement.Above,
    colors: TooltipColors = TooltipDefaults.Colors,
    dimensions: TooltipDimensions = UiSetTheme.dimensions.tooltips,
    shape: Shape = UiSetTheme.shapes.tooltip,
    titleTextStyle: TextStyle = UiSetTheme.typography.body,
    subtitleTextStyle: TextStyle = UiSetTheme.typography.bodySmall,
    titleMaxLines: Int = 2,
    subtitleMaxLines: Int = 3,
)

Parameters

title: String primary tooltip text
anchor: UiSetAnchor tracked bounds of the content described by this tooltip
modifier: Modifier modifier applied to the tooltip bubble inside the popup; the popup itself has no layout node that can receive a modifier
subtitle: String? optional supporting tooltip text
icon: (@Composable () -> Unit)? optional icon inside the tooltip bubble
placement: TooltipPlacement preferred side of the anchor; the popup flips when that side does not fit
colors: TooltipColors bubble, text, icon, and outline colors
dimensions: TooltipDimensions bubble padding, icon, width, gap, and elevation geometry
shape: Shape tooltip bubble shape
titleTextStyle: TextStyle primary text typography
subtitleTextStyle: TextStyle supporting text typography
titleMaxLines: Int maximum visible title lines before ellipsizing
subtitleMaxLines: Int maximum visible subtitle lines before ellipsizing