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 and label 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

Called when mouse enters the bbox of the widget AND the widget is visible

on_leave

Called when the mouse exits the widget AND the widget is visible

tooltip_bg_color

Tooltip background color in rgba format.

tooltip_bg_color is an ColorProperty and defaults to None.

tooltip_text_color

Tooltip text color in rgba format.

tooltip_text_color is an ColorProperty and defaults to None.

tooltip_text

Tooltip text.

tooltip_text is an StringProperty and defaults to ‘’.

tooltip_font_style

Tooltip font style. Available options are: ‘H1’, ‘H2’, ‘H3’, ‘H4’, ‘H5’, ‘H6’, ‘Subtitle1’, ‘Subtitle2’, ‘Body1’, ‘Body2’, ‘Button’, ‘Caption’, ‘Overline’, ‘Icon’.

tooltip_font_style is an OptionProperty and defaults to ‘Caption’.

tooltip_radius

Corner radius values.

radius is an ListProperty and defaults to [dp(7),].

tooltip_display_delay

Tooltip dsiplay delay.

tooltip_display_delay is an BoundedNumericProperty and defaults to 0, min of 0 & max of 4. This property only works on desktop.

shift_y

Y-offset of tooltip text.

shift_y is an StringProperty and defaults to 0.

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.

on_show(self)
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.

tooltip_font_style

See tooltip_font_style.

tooltip_radius

See tooltip_radius.