[ Web Proxy ]
URL:
Viewing: https://developer.android.com/develop/ui/compose/components/tooltip [Back]  [Original]

Tooltip  |  Jetpack Compose  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]

Tooltip Stay organized with collections Save and categorize content based on your preferences.

Use tooltips to add context to a button or other UI element. There are two types of tooltips:

Single line plain tooltip labeled (1), and a multi-line rich tooltip with a title and information block labeled (2). [Single line plain tooltip labeled (1), and a multi-line rich tooltip with a title and information block labeled (2).] Figure 1. A plain tooltip (1) and a rich tooltip (2).

API surface

You can use the TooltipBox composable to implement tooltips in your app. You control TooltipBox appearance with these main parameters:

Display a plain tooltip

Use a plain tooltip to briefly describe a UI element. This code snippet displays a plain tooltip on top of an icon button, labeled "Add to favorites":

@Composable
fun PlainTooltipExample(
    modifier: Modifier = Modifier,
    plainTooltipText: String = "Add to favorites"
) {
    TooltipBox(
        modifier = modifier,
        positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
        tooltip = {
            PlainTooltip { Text(plainTooltipText) }
        },
        state = rememberTooltipState()
    ) {
        IconButton(onClick = { /* Do something... */ }) {
            Icon(
                imageVector = Icons.Filled.Favorite,
                contentDescription = "Add to favorites"
            )
        }
    }
}

Key points about the code

Result

This example produces a plain tooltip on top of an icon:

Single-line tooltip containing the text 'Add to favorites' displayed above a heart icon. The tooltip appears on hover or long-press. [Single-line tooltip containing the text 'Add to favorites' displayed above a heart icon. The tooltip appears on hover or long-press.] Figure 2. A plain tooltip that appears when a user hovers over or long-presses the heart icon.

Display a rich tooltip

Use a rich tooltip to provide additional context about a UI element. This example creates a multi-line rich tooltip with a title that is anchored to an Icon:

@Composable
fun RichTooltipExample(
    modifier: Modifier = Modifier,
    richTooltipSubheadText: String = "Rich Tooltip",
    richTooltipText: String = "Rich tooltips support multiple lines of informational text."
) {
    TooltipBox(
        modifier = modifier,
        positionProvider = TooltipDefaults.rememberRichTooltipPositionProvider(),
        tooltip = {
            RichTooltip(
                title = { Text(richTooltipSubheadText) }
            ) {
                Text(richTooltipText)
            }
        },
        state = rememberTooltipState()
    ) {
        IconButton(onClick = { /* Icon button's click event */ }) {
            Icon(
                imageVector = Icons.Filled.Info,
                contentDescription = "Show more information"
            )
        }
    }
}

Key points about the code

Result

This example produces a rich tooltip with a title attached to an information icon:

A multiple-line tooltip with the title 'Rich Tooltip' and a line of text above an information icon. [A multiple-line tooltip with the title 'Rich Tooltip' and a line of text above an information icon.] Figure 3. A rich tooltip with a title and an information icon.

Customize a rich tooltip

This code snippet displays a rich tooltip with a title, custom actions, and a custom caret (arrow) displayed on top of a camera icon button:

@Composable
fun AdvancedRichTooltipExample(
    modifier: Modifier = Modifier,
    richTooltipSubheadText: String = "Custom Rich Tooltip",
    richTooltipText: String = "Rich tooltips support multiple lines of informational text.",
    richTooltipActionText: String = "Dismiss"
) {
    val tooltipState = rememberTooltipState()
    val coroutineScope = rememberCoroutineScope()

    TooltipBox(
        modifier = modifier,
        positionProvider = TooltipDefaults.rememberRichTooltipPositionProvider(),
        tooltip = {
            RichTooltip(
                title = { Text(richTooltipSubheadText) },
                action = {
                    Row {
                        TextButton(onClick = {
                            coroutineScope.launch {
                                tooltipState.dismiss()
                            }
                        }) {
                            Text(richTooltipActionText)
                        }
                    }
                },
            ) {
                Text(richTooltipText)
            }
        },
        state = tooltipState
    ) {
        IconButton(onClick = {
            coroutineScope.launch {
                tooltipState.show()
            }
        }) {
            Icon(
                imageVector = Icons.Filled.Camera,
                contentDescription = "Open camera"
            )
        }
    }
}

Key points about the code

Result

This example produces the following:

Multi-line tooltip with the title 'Custom Rich Tooltip' and a dismiss button. The tooltip is anchored to a camera icon. [Multi-line tooltip with the title 'Custom Rich Tooltip' and a dismiss button. The tooltip is anchored to a camera icon.] Figure 4. A custom rich tooltip with a dismiss action anchored to a camera icon.

Additional resources

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-14 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page