ComposeTooltip
Tooltip library for Jetpack Compose
Install / Use
/learn @skgmn/ComposeTooltipREADME

Setup
implementation "com.github.skgmn:composetooltip:0.2.0"
Tooltip method
Tooltip can be either used inside ConstraintLayout or displayed as a popup.
ConstraintLayout
Basic example
ConstraintLayout {
val someImage = createRef()
Image(
painter = painterResource(R.drawable.some_image),
contentDescription = "Some image"
modifier = Modifier.constrainAs(someImage) {
// Place it where you want
}
)
Tooltip(
anchor = someImage,
anchorEdge = AnchorEdge.Top,
) {
Text("This is my image!")
}
}
Method signatures
fun ConstraintLayoutScope.Tooltip(
anchor: ConstrainedLayoutReference,
anchorEdge: AnchorEdge,
modifier: Modifier = Modifier,
tooltipStyle: TooltipStyle = rememberTooltipStyle(),
tipPosition: EdgePosition = remember { EdgePosition() },
anchorPosition: EdgePosition = remember { EdgePosition() },
margin: Dp = 8.dp,
content: @Composable RowScope.() -> Unit
)
anchor-ConstrainedLayoutReferenceto locate this tooltip nearbyanchorEdge- Can be either ofAnchorEdge.Start,AnchorEdge.Top,AnchorEdge.End, orAnchorEdge.BottomtooltipStyle- Style for tooltip. Can be created byrememberTooltipStyletipPosition- Tip position relative to balloonanchorPosition- Position on theanchor's edge where the tip points out.margin- Margin between tip andanchorcontent- Content inside balloon. TypicallyText.
Tooltip also supports enter/exit transition using AnimatedVisibility. Because AnimatedVisibility is experimental, this method is also experimental.
fun ConstraintLayoutScope.Tooltip(
anchor: ConstrainedLayoutReference,
anchorEdge: AnchorEdge,
enterTransition: EnterTransition,
exitTransition: ExitTransition,
modifier: Modifier = Modifier,
visible: Boolean = true,
tooltipStyle: TooltipStyle = rememberTooltipStyle(),
tipPosition: EdgePosition = remember { EdgePosition() },
anchorPosition: EdgePosition = remember { EdgePosition() },
margin: Dp = 8.dp,
content: @Composable RowScope.() -> Unit
)
enterTransition-EnterTransitionto be applied when thevisiblebecomes true. Types ofEnterTransitionare listed here.exitTransition-ExitTransitionto be applied when thevisiblebecomes false. Types ofExitTransitionare listed here.
Popup
Box {
// Some other composables here
// This Box is a conatiner for anchoring
Box {
Image(
painter = painterResource(R.drawable.some_image),
contentDescription = "Some image"
)
Tooltip(
anchorEdge = AnchorEdge.Top,
) {
Text("This is my image!")
}
}
}
When Tooltip is being displayed as a popup, an anchor and Tooltip should be put altogether inside one composable.
Method signatures
fun Tooltip(
anchorEdge: AnchorEdge,
modifier: Modifier = Modifier,
tooltipStyle: TooltipStyle = rememberTooltipStyle(),
tipPosition: EdgePosition = remember { EdgePosition() },
anchorPosition: EdgePosition = remember { EdgePosition() },
margin: Dp = 8.dp,
onDismissRequest: (() -> Unit)? = null,
properties: PopupProperties = remember { PopupProperties() },
content: @Composable RowScope.() -> Unit
)
onDismissRequest- Executes when the user clicks outside of the tooltip.properties-PopupPropertiesfor further customization of this tooltip's behavior.
Other parameteres are same as for ConstraintLayout.
There is also an another version of supporting transition.
Related Skills
node-connect
341.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
