After updating to Compose BOM 2024.02.01, which implements Material 3 v2.0, I realized that I can't use PlainTooltipBox
anymore. Instead, I see TooltipBox
and BasicTooltipBox
(which is implemented by TooltipBox
).
For both I need to set a PopupPositionProvider
parameter, but I can't find an example anywhere of how to get and use this.
Can you please explain how to implement the new ToolTip?
The old one was so easy to use 😢, but I know these are Experimental APIs and subject to changes.
Thank you!
The PopupPositionProvider
is just a simple interface with a single function that defines where the tooltip should be positioned. You can implement that yourself or you can use the default implementation TooltipDefaults.rememberPlainTooltipPositionProvider()
:
TooltipBox(
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
tooltip = {
PlainTooltip {
Text(/* tooltip content */)
}
},
state = rememberTooltipState(),
) {
// tooltip anchor
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With