androidx.compose.foundation

BasicTooltipBoxExperimental

Composable function · from org.jetbrains.compose.foundation:foundation:1.12.2

BasicTooltipBox shows a popup next to its content, when the user hovers it, long-presses it, or when you show it from code. It has no look of its own: you draw the tooltip yourself.

Use the Material TooltipBox with PlainTooltip or RichTooltip in Material apps. They use this inside and add the shape, colors and position.

It is experimental: add @OptIn(ExperimentalFoundationApi::class).

Read more

ParametersExperimental

@Composable
fun BasicTooltipBox(
    positionProvider: PopupPositionProvider,
    tooltip: @Composable () -> Unit,
    state: BasicTooltipState,
    modifier: Modifier = Modifier,
    focusable: Boolean = true,
    enableUserInput: Boolean = true,
    propagateMinConstraints: Boolean = false,
    content: @Composable () -> Unit,
)

positionProvider: PopupPositionProviderRequired

Where the tooltip goes, relative to the content.

tooltip: @Composable () -> UnitRequired

What the tooltip shows. Give it a background; it has none.

state: BasicTooltipStateRequired

Whether the tooltip is visible. Create it with rememberBasicTooltipState(); call show() and dismiss() from a coroutine.

modifier: ModifierOptional

Default: Modifier

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

focusable: BooleanOptional

Default: true

Whether the tooltip takes focus when it opens. Set to true if it has buttons.

enableUserInput: BooleanOptional

Default: true

Set to false to stop hover and long-press from opening it. Then only your code opens it.

propagateMinConstraints: BooleanOptionalSince 1.11

Default: false

Set to true to pass the minimum size of the box on to the content.

content: @Composable () -> UnitRequired

The element the tooltip belongs to, like an icon button.