iOS Dropdown#

#

Added in version 2.0.1.

Provides liquid metaball morphing and glassmorphic dropdown behavior inspired by iOS visual effects.

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/dropdown-behavior-preview.jpeg
  • Streamlines single tasks or options, keeping the user in flow;

  • Supports basic pop-ups and expanded full-size menus;

  • Blends and splits elements with dynamic GLSL shader animations;

  • Rendered as frosted glass with refraction, blur, and smooth corners;

  • Displays relevant info for quick changes or confirmations;

Anatomy#

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/dropdown-behavior-anatomy.png

Example#

from kivy.lang import Builder

from kivymd.app import MDApp

KV = '''
MDScreen:

    FitImage:
        id: bg_image
        source: "https://picsum.photos/800/600?random=1"

    IOSLiquidDropdownContainer:
        id: dropdown_container
        caller: trigger_btn
        menu: menu_btn

        IOSButton:
            id: trigger_btn
            size_hint: None, None
            size: dp(56), dp(56)
            border_radius: [dp(28)] * 4
            target_background: bg_image
            pos_hint: {"center_x": 0.5, "center_y": 0.65}
            on_release: dropdown_container.toggle_dropdown()

            IOSIconButton:
                icon: "filter-variant"
                theme_icon_color: "Custom"
                icon_color: "white"

        IOSButton:
            id: menu_btn
            adaptive_size: True
            target_background: bg_image
            border_radius: [dp(22)] * 4
            on_release: dropdown_container.toggle_dropdown()

            IOSButtonText:
                text: "IOS Button"
                theme_text_color: "Custom"
                text_color: "white"
'''


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


if __name__ == "__main__":
    LiquidGlassDropdownDemo().run()
https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/dropdown-behavior-example.gif

API - kivymd.uix.behaviors.ios.dropdown_behavior#

class kivymd.uix.behaviors.ios.dropdown_behavior.IOSLiquidDropdownBehavior(*args, **kwargs)#

Behavior class responsible for orchestrating the liquid metaball transition, shader uniform synchronization, and wobble dynamics between a trigger button and a dropdown menu.

For more information see in the IOSBaseGlassBehavior class documentation.

direction#

Direction in which the dropdown menu expands relative to the caller button.

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/dropdown-behavior-direction.png

Available options: ‘bottom’, ‘top’, ‘left’, ‘right’, ‘bottom-left’, ‘bottom-right’, ‘top-left’, ‘top-right’.

direction is an OptionProperty and defaults to ‘bottom’.

spacing#

Gap between the trigger button and the dropdown menu.

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/dropdown-behavior-spacing.png

spacing is a NumericProperty and defaults to dp(12).

open_transition#

Easing curve transition type for the expansion animation.

open_transition is a StringProperty and defaults to ‘out_cubic’.

open_duration#

Total time in seconds required to fully expand the dropdown menu.

open_duration is a NumericProperty and defaults to 0.6.

close_transition#

Easing curve transition type for the collapse animation.

close_transition is a StringProperty and defaults to ‘in_out_cubic’.

close_duration#

Total time in seconds required to collapse back into the trigger button.

close_duration is a NumericProperty and defaults to 0.45.

viscosity#

Maximum smooth-minimum blending factor (k) controlling the liquid neck stretch.

viscosity is a NumericProperty and defaults to dp(100).

is_open#

State flag indicating whether the dropdown menu is currently open.

is_open is a BooleanProperty and defaults to False.

btn_fade_out_transition#

Easing curve transition for hiding trigger button on open.

btn_fade_out_transition is a StringProperty and defaults to ‘out_quad’.

btn_fade_in_transition#

Easing curve transition for restoring trigger button on close.

btn_fade_in_transition is a StringProperty and defaults to ‘in_quad’.

menu_fade_in_transition#

Easing curve transition for revealing dropdown menu content on open completion.

menu_fade_in_transition is a StringProperty and defaults to ‘out_quad’.

menu_fade_out_transition#

Easing curve transition for hiding dropdown menu content on close.

menu_fade_out_transition is a StringProperty and defaults to ‘out_quad’.

k_ramp_up_transition#

Easing curve transition for increasing viscosity (k).

k_ramp_up_transition is a StringProperty and defaults to ‘out_quad’.

k_ramp_down_transition#

Easing curve transition for collapsing viscosity (k).

k_ramp_down_transition is a StringProperty and defaults to ‘in_cubic’.

on_open(*args) → None#

Default event handler fired when expansion animation finishes.

on_close(*args) → None#

Default event handler fired when collapse animation finishes.

on_parent(instance, parent)#

Cleanup when removing a widget from the layout.

on_touch_down(touch)#
on_touch_move(touch)#
on_touch_up(touch)#
update_menu_position(*args) → None#

Dynamically repositions the dropdown menu relative to the trigger button based on direction and properties.

toggle_dropdown() → None#

Toggle between open and close states.

open() → None#

Triggers liquid expansion sequence: stretches metaball neck, triggers pinch-off wobble impulse, and reveals content upon completion.

close() → None#

Triggers liquid collapse sequence: hides menu UI immediately, pulls liquid body back into trigger button, and restores original UI state.

class kivymd.uix.behaviors.ios.dropdown_behavior.IOSLiquidDropdownContainer(*args, **kwargs)#

Container handling liquid drop transition logic.

For more information see in the DeclarativeBehavior and IOSLiquidDropdownBehavior and FloatLayout and MDAdaptiveWidget class documentation.

caller#

A widget trigger (button) that initiates the droplet animation.

caller is a ObjectProperty and defaults to None.

menu#

Drop-down menu.

menu is a ObjectProperty and defaults to None.

on_touch_down(touch)#

Receive a touch down event.

Parameters:
touch: MotionEvent class

Touch received. The touch is in parent coordinates. See relativelayout for a discussion on coordinate systems.

Returns:

bool If True, the dispatching of the touch event will stop. If False, the event will continue to be dispatched to the rest of the widget tree.