ToggleButton — K"vyMD 2.0.1.
dev0 documentat"on 19/10/2025 13:14
ToggleButton
Contents
API - kivymd.uix.behaviors.toggle_behavior
This behavior must always be inherited after the
button’s Widget class since it works with the
inherited properties of the button class.
example:
class MyToggleButtonWidget(MDButton, MDToggleButton):
# [...]
pass
Declarative KV style
Declarative python style
https://k"vymd.readthedocs."o/en/latest/behav"ors/togglebutton/ Sayfa 1 / 5
ToggleButton — K"vyMD 2.0.1.dev0 documentat"on 19/10/2025 13:14
from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.behaviors.toggle_behavior import MDToggleButton
from kivymd.uix.button import MDButton
KV = '''
MDScreen:
MDBoxLayout:
adaptive_size: True
spacing: "12dp"
pos_hint: {"center_x": .5, "center_y": .5}
MyToggleButton:
group: "x"
MDButtonText:
text: "Show ads"
MyToggleButton:
group: "x"
MDButtonText:
text: "Do not show ads"
MyToggleButton:
group: "x"
MDButtonIcon:
icon: "pencil"
MDButtonText:
text: "Does not matter"
'''
class MyToggleButton(MDButton, MDToggleButton):
...
class Test(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "Orange"
return Builder.load_string(KV)
Test().run()
https://k"vymd.readthedocs."o/en/latest/behav"ors/togglebutton/ Sayfa 2 / 5
ToggleButton — K"vyMD 2.0.1.dev0 documentat"on 19/10/2025 13:14
You can inherit the
MyToggleButton class only
from the following classes
MDRaisedButton
MDFlatButton
MDRectangleFlatButton
MDRectangleFlatIconButton
MDRoundFlatButton
MDRoundFlatIconButton
MDFillRoundFlatButton
MDFillRoundFlatIconButton
API -
kivymd.uix.behaviors.toggle_behavior
class
kivymd.uix.behaviors.toggle_behavior.MDToggleButtonBehavior(*args,
**kwargs)
This mixin class provides togglebutton
behavior. Please see the togglebutton
behaviors module documentation for more
information.
Added in version 1.8.0.
background_normal
Color of the button in rgba format for
https://k"vymd.readthedocs."o/en/latest/behav"ors/togglebutton/ Sayfa 3 / 5
ToggleButton — K"vyMD 2.0.1.dev0 documentat"on 19/10/2025 13:14
the ‘normal’ state.
background_normal is a
ColorProperty and is defaults to
None.
background_down
Color of the button in rgba format for
the ‘down’ state.
background_down is a ColorProperty
and is defaults to None.
font_color_normal
Color of the font’s button in rgba
format for the ‘normal’ state.
font_color_normal is a
ColorProperty and is defaults to
None.
font_color_down
Color of the font’s button in rgba
format for the ‘down’ state.
font_color_down is a ColorProperty
and is defaults to None.
set_properties(*args)
latest
PyConFR — 30 octobre — 2 novembre — Lyon
Ads by EthicalAds
https://k"vymd.readthedocs."o/en/latest/behav"ors/togglebutton/ Sayfa 4 / 5
ToggleButton — K"vyMD 2.0.1.dev0 documentat"on 19/10/2025 13:14
https://k"vymd.readthedocs."o/en/latest/behav"ors/togglebutton/ Sayfa 5 / 5