Skip to content

Tooltip

Tooltips appear on hover and provide brief contextual information about a UI element. MorphUI provides two ready-to-use tooltip variants.

Variants

Class Description
MorphSimpleTooltip Single plain text label
MorphRichTooltip Bold heading + supporting detail text

Usage

Attach a tooltip via the tooltip keyword on any widget that uses MorphTooltipBehavior (all standard MorphUI buttons and labels):

from morphui.uix.button import MorphIconButton
from morphui.uix.tooltip import MorphSimpleTooltip, MorphRichTooltip

# Simple
btn = MorphIconButton(
    icon='information',
    tooltip=MorphSimpleTooltip(text="Show details"),
)

# Rich
btn = MorphIconButton(
    icon='settings',
    tooltip=MorphRichTooltip(
        heading="Settings",
        supporting="Open application settings",
    ),
)

morphui.uix.tooltip

Tooltip widgets for MorphUI.

Tooltips appear on hover and provide brief contextual information about a UI element. Attach a tooltip to any widget that uses MorphTooltipBehavior via its tooltip property.

CLASS DESCRIPTION
MorphTooltip

Base tooltip container — extend this to build custom tooltips.

MorphSimpleTooltip

Ready-to-use tooltip with a single plain-text label.

MorphRichTooltip

Tooltip with a bold heading and a supporting detail line.

MorphTooltip(*widgets, **kwargs)

Bases: MorphDeclarativeBehavior, MorphMenuMotionBehavior, MorphColorThemeBehavior, MorphSurfaceLayerBehavior, MorphElevationBehavior, MorphAutoSizingBehavior, BoxLayout

A tooltip widget that provides brief information about a UI element when hovered over.

This widget combines the motion behavior for menu-like positioning with elevation styling to create a visually distinct tooltip.

Example
from morphui.app import MorphApp
from morphui.uix.label import MorphSimpleLabel
from morphui.uix.button import MorphIconButton
from morphui.uix.tooltip import MorphTooltip
from morphui.uix.floatlayout import MorphFloatLayout

class MyApp(MorphApp):

    def build(self) -> MorphFloatLayout:
        self.theme_manager.theme_mode = 'Dark'
        self.theme_manager.seed_color = 'morphui_teal'

        layout = MorphFloatLayout(
            MorphIconButton(
                tooltip=MorphTooltip(
                    MorphSimpleLabel(
                        text="This is helpful information!",
                        auto_size=True),),
                icon='information',
                pos_hint={'center_x': 0.5, 'center_y': 0.5}),
            theme_color_bindings={
                'normal_surface_color': 'surface_color',},)
        return layout

if __name__ == '__main__':
    MyApp().run()

default_config = dict(theme_color_bindings=(dict(normal_surface_color='surface_container_highest_color')), menu_caller_spacing=(dp(8)), orientation='vertical', padding=[dp(8), dp(4)], radius=(dp(4)), spacing=(dp(5)), elevation=2, scale_enabled=False, auto_size=(True, True)) class-attribute instance-attribute

Default configuration for MorphTooltip.

update_tooltip_text(text)

Update the primary text of the tooltip.

Override in subclasses to map text to the appropriate child label. The default implementation is a no-op so that plain :class:MorphTooltip instances (with arbitrary child widgets) are unaffected.

PARAMETER DESCRIPTION
text

The new text to display.

TYPE: str

MorphSimpleTooltip(tooltip_text, **kwargs)

Bases: MorphTooltip

A tooltip that displays a single line of text.

This is the simplest tooltip variant: it wraps a :class:~morphui.uix.label.MorphSimpleLabel inside a :class:MorphTooltip. Use it when you only need a short text hint. For richer content (icons, multi-line, etc.) subclass :class:MorphTooltip directly.

PARAMETER DESCRIPTION
tooltip_text

The text to display inside the tooltip.

TYPE: str

**kwargs

Additional keyword arguments forwarded to :class:MorphTooltip.

TYPE: Any DEFAULT: {}

Example
from morphui.uix.button import MorphIconButton
from morphui.uix.tooltip import MorphSimpleTooltip

btn = MorphIconButton(
    tooltip=MorphSimpleTooltip(
        'This is helpful information!',
        menu_anchor_position='right'),
    icon='information')

update_tooltip_text(text)

Update the label text.

MorphRichTooltip(heading='', supporting='', **kwargs)

Bases: MorphTooltip

A tooltip with a bold heading and an optional supporting line.

Composes a :class:MorphTooltipHeadingLabel and, when supporting is provided, a :class:MorphTooltipLabel below it. Both texts are exposed as :class:~kivy.properties.StringProperty so they can be updated after construction.

PARAMETER DESCRIPTION
heading

The bold heading text displayed at the top of the tooltip.

TYPE: str DEFAULT: ''

supporting

Optional secondary text displayed below the heading. Pass an empty string (default) to show only the heading.

TYPE: str DEFAULT: ''

**kwargs

Additional keyword arguments forwarded to :class:MorphTooltip.

TYPE: Any DEFAULT: {}

Example
from morphui.uix.button import MorphIconButton
from morphui.uix.tooltip import MorphRichTooltip

btn = MorphIconButton(
    tooltip=MorphRichTooltip(
        heading='Unsaved changes',
        supporting='Your edits will be lost.',
        menu_anchor_position='right'),
    icon='warning')

heading = heading class-attribute instance-attribute

The bold heading text displayed at the top of the tooltip.

supporting = supporting class-attribute instance-attribute

Optional secondary text displayed below the heading.

update_tooltip_text(text)

Update the supporting text.

Maps text to :attr:supporting, which is the contextual detail line below the fixed heading.