Tooltip

Tooltips display informative text when users hover over, focus on, or tap an element.

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tooltip.png

To use the MDTooltip class, you must create a new class inherited from the MDTooltip class:

In Kv-language:

<TooltipMDIconButton@MDIconButton+MDTooltip>

In Python code:

class TooltipMDIconButton(MDIconButton, MDTooltip):
    pass

Warning

MDTooltip only works correctly with button classes.

from kivy.lang import Builder

from kivymd.app import MDApp

KV = '''
<TooltipMDIconButton@MDIconButton+MDTooltip>


Screen:

    TooltipMDIconButton:
        icon: "language-python"
        tooltip_text: self.icon
        pos_hint: {"center_x": .5, "center_y": .5}
'''


class Test(MDApp):
    def build(self):
        return Builder.load_string(KV)


Test().run()
https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tooltip.gif

Note

The behavior of tooltips on desktop and mobile devices is different. For more detailed information, click here.

API - kivymd.uix.tooltip

class kivymd.uix.tooltip.MDTooltip(**kwargs)
Events

on_enter

Fired when mouse enter the bbox of the widget.

on_leave

Fired when the mouse exit the widget.

tooltip_bg_color

Tooltip background color in rgba format.

tooltip_bg_color is an ListProperty and defaults to [].

tooltip_text_color

Tooltip text color in rgba format.

tooltip_text_color is an ListProperty and defaults to [].

tooltip_text

Tooltip text.

tooltip_text is an StringProperty and defaults to ‘’.

delete_clock(self, widget, touch, *args)
adjust_tooltip_position(self, x, y)

Returns the coordinates of the tooltip that fit into the borders of the screen.

display_tooltip(self, interval)
animation_tooltip_show(self, interval)
remove_tooltip(self, *args)
on_long_touch(self, touch, *args)

Called when the widget is pressed for a long time.

on_enter(self, *args)

See on_enter method in HoverBehavior class.

on_leave(self)

See on_leave method in HoverBehavior class.

class kivymd.uix.tooltip.MDTooltipViewClass(**kwargs)

Box layout class. See module documentation for more information.

tooltip_bg_color

See tooltip_bg_color.

tooltip_text_color

See tooltip_text_color.

tooltip_text

See tooltip_text.