Kivymd PDF
Kivymd PDF
Kivymd PDF
Release 0.104.2.dev0
1 KivyMD 1
2 Contents 3
2.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4 Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
2.5 Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
2.6 About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
2.7 KivyMD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Index 299
i
ii
CHAPTER
ONE
KIVYMD
Is a collection of Material Design compliant widgets for use with, Kivy cross-platform graphical framework a frame-
work for cross-platform, touch-enabled graphical applications. The project’s goal is to approximate Google’s Material
Design spec as close as possible without sacrificing ease of use or application performance.
This library is a fork of the KivyMD project the author of which stopped supporting this project three years ago. We
found the strength and brought this project to a new level. Currently we’re in beta status, so things are changing all
the time and we cannot promise any kind of API stability. However it is safe to vendor now and make use of what’s
currently available.
Join the project! Just fork the project, branch out and submit a pull request when your patch is ready. If any changes
are necessary, we’ll guide you through the steps that need to be done via PR comments or access to your for may
be requested to outright submit them. If you wish to become a project developer (permission to create branches on
the project without forking for easier collaboration), have at least one PR approved and ask for it. If you contribute
regularly to the project the role may be offered to you without asking too.
1
KivyMD, Release 0.104.2.dev0
2 Chapter 1. KivyMD
CHAPTER
TWO
CONTENTS
In order to start using KivyMD, you must first install the Kivy framework on your computer. Once you have installed
Kivy, you can install KivyMD.
Warning: KivyMD depends on Kivy! Therefore, before using KivyMD, first learn how to work with Kivy.
2.1.1 Installation
_Speed Tip_: If you don’t need full commit history (about 320 MiB), you can use a shallow clone (git clone
https://github.com/kivymd/KivyMD.git –depth 1) to save time. If you need full commit history, then remove –depth 1.
class MainApp(MDApp):
def build(self):
return MDLabel(text="Hello, World", halign="center")
MainApp().run()
3
KivyMD, Release 0.104.2.dev0
class MainApp(App):
def build(self):
return Label(text="Hello, World")
MainApp().run()
At first glance, the KivyMD example contains more code. . . However, the following example already demonstrates
how difficult it is to create a custom button in Kivy:
KV = """
<RectangleFlatButton>:
ripple_color: 0, 0, 0, .2
background_color: 0, 0, 0, 0
color: root.primary_color
canvas.before:
Color:
rgba: root.primary_color
Line:
width: 1
rectangle: (self.x, self.y, self.width, self.height)
4 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class MainApp(App):
def build(self):
screen = Builder.load_string(KV)
screen.add_widget(
RectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
size_hint=(None, None),
size=(dp(110), dp(35)),
ripple_color=(0.8, 0.8, 0.8, 0.5),
)
)
return screen
MainApp().run()
class MainApp(MDApp):
def build(self):
screen = Screen()
screen.add_widget(
MDRectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
)
)
return screen
MainApp().run()
2.2 Themes
2.2.1 Theming
See also:
Material Design spec, Material theming
Material App
The main class of your application, which in Kivy inherits from the App class, in KivyMD must inherit from the MDApp
class. The MDApp class has properties that allow you to control application properties such as color/style/font
of interface elements and much more.
The main application class inherited from the MDApp class has the theme_cls attribute, with which you control the
material properties of your application.
6 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.theming
class kivymd.theming.ThemeManager(**kwargs)
primary_palette
The name of the color scheme that the application will use. All major material components will have the
color of the specified color theme.
Available options are: ‘Red’, ‘Pink’, ‘Purple’, ‘DeepPurple’, ‘Indigo’, ‘Blue’, ‘LightBlue’, ‘Cyan’, ‘Teal’,
‘Green’, ‘LightGreen’, ‘Lime’, ‘Yellow’, ‘Amber’, ‘Orange’, ‘DeepOrange’, ‘Brown’, ‘Gray’, ‘BlueGray’.
To change the color scheme of an application:
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Green" # "Purple", "Red"
screen = Screen()
screen.add_widget(
MDRectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
)
)
return screen
MainApp().run()
2.2. Themes 7
KivyMD, Release 0.104.2.dev0
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Green" # "Purple", "Red"
self.theme_cls.primary_hue = "200" # "500"
screen = Screen()
screen.add_widget(
MDRectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
)
)
return screen
MainApp().run()
8 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
KV = '''
Screen:
MDRaisedButton:
text: "primary_light"
pos_hint: {"center_x": 0.5, "center_y": 0.7}
md_bg_color: app.theme_cls.primary_light
MDRaisedButton:
text: "primary_color"
pos_hint: {"center_x": 0.5, "center_y": 0.5}
MDRaisedButton:
text: "primary_dark"
pos_hint: {"center_x": 0.5, "center_y": 0.3}
md_bg_color: app.theme_cls.primary_dark
'''
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Green"
return Builder.load_string(KV)
MainApp().run()
2.2. Themes 9
KivyMD, Release 0.104.2.dev0
primary_light is an AliasProperty that returns the value of the current application theme (in
lighter color), property is readonly.
primary_dark
Colors of the current application color theme in rgba format (in darker color).
primary_dark is an AliasProperty that returns the value of the current application theme (in
darker color), property is readonly.
accent_palette
The application color palette used for items such as the tab indicator in the MDTabsBar class and so on. . .
The image below shows the color schemes with the values self.theme_cls.accent_palette =
'Blue', Red' and Yellow':
10 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class MainApp(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark" # "Light"
screen = Screen()
screen.add_widget(
MDRectangleFlatButton(
text="Hello, World",
pos_hint={"center_x": 0.5, "center_y": 0.5},
)
)
return screen
MainApp().run()
KV = '''
<Box@BoxLayout>:
bg: 0, 0, 0, 0
canvas:
Color:
rgba: root.bg
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
Box:
bg: app.theme_cls.bg_light
Box:
(continues on next page)
2.2. Themes 11
KivyMD, Release 0.104.2.dev0
class MainApp(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark" # "Light"
return Builder.load_string(KV)
MainApp().run()
bg_darkest is an AliasProperty that returns the value in rgba format for bg_darkest, property
is readonly.
opposite_bg_darkest
The opposite value of color in the bg_darkest.
opposite_bg_darkest is an AliasProperty that returns the value in rgba format for
opposite_bg_darkest, property is readonly.
bg_dark
Similar to bg_normal, but the color values are one tone lower (darker) than bg_normal.
bg_dark is an AliasProperty that returns the value in rgba format for bg_dark, property is
readonly.
opposite_bg_dark
The opposite value of color in the bg_dark.
opposite_bg_dark is an AliasProperty that returns the value in rgba format for
opposite_bg_dark, property is readonly.
12 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
bg_normal
Similar to bg_light, but the color values are one tone lower (darker) than bg_light.
bg_normal is an AliasProperty that returns the value in rgba format for bg_normal, property
is readonly.
opposite_bg_normal
The opposite value of color in the bg_normal.
opposite_bg_normal is an AliasProperty that returns the value in rgba format for
opposite_bg_normal, property is readonly.
bg_light
” Depending on the style of the theme (‘Dark’ or ‘Light’) that the application uses, bg_light contains
the color value in rgba format for the widgets background.
bg_light is an AliasProperty that returns the value in rgba format for bg_light, property is
readonly.
opposite_bg_light
The opposite value of color in the bg_light.
opposite_bg_light is an AliasProperty that returns the value in rgba format for
opposite_bg_light, property is readonly.
divider_color
Color for dividing lines such as MDSeparator.
divider_color is an AliasProperty that returns the value in rgba format for divider_color,
property is readonly.
opposite_divider_color
The opposite value of color in the divider_color.
opposite_divider_color is an AliasProperty that returns the value in rgba format for
opposite_divider_color, property is readonly.
text_color
Color of the text used in the MDLabel.
text_color is an AliasProperty that returns the value in rgba format for text_color, property
is readonly.
opposite_text_color
The opposite value of color in the text_color.
opposite_text_color is an AliasProperty that returns the value in rgba format for
opposite_text_color, property is readonly.
secondary_text_color
The color for the secondary text that is used in classes from the module TwoLineListItem.
secondary_text_color is an AliasProperty that returns the value in rgba format for
secondary_text_color, property is readonly.
opposite_secondary_text_color
The opposite value of color in the secondary_text_color.
opposite_secondary_text_color is an AliasProperty that returns the value in rgba format
for opposite_secondary_text_color, property is readonly.
icon_color
Color of the icon used in the MDIconButton.
2.2. Themes 13
KivyMD, Release 0.104.2.dev0
icon_color is an AliasProperty that returns the value in rgba format for icon_color, property
is readonly.
opposite_icon_color
The opposite value of color in the icon_color.
opposite_icon_color is an AliasProperty that returns the value in rgba format for
opposite_icon_color, property is readonly.
disabled_hint_text_color
Color of the disabled text used in the MDTextField.
disabled_hint_text_color is an AliasProperty that returns the value in rgba format for
disabled_hint_text_color, property is readonly.
opposite_disabled_hint_text_color
The opposite value of color in the disabled_hint_text_color.
opposite_disabled_hint_text_color is an AliasProperty that returns the value in rgba
format for opposite_disabled_hint_text_color, property is readonly.
error_color
Color of the error text used in the MDTextField.
error_color is an AliasProperty that returns the value in rgba format for error_color,
property is readonly.
ripple_color
Color of ripple effects.
ripple_color is an AliasProperty that returns the value in rgba format for ripple_color,
property is readonly.
device_orientation
Device orientation.
device_orientation is an StringProperty.
standard_increment
Value of standard increment.
standard_increment is an AliasProperty that returns the value in rgba format for
standard_increment, property is readonly.
horizontal_margins
Value of horizontal margins.
horizontal_margins is an AliasProperty that returns the value in rgba format for
horizontal_margins, property is readonly.
set_clearcolor
font_styles
Data of default font styles.
Add custom font:
KV = '''
Screen:
MDLabel:
text: "JetBrainsMono"
halign: "center"
(continues on next page)
14 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
class MainApp(MDApp):
def build(self):
LabelBase.register(
name="JetBrainsMono",
fn_regular="JetBrainsMono-Regular.ttf")
theme_font_styles.append('JetBrainsMono')
self.theme_cls.font_styles["JetBrainsMono"] = [
"JetBrainsMono",
16,
False,
0.15,
]
return Builder.load_string(KV)
MainApp().run()
font_styles is an DictProperty.
on_theme_style(self, instance, value)
set_clearcolor_by_theme_style(self, theme_style)
class kivymd.theming.ThemableBehavior(**kwargs)
theme_cls
Instance of ThemeManager class.
2.2. Themes 15
KivyMD, Release 0.104.2.dev0
theme_cls is an ObjectProperty.
device_ios
True if device is iOS.
device_ios is an BooleanProperty.
opposite_colors
This module contains MDApp class that is inherited from App. MDApp has some properties needed for KivyMD
library (like theme_cls).
You can turn on the monitor displaying the current FPS value in your application:
KV = '''
Screen:
MDLabel:
text: "Hello, World!"
halign: "center"
'''
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
self.fps_monitor_start()
MainApp().run()
16 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.app
class kivymd.app.MDApp(**kwargs)
Application class, see module documentation for more information.
Events
on_start: Fired when the application is being started (before the runTouchApp() call.
on_stop: Fired when the application stops.
on_pause: Fired when the application is paused by the OS.
on_resume: Fired when the application is resumed from pause by the OS. Beware: you have
no guarantee that this event will be fired after the on_pause event has been called.
Changed in version 1.7.0: Parameter kv_file added.
Changed in version 1.8.0: Parameters kv_file and kv_directory are now properties of App.
2.2. Themes 17
KivyMD, Release 0.104.2.dev0
theme_cls
Instance of ThemeManager class.
Warning: The theme_cls attribute is already available in a class that is inherited from the MDApp
class. The following code will result in an error!
class MainApp(MDApp):
theme_cls = ThemeManager()
theme_cls.primary_palette = "Teal"
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Teal"
theme_cls is an ObjectProperty.
See also:
Material Design spec, The color system
Material colors palette to use in kivymd.theming.ThemeManager. colors is a dict-in-dict where the first key
is a value from palette and the second key is a value from hue. Color is a hex value, a string of 6 characters (0-9,
A-F) written in uppercase.
For example, colors["Red"]["900"] is "B71C1C".
API - kivymd.color_definitions
kivymd.color_definitions.colors
Color palette. Taken from 2014 Material Design color palettes.
To demonstrate the shades of the palette, you can run the following code:
demo = '''
<Root@BoxLayout>
orientation: 'vertical'
MDToolbar:
title: app.title
18 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
ScrollView:
MDList:
id: box
<ItemColor>:
size_hint_y: None
height: "42dp"
canvas:
Color:
rgba: root.color
Rectangle:
size: self.size
pos: self.pos
MDLabel:
text: root.text
halign: "center"
<Tab>:
'''
class ItemColor(BoxLayout):
text = StringProperty()
color = ListProperty()
class Palette(MDApp):
title = "Colors definitions"
def build(self):
Builder.load_string(demo)
self.screen = Factory.Root()
2.2. Themes 19
KivyMD, Release 0.104.2.dev0
self.screen.ids.box.clear_widgets()
for value_color in colors[tab_text]:
self.screen.ids.box.add_widget(
ItemColor(
color=get_color_from_hex(colors[tab_text][value_color]),
text=value_color,
)
)
def on_start(self):
self.on_tab_switch(
None,
None,
None,
self.screen.ids.android_tabs.ids.layout.children[-1].text,
)
Palette().run()
text_colors = {}
for p in palette:
text_colors[p] = {}
for h in hue:
if h in light_colors[p]:
text_colors[p][h] = "000000"
else:
text_colors[p][h] = "FFFFFF"
20 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
See also:
Material Design Icons
List of icons from materialdesignicons.com. These expanded material design icons are maintained by Austin Andrews
(Templarian on Github).
LAST UPDATED: Version 5.8.55
To preview the icons and their names, you can use the following application:
Builder.load_string(
'''
#:import images_path kivymd.images_path
<CustomOneLineIconListItem>:
IconLeftWidget:
icon: root.icon
<PreviousMDIcons>:
BoxLayout:
orientation: 'vertical'
spacing: dp(10)
padding: dp(20)
BoxLayout:
size_hint_y: None
height: self.minimum_height
(continues on next page)
2.2. Themes 21
KivyMD, Release 0.104.2.dev0
MDIconButton:
icon: 'magnify'
MDTextField:
id: search_field
hint_text: 'Search icon'
on_text: root.set_list_md_icons(self.text, True)
RecycleView:
id: rv
key_viewclass: 'viewclass'
key_size: 'height'
RecycleBoxLayout:
padding: dp(10)
default_size: None, dp(48)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
'''
)
class CustomOneLineIconListItem(OneLineIconListItem):
icon = StringProperty()
class PreviousMDIcons(Screen):
def add_icon_item(name_icon):
self.ids.rv.data.append(
{
"viewclass": "CustomOneLineIconListItem",
"icon": name_icon,
"text": name_icon,
"callback": lambda x: x,
}
)
self.ids.rv.data = []
for name_icon in md_icons.keys():
if search:
if text in name_icon:
add_icon_item(name_icon)
else:
add_icon_item(name_icon)
class MainApp(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = PreviousMDIcons()
(continues on next page)
22 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
def build(self):
return self.screen
def on_start(self):
self.screen.set_list_md_icons()
MainApp().run()
API - kivymd.icon_definitions
kivymd.icon_definitions.md_icons
See also:
Material Design spec, The type system
API - kivymd.font_definitions
kivymd.font_definitions.fonts
kivymd.font_definitions.theme_font_styles = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'Subtitle1
2.2. Themes 23
KivyMD, Release 0.104.2.dev0
2.3 Components
2.3.1 Tabs
See also:
Material Design spec, Tabs
24 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Tabs organize content across different screens, data sets, and other interactions.
Usage
To create a tab, you must create a new class that inherits from the MDTabsBase class and the Kivy container, in which
you will create content for the tab.
<Tab>:
MDLabel:
text: "Content"
pos_hint: {"center_x": .5, "center_y": .5}
Root:
MDTabs:
Tab:
text: "Tab 1"
Tab:
text: "Tab 1"
...
2.3. Components 25
KivyMD, Release 0.104.2.dev0
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
on_tab_switch: app.on_tab_switch(*args)
<Tab>:
MDIconButton:
id: icon
icon: app.icons[0]
user_font_size: "48sp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
icons = list(md_icons.keys())[15:30]
def build(self):
return Builder.load_string(KV)
def on_start(self):
for name_tab in self.icons:
self.root.ids.tabs.add_widget(Tab(text=name_tab))
def on_tab_switch(
self, instance_tabs, instance_tab, instance_tab_label, tab_text
):
'''Called when switching tabs.
26 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Example().run()
Note: The MDTabsBase class has an icon parameter and, by default, tries to find the name of the icon in the file
kivymd/icon_definitions.py. If the name of the icon is not found, then the name of the tab will be plain
text, if found, the tab will look like the corresponding icon.
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
on_tab_switch: app.on_tab_switch(*args)
<Tab>:
MDLabel:
id: label
text: "Tab 0"
halign: "center"
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
for i in range(20):
self.root.ids.tabs.add_widget(Tab(text=f"Tab {i}"))
def on_tab_switch(
(continues on next page)
2.3. Components 27
KivyMD, Release 0.104.2.dev0
instance_tab.ids.label.text = tab_text
Example().run()
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
for name_tab in list(md_icons.keys())[15:30]:
self.root.ids.tabs.add_widget(
Tab(
text=f"[size=20][font={fonts[-1]['fn_regular']}]{md_icons[name_
˓→tab]}[/size][/font] {name_tab}"
)
)
(continues on next page)
28 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Example().run()
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
<Tab>:
MDList:
MDBoxLayout:
adaptive_height: True
MDFlatButton:
text: "ADD TAB"
on_release: app.add_tab()
MDFlatButton:
text: "REMOVE LAST TAB"
on_release: app.remove_tab()
MDFlatButton:
text: "GET TAB LIST"
on_release: app.get_tab_list()
'''
2.3. Components 29
KivyMD, Release 0.104.2.dev0
def build(self):
return Builder.load_string(KV)
def on_start(self):
self.add_tab()
def get_tab_list(self):
'''Prints a list of tab objects.'''
print(self.root.ids.tabs.get_tab_list())
def add_tab(self):
self.index += 1
self.root.ids.tabs.add_widget(Tab(text=f"{self.index} tab"))
def remove_tab(self):
if self.index > 1:
self.index -= 1
self.root.ids.tabs.remove_widget(
self.root.ids.tabs.get_tab_list()[0]
)
Example().run()
You can use markup for the text of the tabs and use the on_ref_press method accordingly:
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
on_ref_press: app.on_ref_press(*args)
<Tab>:
(continues on next page)
30 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDIconButton:
id: icon
icon: app.icons[0]
user_font_size: "48sp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
icons = list(md_icons.keys())[15:30]
def build(self):
return Builder.load_string(KV)
def on_start(self):
for name_tab in self.icons:
self.root.ids.tabs.add_widget(
Tab(
text=f"[ref={name_tab}][font={fonts[-1]['fn_regular']}]{md_icons[
˓→'close']}[/font][/ref] {name_tab}"
)
)
def on_ref_press(
self,
instance_tabs,
instance_tab_label,
instance_tab,
instance_tab_bar,
instance_carousel,
):
'''
The method will be called when the ``on_ref_press`` event
occurs when you, for example, use markup text for tabs.
Example().run()
2.3. Components 31
KivyMD, Release 0.104.2.dev0
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Example Tabs"
MDTabs:
id: tabs
<Tab>:
MDIconButton:
id: icon
icon: "arrow-right"
user_font_size: "48sp"
pos_hint: {"center_x": .5, "center_y": .5}
on_release: app.switch_tab()
'''
class Example(MDApp):
icons = list(md_icons.keys())[15:30]
def build(self):
self.iter_list = iter(list(self.icons))
return Builder.load_string(KV)
def on_start(self):
for name_tab in list(self.icons):
self.root.ids.tabs.add_widget(Tab(text=name_tab))
def switch_tab(self):
'''Switching the tab by name.'''
try:
self.root.ids.tabs.switch_tab(next(self.iter_list))
except StopIteration:
pass
Example().run()
32 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.tab
class kivymd.uix.tab.MDTabsBase(**kwargs)
This class allow you to create a tab. You must create a new class that inherits from MDTabsBase. In this way
you have total control over the views of your tabbed panel.
text
It will be the label text of the tab.
text is an StringProperty and defaults to ‘’.
tab_label
It is the label object reference of the tab.
tab_label is an ObjectProperty and defaults to None.
on_text(self, widget, text)
class kivymd.uix.tab.MDTabs(**kwargs)
You can use this class to create your own tabbed panel..
Events
on_tab_switch Called when switching tabs.
on_slide_progress Called while the slide is scrolling.
on_ref_press The method will be called when the on_ref_press event occurs when you,
for example, use markup text for tabs.
default_tab
Index of the default tab.
default_tab is an NumericProperty and defaults to 0.
tab_bar_height
Height of the tab bar.
tab_bar_height is an NumericProperty and defaults to ‘48dp’.
tab_indicator_anim
Tab indicator animation. If you want use animation set it to True.
tab_indicator_anim is an BooleanProperty and defaults to False.
tab_indicator_height
Height of the tab indicator.
tab_indicator_height is an NumericProperty and defaults to ‘2dp’.
tab_indicator_type
Type of tab indicator. Available options are: ‘line’, ‘fill’, ‘round’, ‘line-rect’ and ‘line-round’.
tab_indicator_type is an OptionProperty and defaults to ‘line’.
anim_duration
Duration of the slide animation.
anim_duration is an NumericProperty and defaults to 0.2.
anim_threshold
Animation threshold allow you to change the tab indicator animation effect.
anim_threshold is an BoundedNumericProperty and defaults to 0.8.
2.3. Components 33
KivyMD, Release 0.104.2.dev0
allow_stretch
If False - tabs will not stretch to full screen.
allow_stretch is an BooleanProperty and defaults to True.
background_color
Background color of tabs in rgba format.
background_color is an ListProperty and defaults to [].
text_color_normal
Text color of the label when it is not selected.
text_color_normal is an ListProperty and defaults to (1, 1, 1, 1).
text_color_active
Text color of the label when it is selected.
text_color_active is an ListProperty and defaults to (1, 1, 1, 1).
elevation
Tab value elevation.
See also:
Behaviors/Elevation
elevation is an NumericProperty and defaults to 0.
color_indicator
Color indicator in rgba format.
color_indicator is an ListProperty and defaults to [].
lock_swiping
If True - disable switching tabs by swipe.
lock_swiping is an BooleanProperty and defaults to False.
font_name
Font name for tab text.
font_name is an StringProperty and defaults to ‘Roboto’.
switch_tab(self, name_tab)
Switching the tab by name.
get_tab_list(self )
Returns a list of tab objects.
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
34 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
remove_widget(self, widget)
Remove a widget from the children of this widget.
Parameters
widget: Widget Widget to remove from our children list.
on_slide_progress(self, *args)
Called while the slide is scrolling.
on_carousel_index(self, carousel, index)
Called when the carousel index changes.
on_ref_press(self, *args)
The method will be called when the on_ref_press event occurs when you, for example, use markup
text for tabs.
on_tab_switch(self, *args)
Called when switching tabs.
BoxLayout class equivalent. Simplifies working with some widget properties. For example:
BoxLayout
BoxLayout:
size_hint_y: None
height: self.minimum_height
canvas:
Color:
rgba: app.theme_cls.primary_color
Rectangle:
pos: self.pos
size: self.size
2.3. Components 35
KivyMD, Release 0.104.2.dev0
MDBoxLayout
MDBoxLayout:
adaptive_height: True
md_bg_color: app.theme_cls.primary_color
• adaptive_height
• adaptive_width
• adaptive_size
adaptive_height
adaptive_height: True
Equivalent
size_hint_y: None
height: self.minimum_height
adaptive_width
adaptive_width: True
Equivalent
size_hint_x: None
height: self.minimum_width
adaptive_size
adaptive_size: True
Equivalent
36 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.boxlayout
class kivymd.uix.boxlayout.MDBoxLayout(**kwargs)
Box layout class. See module documentation for more information.
2.3.3 TapTargetView
See also:
TapTargetView, GitHub
TapTargetView, Material archive
Provide value and improve engagement by introducing users to new features and functionality at
relevant moments.
Usage
KV = '''
Screen:
MDFloatingActionButton:
id: button
icon: "plus"
pos: 10, 10
on_release: app.tap_target_start()
'''
class TapTargetViewDemo(MDApp):
def build(self):
screen = Builder.load_string(KV)
self.tap_target_view = MDTapTargetView(
widget=screen.ids.button,
title_text="This is an add button",
description_text="This is a description of the button",
widget_position="left_bottom",
)
return screen
def tap_target_start(self):
if self.tap_target_view.state == "close":
self.tap_target_view.start()
else:
self.tap_target_view.stop()
2.3. Components 37
KivyMD, Release 0.104.2.dev0
TapTargetViewDemo().run()
Widget position
self.tap_target_view = MDTapTargetView(
...
widget_position="right",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="left",
)
38 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
self.tap_target_view = MDTapTargetView(
...
widget_position="top",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="bottom",
)
2.3. Components 39
KivyMD, Release 0.104.2.dev0
self.tap_target_view = MDTapTargetView(
...
widget_position="left_top",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="right_top",
)
40 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
self.tap_target_view = MDTapTargetView(
...
widget_position="left_bottom",
)
self.tap_target_view = MDTapTargetView(
...
widget_position="right_bottom",
)
2.3. Components 41
KivyMD, Release 0.104.2.dev0
If you use the widget_position = "center" parameter then you must definitely specify the
title_position.
self.tap_target_view = MDTapTargetView(
...
widget_position="center",
title_position="left_top",
)
42 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Text options
self.tap_target_view = MDTapTargetView(
...
title_text="Title text",
description_text="Description text",
)
You can use the following options to control font size, color, and boldness:
• title_text_size
• title_text_color
• title_text_bold
• description_text_size
• description_text_color
• description_text_bold
2.3. Components 43
KivyMD, Release 0.104.2.dev0
self.tap_target_view = MDTapTargetView(
...
title_text="Title text",
title_text_size="36sp",
description_text="Description text",
description_text_color=[1, 0, 0, 1]
)
self.tap_target_view = MDTapTargetView(
...
title_text="[size=36]Title text[/size]",
description_text="[color=#ff0000ff]Description text[/color]",
)
44 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Events control
self.tap_target_view.bind(on_open=self.on_open, on_close=self.on_close)
print("Open", instance_tap_target_view)
print("Close", instance_tap_target_view)
API - kivymd.uix.taptargetview
class kivymd.uix.taptargetview.MDTapTargetView(**kwargs)
Rough try to mimic the working of Android’s TapTargetView.
Events
on_open Called at the time of the start of the widget opening animation.
on_close Called at the time of the start of the widget closed animation.
widget
Widget to add TapTargetView upon.
widget is an ObjectProperty and defaults to None.
outer_radius
Radius for outer circle.
self.tap_target_view = MDTapTargetView(
...
outer_circle_color=(1, 0, 0)
)
2.3. Components 45
KivyMD, Release 0.104.2.dev0
46 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
self.tap_target_view = MDTapTargetView(
...
target_circle_color=(1, 0, 0)
)
2.3. Components 47
KivyMD, Release 0.104.2.dev0
description_text_color
Text size for description text.
description_text_color is an ListProperty and defaults to [0.9, 0.9, 0.9, 1].
description_text_bold
Whether description should be bold.
description_text_bold is an BooleanProperty and defaults to False.
draw_shadow
Whether to show shadow.
draw_shadow is an BooleanProperty and defaults to False.
cancelable
Whether clicking outside the outer circle dismisses the view.
cancelable is an BooleanProperty and defaults to False.
widget_position
Sets the position of the widget on the outer_circle. Available options are ‘left’, ‘right’, ‘top’, ‘bot-
tom’, ‘left_top’, ‘right_top’, ‘left_bottom’, ‘right_bottom’, ‘center’.
widget_position is an OptionProperty and defaults to ‘left’.
title_position
Sets the position of :attr`~title_text` on the outer circle. Only works if :attr`~widget_position` is set to
‘center’. In all other cases, it calculates the :attr`~title_position` itself. Must be set to other than ‘auto’
when :attr`~widget_position` is set to ‘center’.
Available options are ‘auto’, ‘left’, ‘right’, ‘top’, ‘bottom’, ‘left_top’, ‘right_top’, ‘left_bottom’,
‘right_bottom’, ‘center’.
title_position is an OptionProperty and defaults to ‘auto’.
stop_on_outer_touch
Whether clicking on outer circle stops the animation.
stop_on_outer_touch is an BooleanProperty and defaults to False.
stop_on_target_touch
Whether clicking on target circle should stop the animation.
stop_on_target_touch is an BooleanProperty and defaults to True.
state
State of MDTapTargetView.
state is an OptionProperty and defaults to ‘close’.
stop(self, *args)
Starts widget close animation.
start(self, *args)
Starts widget opening animation.
on_open(self, *args)
Called at the time of the start of the widget opening animation.
on_close(self, *args)
Called at the time of the start of the widget closed animation.
on_draw_shadow(self, instance, value)
on_description_text(self, instance, value)
48 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Example
Builder.load_string('''
<ItemForList>
text: root.text
IconLeftSampleWidget:
icon: root.icon
<Example@FloatLayout>
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: app.title
md_bg_color: app.theme_cls.primary_color
background_palette: 'Primary'
elevation: 10
left_action_items: [['menu', lambda x: x]]
MDScrollViewRefreshLayout:
id: refresh_layout
refresh_callback: app.refresh_callback
(continues on next page)
2.3. Components 49
KivyMD, Release 0.104.2.dev0
MDGridLayout:
id: box
adaptive_height: True
cols: 1
''')
class ItemForList(OneLineIconListItem):
icon = StringProperty()
class Example(MDApp):
title = 'Example Refresh Layout'
screen = None
x = 0
y = 15
def build(self):
self.screen = Factory.Example()
self.set_list()
return self.screen
def set_list(self):
async def set_list():
names_icons_list = list(md_icons.keys())[self.x:self.y]
for name_icon in names_icons_list:
await asynckivy.sleep(0)
self.screen.ids.box.add_widget(
ItemForList(icon=name_icon, text=name_icon))
asynckivy.start(set_list())
def refresh_callback(interval):
self.screen.ids.box.clear_widgets()
if self.x == 0:
self.x, self.y = 15, 30
else:
self.x, self.y = 0, 15
self.set_list()
self.screen.ids.refresh_layout.refresh_done()
self.tick = 0
Clock.schedule_once(refresh_callback, 1)
Example().run()
50 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.refreshlayout
class kivymd.uix.refreshlayout.MDScrollViewRefreshLayout(**kargs)
ScrollView class. See module documentation for more information.
Events
on_scroll_start Generic event fired when scrolling starts from touch.
on_scroll_move Generic event fired when scrolling move from touch.
on_scroll_stop Generic event fired when scrolling stops from touch.
Changed in version 1.9.0: on_scroll_start, on_scroll_move and on_scroll_stop events are now dispatched when
scrolling to handle nested ScrollViews.
Changed in version 1.7.0: auto_scroll, scroll_friction, scroll_moves, scroll_stoptime’ has been deprecated, use
:attr:`effect_cls instead.
root_layout
The spinner will be attached to this layout.
on_touch_up(self, *args)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
refresh_done(self )
class kivymd.uix.refreshlayout.RefreshSpinner(**kwargs)
Float layout class. See module documentation for more information.
spinner_color
start_anim_spinner(self )
hide_anim_spinner(self )
set_spinner(self, *args)
See also:
Material Design spec, Expansion panel
Expansion panels contain creation flows and allow lightweight editing of an element.
2.3. Components 51
KivyMD, Release 0.104.2.dev0
Usage
self.add_widget(
MDExpansionPanel(
icon="logo.png", # panel icon
content=Content(), # panel content
panel_cls=MDExpansionPanelOneLine(text="Secondary text"), # panel class
)
)
To use MDExpansionPanel you must pass one of the following classes to the panel_cls parameter:
• MDExpansionPanelOneLine
• MDExpansionPanelTwoLine
• MDExpansionPanelThreeLine
These classes are inherited from the following classes:
• OneLineAvatarIconListItem
• TwoLineAvatarIconListItem
• ThreeLineAvatarIconListItem
self.root.ids.box.add_widget(
MDExpansionPanel(
icon="logo.png",
content=Content(),
panel_cls=MDExpansionPanelThreeLine(
text="Text",
secondary_text="Secondary text",
tertiary_text="Tertiary text",
)
)
)
Example
KV = '''
<Content>
adaptive_height: True
TwoLineIconListItem:
text: "(050)-123-45-67"
secondary_text: "Mobile"
IconLeftWidget:
icon: 'phone'
(continues on next page)
52 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
ScrollView:
MDGridLayout:
id: box
cols: 1
adaptive_height: True
'''
class Content(MDBoxLayout):
'''Custom content.'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
for i in range(10):
self.root.ids.box.add_widget(
MDExpansionPanel(
icon=f"{images_path}kivymd.png",
content=Content(),
panel_cls=MDExpansionPanelThreeLine(
text="Text",
secondary_text="Secondary text",
tertiary_text="Tertiary text",
)
)
)
Test().run()
• on_open
• on_close
MDExpansionPanel:
on_open: app.on_panel_open(args)
on_close: app.on_panel_close(args)
The user function takes one argument - the object of the panel:
See also:
See Expansion panel example
2.3. Components 53
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.expansionpanel
class kivymd.uix.expansionpanel.MDExpansionPanelOneLine(**kwargs)
Single line panel.
class kivymd.uix.expansionpanel.MDExpansionPanelTwoLine(**kwargs)
Two-line panel.
class kivymd.uix.expansionpanel.MDExpansionPanelThreeLine(**kwargs)
Three-line panel.
class kivymd.uix.expansionpanel.MDExpansionPanel(**kwargs)
Events
content
Content of panel. Must be Kivy widget.
content is an ObjectProperty and defaults to None.
icon
Icon of panel.
Icon Should be either be a path to an image or a logo name in md_icons
icon is an StringProperty and defaults to ‘’.
opening_transition
The name of the animation transition type to use when animating to the state ‘open’.
opening_transition is a StringProperty and defaults to ‘out_cubic’.
opening_time
The time taken for the panel to slide to the state ‘open’.
opening_time is a NumericProperty and defaults to 0.2.
closing_transition
The name of the animation transition type to use when animating to the state ‘close’.
closing_transition is a StringProperty and defaults to ‘out_sine’.
closing_time
The time taken for the panel to slide to the state ‘close’.
closing_time is a NumericProperty and defaults to 0.2.
panel_cls
Panel object. The object must be one of the classes MDExpansionPanelOneLine,
MDExpansionPanelTwoLine or MDExpansionPanelThreeLine.
panel_cls is a ObjectProperty and defaults to None.
on_open(self, *args)
Called when a panel is opened.
on_close(self, *args)
Called when a panel is closed.
54 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
check_open_panel(self, instance)
Called when you click on the panel. Called methods to open or close a panel.
set_chevron_down(self )
Sets the chevron down.
set_chevron_up(self, instance_chevron)
Sets the chevron up.
close_panel(self, instance_panel, press_current_panel)
Method closes the panel.
open_panel(self, *args)
Method opens a panel.
get_state(self )
Returns the state of panel. Can be close or open .
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
2.3.6 Button
See also:
Material Design spec, Buttons
Material Design spec, Buttons: floating action button
2.3. Components 55
KivyMD, Release 0.104.2.dev0
Buttons allow users to take actions, and make choices, with a single tap.
MDIconButton
56 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDIconButton
KV = '''
Screen:
MDIconButton:
icon: "language-python"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
The icon parameter must have the name of the icon from kivymd/icon_definitions.py file.
You can also use custom icons:
MDIconButton:
icon: "data/logo/kivy-icon-256.png"
By default, MDIconButton button has a size (dp(48), dp (48)). Use user_font_size attribute to resize
the button:
MDIconButton:
icon: "android"
user_font_size: "64sp"
By default, the color of MDIconButton (depending on the style of the application) is black or white. You can change
the color of MDIconButton as the text color of MDLabel:
MDIconButton:
icon: "android"
theme_text_color: "Custom"
text_color: app.theme_cls.primary_color
2.3. Components 57
KivyMD, Release 0.104.2.dev0
MDFloatingActionButton
MDFloatingActionButton:
icon: "android"
md_bg_color: app.theme_cls.primary_color
MDFloatingActionButton:
icon: "android"
elevation_normal: 12
MDFlatButton
To change the text color of: class:~MDFlatButton use the text_color parameter:
MDFlatButton:
text: "MDFLATBUTTON"
text_color: 0, 0, 1, 1
Or use markup:
58 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDFlatButton:
text: "[color=#00ffcc]MDFLATBUTTON[/color]"
markup: True
To specify the font size and font name, use the parameters as in the usual Kivy buttons:
MDFlatButton:
text: "MDFLATBUTTON"
font_size: "18sp"
font_name: "path/to/font"
Warning: You cannot use the size_hint_x parameter for KivyMD buttons (the width of the buttons is set
automatically)!
MDRaisedButton
This button is similar to the MDFlatButton button except that you can set the background color for
MDRaisedButton:
MDRaisedButton:
text: "MDRAISEDBUTTON"
md_bg_color: 1, 0, 1, 1
MDRectangleFlatButton
MDRectangleFlatButton:
text: "MDRECTANGLEFLATBUTTON"
text_color: 0, 0, 1, 1
md_bg_color: 1, 1, 0, 1
Note: Note that the frame color will be the same as the text color.
2.3. Components 59
KivyMD, Release 0.104.2.dev0
MDRectangleFlatIconButton
MDRectangleFlatIconButton:
icon: "android"
text: "MDRECTANGLEFLATICONBUTTON"
Without border
class Example(MDApp):
def build(self):
screen = Screen()
screen.add_widget(
MDRectangleFlatIconButton(
text="MDRectangleFlatIconButton",
icon="language-python",
line_color=(0, 0, 0, 0),
pos_hint={"center_x": .5, "center_y": .5},
)
)
return screen
Example().run()
MDRectangleFlatIconButton:
text: "MDRectangleFlatIconButton"
icon: "language-python"
line_color: 0, 0, 0, 0
pos_hint: {"center_x": .5, "center_y": .5}
60 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDRoundFlatButton
MDRoundFlatButton:
text: "MDROUNDFLATBUTTON"
Warning: The border color does change when using text_color parameter.
MDRoundFlatButton:
text: "MDROUNDFLATBUTTON"
text_color: 0, 1, 0, 1
MDRoundFlatIconButton
MDRoundFlatIconButton:
icon: "android"
text: "MDROUNDFLATICONBUTTON"
2.3. Components 61
KivyMD, Release 0.104.2.dev0
MDFillRoundFlatButton
MDFillRoundFlatIconButton
Note: Notice that the width of the MDFillRoundFlatIconButton button matches the size of the button text.
MDTextButton
MDTextButton:
text: "MDTEXTBUTTON"
custom_color: 0, 1, 0, 1
62 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDFloatingActionButtonSpeedDial
KV = '''
Screen:
MDFloatingActionButtonSpeedDial:
data: app.data
rotation_root_button: True
'''
class Example(MDApp):
data = {
'language-python': 'Python',
'language-php': 'PHP',
'language-cpp': 'C++',
}
def build(self):
return Builder.load_string(KV)
Example().run()
Or without KV Language:
from kivy.uix.screenmanager import Screen
class Example(MDApp):
data = {
'language-python': 'Python',
'language-php': 'PHP',
'language-cpp': 'C++',
}
def build(self):
screen = Screen()
speed_dial = MDFloatingActionButtonSpeedDial()
speed_dial.data = self.data
speed_dial.rotation_root_button = True
screen.add_widget(speed_dial)
return screen
2.3. Components 63
KivyMD, Release 0.104.2.dev0
You can use various types of animation of labels for buttons on the stack:
MDFloatingActionButtonSpeedDial:
hint_animation: True
You can set your color values for background, text of buttons etc:
MDFloatingActionButtonSpeedDial:
bg_hint_color: app.theme_cls.primary_light
See also:
See full example
64 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.button
class kivymd.uix.button.MDIconButton(**kwargs)
Abstract base class for all round buttons, bringing in the appropriate on-touch behavior
icon
Button icon.
icon is an StringProperty and defaults to ‘checkbox-blank-circle’.
class kivymd.uix.button.MDFlatButton(**kwargs)
Abstract base class for all rectangular buttons, bringing in the appropriate on-touch behavior. Also maintains
the correct minimum width as stated in guidelines.
class kivymd.uix.button.MDRaisedButton(**kwargs)
Abstract base class for all rectangular buttons, bringing in the appropriate on-touch behavior. Also maintains
the correct minimum width as stated in guidelines.
class kivymd.uix.button.MDFloatingActionButton(**kwargs)
Abstract base class for all round buttons, bringing in the appropriate on-touch behavior
icon
Button icon.
icon is an StringProperty and defaults to ‘android’.
background_palette
The name of the palette used for the background color of the button.
background_palette is an StringProperty and defaults to ‘Accent’.
on_md_bg_color(self, instance, value)
class kivymd.uix.button.MDRectangleFlatButton(**kwargs)
Abstract base class for all rectangular buttons, bringing in the appropriate on-touch behavior. Also maintains
the correct minimum width as stated in guidelines.
update_md_bg_color(self, instance, value)
Called when the application color palette changes.
on_disabled(self, instance, value)
class kivymd.uix.button.MDRoundFlatButton(**kwargs)
Abstract base class for all rectangular buttons, bringing in the appropriate on-touch behavior. Also maintains
the correct minimum width as stated in guidelines.
update_md_bg_color(self, instance, value)
Called when the application color palette changes.
lay_canvas_instructions(self )
class kivymd.uix.button.MDTextButton(**kwargs)
Button class, see module documentation for more information.
Changed in version 1.8.0: The behavior / logic of the button has been moved to ButtonBehaviors.
custom_color
Custom user button color in rgba format.
custom_color is an ListProperty and defaults to [].
animation_label(self )
on_press(self, *args)
2.3. Components 65
KivyMD, Release 0.104.2.dev0
66 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
icon
Root button icon name.
icon is a StringProperty and defaults to ‘plus’.
anchor
Stack anchor. Available options are: ‘right’.
anchor is a OptionProperty and defaults to ‘right’.
callback
Custom callback.
MDFloatingActionButtonSpeedDial:
callback: app.callback
{
'name-icon': 'Text label',
...,
...,
}
right_pad
If True, the button will increase on the right side by 2.5 pixels if the hint_animation parameter equal
to True.
False
True
2.3. Components 67
KivyMD, Release 0.104.2.dev0
closing_transition
The name of the stack closing animation type.
closing_transition is a StringProperty and defaults to ‘out_cubic’.
opening_transition_button_rotation
The name of the animation type to rotate the root button when opening the stack.
opening_transition_button_rotation is a StringProperty and defaults to ‘out_cubic’.
closing_transition_button_rotation
The name of the animation type to rotate the root button when closing the stack.
closing_transition_button_rotation is a StringProperty and defaults to ‘out_cubic’.
opening_time
Time required for the stack to go to: attr:state ‘open’.
opening_time is a NumericProperty and defaults to 0.2.
closing_time
Time required for the stack to go to: attr:state ‘close’.
closing_time is a NumericProperty and defaults to 0.2.
opening_time_button_rotation
Time required to rotate the root button 45 degrees during the stack opening animation.
opening_time_button_rotation is a NumericProperty and defaults to 0.2.
closing_time_button_rotation
Time required to rotate the root button 0 degrees during the stack closing animation.
closing_time_button_rotation is a NumericProperty and defaults to 0.2.
state
Indicates whether the stack is closed or open. Available options are: ‘close’, ‘open’.
state is a OptionProperty and defaults to ‘close’.
bg_color_root_button
Root button color in rgba format.
bg_color_root_button is a ListProperty and defaults to [].
bg_color_stack_button
The color of the buttons in the stack rgba format.
bg_color_stack_button is a ListProperty and defaults to [].
color_icon_stack_button
The color icon of the buttons in the stack rgba format.
color_icon_stack_button is a ListProperty and defaults to [].
color_icon_root_button
The color icon of the root button rgba format.
color_icon_root_button is a ListProperty and defaults to [].
bg_hint_color
Background color for the text of the buttons in the stack rgba format.
bg_hint_color is a ListProperty and defaults to [].
68 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
hint_animation
Whether to use button extension animation to display text labels.
hint_animation is a BooleanProperty and defaults to False.
on_open(self, *args)
Called when a stack is opened.
on_close(self, *args)
Called when a stack is closed.
on_leave(self, instance)
Called when the mouse cursor goes outside the button of stack.
on_enter(self, instance)
Called when the mouse cursor is over a button from the stack.
on_data(self, instance, value)
Creates a stack of buttons.
on_icon(self, instance, value)
on_label_text_color(self, instance, value)
on_color_icon_stack_button(self, instance, value)
on_hint_animation(self, instance, value)
on_bg_hint_color(self, instance, value)
on_color_icon_root_button(self, instance, value)
on_bg_color_stack_button(self, instance, value)
on_bg_color_root_button(self, instance, value)
set_pos_labels(self, widget)
Sets the position of the floating labels.
set_pos_root_button(self, instance)
Sets the position of the root button.
set_pos_bottom_buttons(self, instance)
Sets the position of the bottom buttons in a stack.
open_stack(self, instance)
Opens a button stack.
do_animation_open_stack(self, anim_data)
close_stack(self )
Closes the button stack.
2.3.7 Spinner
Usage
2.3. Components 69
KivyMD, Release 0.104.2.dev0
KV = '''
Screen:
MDSpinner:
size_hint: None, None
size: dp(46), dp(46)
pos_hint: {'center_x': .5, 'center_y': .5}
active: True if check.active else False
MDCheckbox:
id: check
size_hint: None, None
size: dp(48), dp(48)
pos_hint: {'center_x': .5, 'center_y': .4}
active: True
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Spinner palette
MDSpinner:
# The number of color values can be any.
palette:
[0.28627450980392155, 0.8431372549019608, 0.596078431372549, 1],
˓→[0.3568627450980392, 0.3215686274509804, 0.8666666666666667, 1], [0.
˓→8862745098039215, 0.36470588235294116, 0.592156862745098, 1], [0.
˓→8784313725490196, 0.9058823529411765, 0.40784313725490196, 1],
MDSpinner(
size_hint=(None, None),
size=(dp(46), dp(46)),
pos_hint={'center_x': .5, 'center_y': .5},
active=True,
palette=[
[0.28627450980392155, 0.8431372549019608, 0.596078431372549, 1],
[0.3568627450980392, 0.3215686274509804, 0.8666666666666667, 1],
[0.8862745098039215, 0.36470588235294116, 0.592156862745098, 1],
[0.8784313725490196, 0.9058823529411765, 0.40784313725490196, 1],
]
)
70 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.spinner
class kivymd.uix.spinner.MDSpinner(**kwargs)
MDSpinner is an implementation of the circular progress indicator in Google’s Material Design.
It can be used either as an indeterminate indicator that loops while the user waits for something to happen, or as
a determinate indicator.
Set determinate to True to activate determinate mode, and determinate_time to set the duration of
the animation.
determinate
Determinate value.
determinate is a BooleanProperty and defaults to False.
determinate_time
Determinate time value.
determinate_time is a NumericProperty and defaults to 2.
active
Use active to start or stop the spinner.
active is a BooleanProperty and defaults to True.
color
Spinner color.
color is a ListProperty and defaults to self.theme_cls.primary_color.
palette
A set of colors. Changes with each completed spinner cycle.
palette is a ListProperty and defaults to [].
on__rotation_angle(self, *args)
on_palette(self, instance, value)
on_active(self, *args)
Usage
path = '/' # path to the directory that will be opened in the file manager
file_manager = MDFileManager(
exit_manager=self.exit_manager, # function called when the user reaches
˓→directory tree root
2.3. Components 71
KivyMD, Release 0.104.2.dev0
Warning: The preview mode is intended only for viewing images and will not display other types of files.
Example
72 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDToolbar:
title: "MDFileManager"
left_action_items: [['menu', lambda x: None]]
elevation: 10
FloatLayout:
MDRoundFlatIconButton:
text: "Open manager"
icon: "folder"
pos_hint: {'center_x': .5, 'center_y': .6}
on_release: app.file_manager_open()
'''
class Example(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
Window.bind(on_keyboard=self.events)
self.manager_open = False
self.file_manager = MDFileManager(
exit_manager=self.exit_manager,
select_path=self.select_path,
preview=True,
)
def build(self):
return Builder.load_string(KV)
def file_manager_open(self):
self.file_manager.show('/') # output manager to the screen
self.manager_open = True
self.exit_manager()
toast(path)
self.manager_open = False
self.file_manager.close()
2.3. Components 73
KivyMD, Release 0.104.2.dev0
Example().run()
API - kivymd.uix.filemanager
class kivymd.uix.filemanager.MDFileManager(**kwargs)
Float layout class. See module documentation for more information.
icon
The icon that will be used on the directory selection button.
icon is an StringProperty and defaults to check.
icon_folder
The icon that will be used for folder icons when using preview = True.
icon is an StringProperty and defaults to check.
exit_manager
Function called when the user reaches directory tree root.
exit_manager is an ObjectProperty and defaults to lambda x: None.
select_path
Function, called when selecting a file/directory.
select_path is an ObjectProperty and defaults to lambda x: None.
ext
List of file extensions to be displayed in the manager. For example, [‘.py’, ‘.kv’] - will filter out all files,
except python scripts and Kv Language.
ext is an ListProperty and defaults to [].
search
It can take the values ‘all’ ‘dirs’ ‘files’ - display only directories or only files or both them. By default, it
displays folders, and files. Available options are: ‘all’, ‘dirs’, ‘files’.
search is an OptionProperty and defaults to all.
current_path
Current directory.
current_path is an StringProperty and defaults to /.
use_access
Show access to files and directories.
use_access is an BooleanProperty and defaults to True.
preview
Shows only image previews.
preview is an BooleanProperty and defaults to False.
74 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
show_hidden_files
Shows hidden files.
show_hidden_files is an BooleanProperty and defaults to False.
sort_by
It can take the values ‘nothing’ ‘name’ ‘date’ ‘size’ ‘type’ - sorts files by option By default, sort by name.
Available options are: ‘nothing’, ‘name’, ‘date’, ‘size’, ‘type’.
sort_by is an OptionProperty and defaults to name.
sort_by_desc
Sort by descending.
sort_by_desc is an BooleanProperty and defaults to False.
selector
It can take the values ‘any’ ‘file’ ‘folder’ ‘multi’ By default, any. Available options are: ‘any’, ‘file’,
‘folder’, ‘multi’.
selector is an OptionProperty and defaults to any.
selection
Contains the list of files that are currently selected.
selection is a read-only ListProperty and defaults to [].
show(self, path)
Forms the body of a directory tree.
Parameters path – The path to the directory that will be opened in the file manager.
get_access_string(self, path)
get_content(self )
Returns a list of the type [[Folder List], [file list]].
close(self )
Closes the file manager window.
select_dir_or_file(self, path, widget)
Called by tap on the name of the directory or file.
back(self )
Returning to the branch down in the directory tree.
select_directory_on_press_button(self, *args)
Called when a click on a floating button.
2.3.9 MDSwiper
2.3. Components 75
KivyMD, Release 0.104.2.dev0
Usage
MDSwiper:
MDSwiperItem:
MDSwiperItem:
MDSwiperItem:
Example
kv = '''
<MySwiper@MDSwiperItem>
FitImage:
source: "guitar.png"
radius: [20,]
MDScreen:
MDToolbar:
id: toolbar
title: "MDSwiper"
elevation: 10
pos_hint: {"top": 1}
MDSwiper:
size_hint_y: None
height: root.height - toolbar.height - dp(40)
y: root.height - self.height - toolbar.height - dp(20)
MySwiper:
MySwiper:
MySwiper:
MySwiper:
MySwiper:
'''
class Main(MDApp):
def build(self):
return Builder.load_string(kv)
Main().run()
76 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Warning: The width of MDSwiperItem is adjusted automatically. Consider changing that by width_mult.
Warning: The width of MDSwiper is automatically adjusted according to the width of the window.
__events__ = (
"on_swipe",
"on_pre_swipe",
"on_overswipe_right",
"on_overswipe_left",
"on_swipe_left",
"on_swipe_right"
)
MDSwiper:
on_swipe: print("on_swipe")
on_pre_swipe: print("on_pre_swipe")
on_overswipe_right: print("on_overswipe_right")
on_overswipe_left: print("on_overswipe_left")
on_swipe_left: print("on_swipe_left")
on_swipe_right: print("on_swipe_right")
Example
kv = '''
<MagicButton@MagicBehavior+MDIconButton>
<MySwiper@MDSwiperItem>
RelativeLayout:
FitImage:
source: "guitar.png"
radius: [20,]
MDBoxLayout:
adaptive_height: True
spacing: "12dp"
MagicButton:
id: icon
icon: "weather-sunny"
user_font_size: "56sp"
opposite_colors: True
(continues on next page)
2.3. Components 77
KivyMD, Release 0.104.2.dev0
MDLabel:
text: "MDLabel"
font_style: "H5"
size_hint_y: None
height: self.texture_size[1]
pos_hint: {"center_y": .5}
opposite_colors: True
MDScreen:
MDToolbar:
id: toolbar
title: "MDSwiper"
elevation: 10
pos_hint: {"top": 1}
MDSwiper:
size_hint_y: None
height: root.height - toolbar.height - dp(40)
y: root.height - self.height - toolbar.height - dp(20)
on_swipe: self.get_current_item().ids.icon.shake()
MySwiper:
MySwiper:
MySwiper:
MySwiper:
MySwiper:
'''
class Main(MDApp):
def build(self):
return Builder.load_string(kv)
Main().run()
78 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Example
MDSwiper:
id: swiper
MDRaisedButton:
text: "Go to Second"
on_release: swiper.set_current(1)
API - kivymd.uix.swiper
class kivymd.uix.swiper.MDSwiperItem(**kwargs)
MDSwiperItem is a BoxLayout but it’s size is adjusted automatically.
class kivymd.uix.swiper.MDSwiper(**kwargs)
ScrollView class. See module documentation for more information.
Events
on_scroll_start Generic event fired when scrolling starts from touch.
on_scroll_move Generic event fired when scrolling move from touch.
on_scroll_stop Generic event fired when scrolling stops from touch.
Changed in version 1.9.0: on_scroll_start, on_scroll_move and on_scroll_stop events are now dispatched when
scrolling to handle nested ScrollViews.
Changed in version 1.7.0: auto_scroll, scroll_friction, scroll_moves, scroll_stoptime’ has been deprecated, use
:attr:`effect_cls instead.
items_spacing
The space between each MDSwiperItem.
items_spacing is an NumericProperty and defaults to 20dp.
transition_duration
Duration of switching between MDSwiperItem.
transition_duration is an NumericProperty and defaults to 0.2.
size_duration
Duration of changing the size of MDSwiperItem.
transition_duration is an NumericProperty and defaults to 0.2.
size_transition
The type of animation used for changing the size of MDSwiperItem.
size_transition is an StringProperty and defaults to out_quad.
2.3. Components 79
KivyMD, Release 0.104.2.dev0
swipe_transition
The type of animation used for swiping.
swipe_transition is an StringProperty and defaults to out_quad.
swipe_distance
Distance to move before swiping the MDSwiperItem.
swipe_distance is an NumericProperty and defaults to 70dp.
width_mult
This number is multiplied by items_spacing x2 and then subtracted from the width of window to spec-
ify the width of MDSwiperItem. So by decreasing the width_mult the width of MDSwiperItem
increases and vice versa.
width_mult is an NumericProperty and defaults to 3.
swipe_on_scroll
Wheter to swipe on mouse wheel scrolling or not.
swipe_on_scroll is an BooleanProperty and defaults to True.
add_widget(self, widget, index=0)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
remove_widget(self, widget)
Remove a widget from the children of this widget.
Parameters
widget: Widget Widget to remove from our children list.
set_current(self, index)
Switch to given MDSwiperItem index.
80 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
get_current_index(self )
Returns the current MDSwiperItem index.
get_current_item(self )
Returns the current MDSwiperItem instance.
get_items(self )
Returns the list of MDSwiperItem children.
on_swipe(self )
on_pre_swipe(self )
on_overswipe_right(self )
on_overswipe_left(self )
on_swipe_left(self )
on_swipe_right(self )
swipe_left(self )
swipe_right(self )
on_scroll_start(self, touch, check_children=True)
on_touch_down(self, 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.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
See also:
Material Design spec, Sheets: bottom
2.3. Components 81
KivyMD, Release 0.104.2.dev0
Bottom sheets are surfaces containing supplementary content that are anchored to the bottom of
the screen.
Two classes are available to you MDListBottomSheet and MDGridBottomSheet for standard bottom sheets
dialogs:
Usage MDListBottomSheet
KV = '''
Screen:
MDToolbar:
title: "Example BottomSheet"
pos_hint: {"top": 1}
(continues on next page)
82 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDRaisedButton:
text: "Open list bottom sheet"
on_release: app.show_example_list_bottom_sheet()
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
def show_example_list_bottom_sheet(self):
bottom_sheet_menu = MDListBottomSheet()
for i in range(1, 11):
bottom_sheet_menu.add_item(
f"Standart Item {i}",
lambda x, y=i: self.callback_for_menu_items(
f"Standart Item {y}"
),
)
bottom_sheet_menu.open()
Example().run()
The add_item method of the MDListBottomSheet class takes the following arguments:
text - element text;
callback - function that will be called when clicking on an item;
There is also an optional argument icon, which will be used as an icon to the left of the item:
2.3. Components 83
KivyMD, Release 0.104.2.dev0
KV = '''
Screen:
MDToolbar:
title: 'Example BottomSheet'
pos_hint: {"top": 1}
elevation: 10
MDRaisedButton:
text: "Open grid bottom sheet"
on_release: app.show_example_grid_bottom_sheet()
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
def show_example_grid_bottom_sheet(self):
bottom_sheet_menu = MDGridBottomSheet()
data = {
"Facebook": "facebook-box",
"YouTube": "youtube",
"Twitter": "twitter-box",
"Da Cloud": "cloud-upload",
"Camera": "camera",
}
for item in data.items():
bottom_sheet_menu.add_item(
item[0],
lambda x, y=item[0]: self.callback_for_menu_items(y),
icon_src=item[1],
)
bottom_sheet_menu.open()
Example().run()
84 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
KV = '''
<ItemForCustomBottomSheet@OneLineIconListItem>
on_press: app.custom_sheet.dismiss()
icon: ""
IconLeftWidget:
icon: root.icon
<ContentCustomSheet@BoxLayout>:
orientation: "vertical"
size_hint_y: None
height: "400dp"
MDToolbar:
title: 'Custom bottom sheet:'
ScrollView:
MDGridLayout:
cols: 1
adaptive_height: True
ItemForCustomBottomSheet:
icon: "page-previous"
text: "Preview"
ItemForCustomBottomSheet:
icon: "exit-to-app"
text: "Exit"
Screen:
MDToolbar:
title: 'Example BottomSheet'
pos_hint: {"top": 1}
elevation: 10
MDRaisedButton:
text: "Open custom bottom sheet"
on_release: app.show_example_custom_bottom_sheet()
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
custom_sheet = None
2.3. Components 85
KivyMD, Release 0.104.2.dev0
def show_example_custom_bottom_sheet(self):
self.custom_sheet = MDCustomBottomSheet(screen=Factory.ContentCustomSheet())
self.custom_sheet.open()
Example().run()
Note: When you use the MDCustomBottomSheet class, you must specify the height of the user-defined content
exactly, otherwise dp(100) heights will be used for your ContentCustomSheet class:
<ContentCustomSheet@BoxLayout>:
orientation: "vertical"
size_hint_y: None
height: "400dp"
Note: The height of the bottom sheet dialog will never exceed half the height of the screen!
API - kivymd.uix.bottomsheet
class kivymd.uix.bottomsheet.MDBottomSheet(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
background
Private attribute.
duration_opening
The duration of the bottom sheet dialog opening animation.
86 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
view.open(animation=False)
2.3. Components 87
KivyMD, Release 0.104.2.dev0
on_dismiss(self )
resize_content_layout(self, content, layout, interval=0)
class kivymd.uix.bottomsheet.MDCustomBottomSheet(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
screen
Custom content.
screen is an ObjectProperty and defaults to None.
class kivymd.uix.bottomsheet.MDListBottomSheet(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
sheet_list
sheet_list is an ObjectProperty and defaults to None.
add_item(self, text, callback, icon=None)
Parameters
• text – element text;
• callback – function that will be called when clicking on an item;
• icon – which will be used as an icon to the left of the item;
class kivymd.uix.bottomsheet.GridBottomSheetItem(**kwargs)
This mixin class provides Button behavior. Please see the button behaviors module documentation
for more information.
88 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Events
on_press Fired when the button is pressed.
on_release Fired when the button is released (i.e. the touch/click that pressed the button goes
away).
source
Icon path if you use a local image or icon name if you use icon names from a file kivymd/
icon_definitions.py.
source is an StringProperty and defaults to ‘’.
caption
Item text.
caption is an StringProperty and defaults to ‘’.
icon_size
Icon size.
caption is an StringProperty and defaults to ’32sp’.
class kivymd.uix.bottomsheet.MDGridBottomSheet(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
add_item(self, text, callback, icon_src)
Parameters
• text – element text;
• callback – function that will be called when clicking on an item;
• icon_src – icon item;
2.3.11 Snackbar
See also:
Material Design spec, Snackbars
2.3. Components 89
KivyMD, Release 0.104.2.dev0
Snackbars provide brief messages about app processes at the bottom of the screen.
Usage
KV = '''
#:import Snackbar kivymd.uix.snackbar.Snackbar
Screen:
MDRaisedButton:
text: "Create simple snackbar"
on_release: Snackbar(text="This is a snackbar!").open()
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
90 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
Snackbar(
text="This is a snackbar!",
snackbar_x="10dp",
snackbar_y="10dp",
size_hint_x=(
Window.width - (dp(10) * 2)
) / Window.width
).open()
Control width
Snackbar(
text="This is a snackbar!",
snackbar_x="10dp",
snackbar_y="10dp",
size_hint_x=.5
).open()
Snackbar(
text="[color=#ddbb34]This is a snackbar![/color]",
snackbar_y="10dp",
snackbar_y="10dp",
size_hint_x=.7
).open()
2.3. Components 91
KivyMD, Release 0.104.2.dev0
snackbar = Snackbar(
text="This is a snackbar!",
snackbar_x="10dp",
snackbar_y="10dp",
)
snackbar.size_hint_x = (
Window.width - (snackbar.snackbar_x * 2)
) / Window.width
snackbar.buttons = [
MDFlatButton(
text="UPDATE",
text_color=(1, 1, 1, 1),
on_release=snackbar.dismiss,
),
MDFlatButton(
text="CANCEL",
text_color=(1, 1, 1, 1),
on_release=snackbar.dismiss,
),
]
snackbar.open()
Snackbar(
...
bg_color=(0, 0, 1, 1),
).open()
Custom usage
92 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
KV = '''
Screen:
MDFloatingActionButton:
id: button
x: root.width - self.width - dp(10)
y: dp(10)
on_release: app.snackbar_show()
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
self.snackbar = None
self._interval = 0
def build(self):
return self.screen
def snackbar_show(self):
if not self.snackbar:
self.snackbar = Snackbar(text="This is a snackbar!")
self.snackbar.open()
anim = Animation(y=dp(72), d=.2)
anim.bind(on_complete=lambda *args: Clock.schedule_interval(
self.wait_interval, 0))
anim.start(self.screen.ids.button)
Test().run()
Custom Snackbar
2.3. Components 93
KivyMD, Release 0.104.2.dev0
MDIconButton:
pos_hint: {'center_y': .5}
icon: root.icon
opposite_colors: True
MDLabel:
id: text_bar
size_hint_y: None
height: self.texture_size[1]
text: root.text
font_size: root.font_size
theme_text_color: 'Custom'
text_color: get_color_from_hex('ffffff')
shorten: True
shorten_from: 'right'
pos_hint: {'center_y': .5}
Screen:
MDRaisedButton:
text: "SHOW"
pos_hint: {"center_x": .5, "center_y": .45}
on_press: app.show()
'''
class CustomSnackbar(BaseSnackbar):
text = StringProperty(None)
icon = StringProperty(None)
font_size = NumericProperty("15sp")
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
def show(self):
snackbar = CustomSnackbar(
text="This is a snackbar!",
icon="information",
snackbar_x="10dp",
snackbar_y="10dp",
buttons=[MDFlatButton(text="ACTION", text_color=(1, 1, 1, 1))]
)
snackbar.size_hint_x = (
Window.width - (snackbar.snackbar_x * 2)
) / Window.width
snackbar.open()
Test().run()
94 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.snackbar
class kivymd.uix.snackbar.Snackbar(**kwargs)
Snackbar inherits all its functionality from BaseSnackbar
text
The text that will appear in the snackbar.
text is a StringProperty and defaults to ‘’.
font_size
The font size of the text that will appear in the snackbar.
font_size is a NumericProperty and defaults to ’15sp’.
RelativeLayout class equivalent. Simplifies working with some widget properties. For example:
RelativeLayout
RelativeLayout:
canvas:
Color:
rgba: app.theme_cls.primary_color
RoundedRectangle:
pos: (0, 0)
size: self.size
radius: [25, ]
MDRelativeLayout
MDRelativeLayout:
radius: [25, ]
md_bg_color: app.theme_cls.primary_color
API - kivymd.uix.relativelayout
class kivymd.uix.relativelayout.MDRelativeLayout(**kw)
RelativeLayout class, see module documentation for more information.
2.3. Components 95
KivyMD, Release 0.104.2.dev0
FloatLayout class equivalent. Simplifies working with some widget properties. For example:
FloatLayout
FloatLayout:
canvas:
Color:
rgba: app.theme_cls.primary_color
RoundedRectangle:
pos: self.pos
size: self.size
radius: [25, 0, 0, 0]
MDFloatLayout
MDFloatLayout:
radius: [25, 0, 0, 0]
md_bg_color: app.theme_cls.primary_color
Warning: For a FloatLayout, the minimum_size attributes are always 0, so you cannot use
adaptive_size and related options.
API - kivymd.uix.floatlayout
class kivymd.uix.floatlayout.MDFloatLayout(**kwargs)
Float layout class. See module documentation for more information.
2.3.14 StackLayout
StackLayout class equivalent. Simplifies working with some widget properties. For example:
StackLayout
StackLayout:
size_hint_y: None
height: self.minimum_height
canvas:
Color:
rgba: app.theme_cls.primary_color
Rectangle:
pos: self.pos
size: self.size
96 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDStackLayout
MDStackLayout:
adaptive_height: True
md_bg_color: app.theme_cls.primary_color
• adaptive_height
• adaptive_width
• adaptive_size
adaptive_height
adaptive_height: True
Equivalent
size_hint_y: None
height: self.minimum_height
adaptive_width
adaptive_width: True
Equivalent
size_hint_x: None
width: self.minimum_width
adaptive_size
adaptive_size: True
Equivalent
2.3. Components 97
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.stacklayout
class kivymd.uix.stacklayout.MDStackLayout(**kwargs)
Stack layout class. See module documentation for more information.
2.3.15 Chip
See also:
Material Design spec, Chips
Usage
MDChip:
label: 'Coffee'
color: .4470588235118, .1960787254902, 0, 1
icon: 'coffee'
on_release: app.callback_for_menu_items(self)
The user function takes two arguments - the object and the text of the chip:
98 Chapter 2. Contents
KivyMD, Release 0.104.2.dev0
MDChip:
label: 'Kivy'
icon: 'data/logo/kivy-icon-256.png'
MDChip:
label: 'Without icon'
icon: ''
MDChip:
label: 'Check with icon'
icon: 'city'
check: True
Choose chip
MDChooseChip:
MDChip:
label: 'Earth'
icon: 'earth'
selected_chip_color: .21176470535294, .098039627451, 1, 1
MDChip:
label: 'Face'
icon: 'face'
selected_chip_color: .21176470535294, .098039627451, 1, 1
MDChip:
(continues on next page)
2.3. Components 99
KivyMD, Release 0.104.2.dev0
API - kivymd.uix.chip
class kivymd.uix.chip.MDChip(**kwargs)
This mixin class provides Button behavior. Please see the button behaviors module documentation
for more information.
Events
on_press Fired when the button is pressed.
on_release Fired when the button is released (i.e. the touch/click that pressed the button goes
away).
label
Chip text.
label is an StringProperty and defaults to ‘’.
icon
Chip icon.
icon is an StringProperty and defaults to ‘checkbox-blank-circle’.
color
Chip color in rgba format.
color is an ListProperty and defaults to [].
text_color
Chip’s text color in rgba format.
text_color is an ListProperty and defaults to [].
check
If True, a checkmark is added to the left when touch to the chip.
check is an BooleanProperty and defaults to False.
radius
Corner radius values.
radius is an NumericProperty and defaults to ‘12dp’.
selected_chip_color
The color of the chip that is currently selected in rgba format.
selected_chip_color is an ListProperty and defaults to [].
set_color(self, interval)
on_icon(self, instance, value)
on_touch_down(self, 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.
class kivymd.uix.chip.MDChooseChip(**kwargs)
Stack layout class. See module documentation for more information.
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
2.3.16 Dialog
See also:
Material Design spec, Dialogs
Dialogs inform users about a task and can contain critical information, require decisions, or involve
multiple tasks.
Usage
KV = '''
FloatLayout:
MDFlatButton:
text: "ALERT DIALOG"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_alert_dialog()
'''
class Example(MDApp):
dialog = None
def build(self):
return Builder.load_string(KV)
def show_alert_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
text="Discard draft?",
buttons=[
MDFlatButton(
text="CANCEL", text_color=self.theme_cls.primary_color
),
MDFlatButton(
text="DISCARD", text_color=self.theme_cls.primary_color
),
],
)
self.dialog.open()
Example().run()
API - kivymd.uix.dialog
class kivymd.uix.dialog.MDDialog(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
title
Title dialog.
self.dialog = MDDialog(
title="Reset settings?",
buttons=[
MDFlatButton(
text="CANCEL", text_color=self.theme_cls.primary_color
),
MDFlatButton(
text="ACCEPT", text_color=self.theme_cls.primary_color
),
],
)
self.dialog = MDDialog(
title="Reset settings?",
text="This will reset your device to its default factory settings.",
buttons=[
MDFlatButton(
text="CANCEL", text_color=self.theme_cls.primary_color
),
MDFlatButton(
text="ACCEPT", text_color=self.theme_cls.primary_color
),
],
)
self.dialog = MDDialog(
text="Discard draft?",
buttons=[
MDFlatButton(text="CANCEL"), MDRaisedButton(text="DISCARD"),
],
)
KV = '''
<Item>
ImageLeftWidget:
source: root.source
FloatLayout:
MDFlatButton:
text: "ALERT DIALOG"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_simple_dialog()
'''
class Item(OneLineAvatarListItem):
divider = None
source = StringProperty()
class Example(MDApp):
dialog = None
def build(self):
return Builder.load_string(KV)
(continues on next page)
def show_simple_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
title="Set backup account",
type="simple",
items=[
Item(text="[email protected]", source="user-1.png"),
Item(text="[email protected]", source="user-2.png"),
Item(text="Add account", source="add-icon.png"),
],
)
self.dialog.open()
Example().run()
KV = '''
<ItemConfirm>
on_release: root.set_icon(check)
CheckboxLeftWidget:
id: check
group: "check"
FloatLayout:
MDFlatButton:
text: "ALERT DIALOG"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_confirmation_dialog()
'''
class ItemConfirm(OneLineAvatarIconListItem):
divider = None
class Example(MDApp):
dialog = None
def build(self):
return Builder.load_string(KV)
def show_confirmation_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
title="Phone ringtone",
type="confirmation",
items=[
ItemConfirm(text="Callisto"),
ItemConfirm(text="Luna"),
ItemConfirm(text="Night"),
ItemConfirm(text="Solo"),
ItemConfirm(text="Phobos"),
ItemConfirm(text="Diamond"),
ItemConfirm(text="Sirena"),
ItemConfirm(text="Red music"),
ItemConfirm(text="Allergio"),
ItemConfirm(text="Magic"),
ItemConfirm(text="Tic-tac"),
],
buttons=[
MDFlatButton(
text="CANCEL", text_color=self.theme_cls.primary_color
(continues on next page)
Example().run()
KV = '''
<Content>
orientation: "vertical"
spacing: "12dp"
size_hint_y: None
height: "120dp"
MDTextField:
hint_text: "City"
MDTextField:
hint_text: "Street"
FloatLayout:
MDFlatButton:
text: "ALERT DIALOG"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_confirmation_dialog()
'''
class Content(BoxLayout):
pass
class Example(MDApp):
dialog = None
def build(self):
return Builder.load_string(KV)
def show_confirmation_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
title="Address:",
type="custom",
content_cls=Content(),
buttons=[
MDFlatButton(
text="CANCEL", text_color=self.theme_cls.primary_color
),
MDFlatButton(
text="OK", text_color=self.theme_cls.primary_color
),
(continues on next page)
Example().run()
create_buttons(self )
See also:
Material Design spec, Navigation drawer
When using the class MDNavigationDrawer skeleton of your KV markup should look like this:
Root:
NavigationLayout:
ScreenManager:
Screen_1:
Screen_2:
MDNavigationDrawer:
(continues on next page)
ContentNavigationDrawer
A simple example:
KV = '''
Screen:
NavigationLayout:
ScreenManager:
Screen:
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: "Navigation Drawer"
elevation: 10
left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_
˓→ drawer()]]
Widget:
MDNavigationDrawer:
id: nav_drawer
ContentNavigationDrawer:
'''
class ContentNavigationDrawer(BoxLayout):
pass
class TestNavigationDrawer(MDApp):
def build(self):
return Builder.load_string(KV)
TestNavigationDrawer().run()
Let’s extend the ContentNavigationDrawer class from the above example and create content for our
MDNavigationDrawer panel:
IconLeftWidget:
id: icon
icon: root.icon
theme_text_color: "Custom"
text_color: root.text_color
class ItemDrawer(OneLineIconListItem):
icon = StringProperty()
AnchorLayout:
anchor_x: "left"
size_hint_y: None
height: avatar.height
Image:
id: avatar
size_hint: None, None
size: "56dp", "56dp"
source: "kivymd.png"
MDLabel:
text: "KivyMD library"
font_style: "Button"
size_hint_y: None
height: self.texture_size[1]
MDLabel:
text: "[email protected]"
font_style: "Caption"
size_hint_y: None
height: self.texture_size[1]
ScrollView:
DrawerList:
id: md_list
class ContentNavigationDrawer(BoxLayout):
pass
(continues on next page)
# Set the color of the icon and text for the menu item.
for item in self.children:
if item.text_color == self.theme_cls.primary_color:
item.text_color = self.theme_cls.text_color
break
instance_item.text_color = self.theme_cls.primary_color
KV = '''
<ContentNavigationDrawer>:
MDList:
OneLineListItem:
text: "Screen 1"
on_press:
root.nav_drawer.set_state("close")
root.screen_manager.current = "scr 1"
OneLineListItem:
text: "Screen 2"
on_press:
root.nav_drawer.set_state("close")
root.screen_manager.current = "scr 2"
Screen:
MDToolbar:
id: toolbar
pos_hint: {"top": 1}
elevation: 10
title: "MDNavigationDrawer"
left_action_items: [["menu", lambda x: nav_drawer.set_state("open")]]
NavigationLayout:
x: toolbar.height
ScreenManager:
id: screen_manager
Screen:
name: "scr 1"
MDLabel:
text: "Screen 1"
halign: "center"
Screen:
name: "scr 2"
MDLabel:
text: "Screen 2"
halign: "center"
MDNavigationDrawer:
id: nav_drawer
ContentNavigationDrawer:
screen_manager: screen_manager
nav_drawer: nav_drawer
'''
class ContentNavigationDrawer(BoxLayout):
screen_manager = ObjectProperty()
(continues on next page)
class TestNavigationDrawer(MDApp):
def build(self):
return Builder.load_string(KV)
TestNavigationDrawer().run()
You can use the standard behavior type for the NavigationDrawer:
MDNavigationDrawer:
type: "standard"
See also:
Full example of Components-Navigation-Drawer
API - kivymd.uix.navigationdrawer
class kivymd.uix.navigationdrawer.NavigationLayout(**kwargs)
Float layout class. See module documentation for more information.
update_pos(self, *args)
add_scrim(self, widget)
update_scrim_rectangle(self, *args)
add_widget(self, widget, index=0, canvas=None)
Only two layouts are allowed: ScreenManager and MDNavigationDrawer.
class kivymd.uix.navigationdrawer.MDNavigationDrawer(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
type
Type of drawer. Modal type will be on top of screen. Standard type will be at left or right of screen.
Also it automatically disables close_on_click and enable_swiping to prevent closing drawer
for standard type.
type is a OptionProperty and defaults to modal.
anchor
Anchoring screen edge for drawer. Set it to ‘right’ for right-to-left languages. Available options are: ‘left’,
‘right’.
anchor is a OptionProperty and defaults to left.
close_on_click
Close when click on scrim or keyboard escape. It automatically sets to False for “standard” type.
close_on_click is a BooleanProperty and defaults to True.
state
Indicates if panel closed or opened. Sets after status change. Available options are: ‘close’, ‘open’.
state is a OptionProperty and defaults to ‘close’.
status
Detailed state. Sets before state. Bind to state instead of status. Available options
are: ‘closed’, ‘opening_with_swipe’, ‘opening_with_animation’, ‘opened’, ‘closing_with_swipe’, ‘clos-
ing_with_animation’.
status is a OptionProperty and defaults to ‘closed’.
open_progress
Percent of visible part of side panel. The percent is specified as a floating point number in the range 0-1.
0.0 if panel is closed and 1.0 if panel is opened.
open_progress is a NumericProperty and defaults to 0.0.
enable_swiping
Allow to open or close navigation drawer with swipe. It automatically sets to False for “standard” type.
enable_swiping is a BooleanProperty and defaults to True.
swipe_distance
The distance of the swipe with which the movement of navigation drawer begins.
swipe_distance is a NumericProperty and defaults to 10.
swipe_edge_width
The size of the area in px inside which should start swipe to drag navigation drawer.
swipe_edge_width is a NumericProperty and defaults to 20.
scrim_color
Color for scrim. Alpha channel will be multiplied with _scrim_alpha. Set fourth channel to 0 if you
want to disable scrim.
scrim_color is a ListProperty and defaults to [0, 0, 0, 0.5].
scrim_alpha_transition
The name of the animation transition type to use for changing scrim_alpha.
scrim_alpha_transition is a StringProperty and defaults to ‘linear’.
opening_transition
The name of the animation transition type to use when animating to the state ‘open’.
opening_transition is a StringProperty and defaults to ‘out_cubic’.
opening_time
The time taken for the panel to slide to the state ‘open’.
opening_time is a NumericProperty and defaults to 0.2.
closing_transition
The name of the animation transition type to use when animating to the state ‘close’.
closing_transition is a StringProperty and defaults to ‘out_sine’.
closing_time
The time taken for the panel to slide to the state ‘close’.
closing_time is a NumericProperty and defaults to 0.2.
set_state(self, new_state='toggle', animation=True)
Change state of the side panel. New_state can be one of “toggle”, “open” or “close”.
toggle_nav_drawer(self )
update_status(self, *_)
get_dist_from_side(self, x)
on_touch_down(self, 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.
on_touch_move(self, touch)
Receive a touch move event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_radius(self, instance, value)
on_type(self, *args)
See also:
Material Design spec, Navigation rail
Usage
MDNavigationRail:
MDNavigationRailItem:
MDNavigationRailItem:
MDNavigationRailItem:
KV = '''
#:import get_color_from_hex kivy.utils.get_color_from_hex
<MyTile@SmartTileWithStar>
size_hint_y: None
height: "240dp"
MDBoxLayout:
orientation: "vertical"
MDToolbar:
title: "MDNavigationRail"
md_bg_color: rail.md_bg_color
MDBoxLayout:
MDNavigationRailItem:
icon: "language-cpp"
text: "C++"
MDNavigationRailItem:
icon: "language-python"
text: "Python"
MDNavigationRailItem:
icon: "language-swift"
text: "Swift"
MDBoxLayout:
padding: "24dp"
ScrollView:
MDList:
id: box
cols: 3
spacing: "12dp"
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
for i in range(9):
tile = Factory.MyTile(source="cpp.png")
tile.stars = 5
self.root.ids.box.add_widget(tile)
Test().run()
API - kivymd.uix.navigationrail
class kivymd.uix.navigationrail.MDNavigationRail(**kwargs)
Events
on_action_button
use_hover_behavior
Whether to use the HoverBehavior effect for menu items.
MDNavigationRail:
use_hover_behavior: True
hover_bg: 0, 0, 0, .2
hover_bg
The background color for the menu item. Used when use_hover_behavior parameter is True.
use_resizeable
Allows you to change the width of the rail (open/close).
KV = '''
#:import get_color_from_hex kivy.utils.get_color_from_hex
<MyTile@SmartTileWithStar>
size_hint_y: None
height: "240dp"
MDBoxLayout:
orientation: "vertical"
MDToolbar:
title: "MDNavigationRail"
md_bg_color: rail.md_bg_color
left_action_items: [["menu", lambda x: app.rail_open()]]
MDBoxLayout:
MDNavigationRail:
id: rail
md_bg_color: get_color_from_hex("#344954")
color_normal: get_color_from_hex("#718089")
color_active: get_color_from_hex("#f3ab44")
use_resizeable: True
MDNavigationRailItem:
icon: "language-cpp"
text: "C++"
MDNavigationRailItem:
icon: "language-java"
text: "Java"
MDNavigationRailItem:
icon: "language-swift"
text: "Swift"
MDBoxLayout:
padding: "24dp"
ScrollView:
MDList:
id: box
cols: 3
spacing: "12dp"
(continues on next page)
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
def rail_open(self):
if self.root.ids.rail.rail_state == "open":
self.root.ids.rail.rail_state = "close"
else:
self.root.ids.rail.rail_state = "open"
def on_start(self):
for i in range(9):
tile = Factory.MyTile(source="kitten.png")
tile.stars = 5
self.root.ids.box.add_widget(tile)
Test().run()
MDNavigationRail:
use_resizeable: True
use_title: True
icon_title: "logo.png"
text_title: "[b][color=#ffffff]Example[/color][/b]"
MDNavigationRail:
use_action_button: True
action_text_button: "COMPOSE"
on_action_button: print(args)
action_icon_button
Icon of use_action_button.
action_icon_button is an StringProperty and defaults to ‘plus’.
action_text_button
Text of use_action_button.
action_text_button is an StringProperty and defaults to ‘’.
action_color_button
Text of use_action_button.
action_color_button is an ListProperty and defaults to [].
color_normal
Color normal of item menu.
color_normal is an ListProperty and defaults to [].
color_active
Color active of item menu.
color_active is an ListProperty and defaults to [].
visible
Item label visible type. Available options are: ‘Selected’, ‘Persistent’, ‘Unlabeled’.
MDNavigationRail:
visible: "Persistent"
MDNavigationRail:
visible: "Selected"
MDNavigationRail:
visible: "Unlabeled"
open(self )
close(self )
on_rail_state(self, instance, value)
on_item_switch(self, instance_item)
Called when the menu item is switched.
on_open(self )
Called when a rail is opened.
on_close(self )
Called when a rail is closed.
on_action_button(self, floating_action_button)
Called when the MDFloatingActionButton is pressed.
on_visible(self, instance, value)
on_use_title(self, instance, value)
on_use_resizeable(self, instance, value)
on_use_action_button(self, instance, value)
press_floating_action_button(self, floating_action_button)
set_action_color_button(self, interval)
set_width(self, interval)
set_box_title_size(self, interval)
set_action_icon_button(self, interval)
set_action_text_button(self, interval)
set_color_menu_item(self, instance_item)
set_items_color(self, interval)
set_items_visible(self, interval)
2.3.19 Banner
See also:
Material Design spec, Banner
Usage
Builder.load_string('''
<ExampleBanner@Screen>
MDBanner:
id: banner
text: ["One line string text example without actions."]
# The widget that is under the banner.
# It will be shifted down to the height of the banner.
over_widget: screen
vertical_pad: toolbar.height
MDToolbar:
id: toolbar
title: "Example Banners"
elevation: 10
pos_hint: {'top': 1}
BoxLayout:
id: screen
orientation: "vertical"
(continues on next page)
OneLineListItem:
text: "Banner without actions"
on_release: banner.show()
Widget:
''')
class Test(MDApp):
def build(self):
return Factory.ExampleBanner()
Test().run()
Banner type.
MDBanner:
text: ["One line string text example without actions."]
To use a two-line banner, specify the 'two-line' MDBanner.type for the banner and pass the list of two lines
to the MDBanner.text parameter:
MDBanner:
type: "two-line"
text:
["One line string text example without actions.", "This is the second line of
˓→the banner message."]
MDBanner:
type: "three-line"
text:
["One line string text example without actions.", "This is the second line of
˓→the banner message." "and this is the third line of the banner message."]
To add buttons to any type of banner, use the MDBanner.left_action and MDBanner.right_action pa-
rameters, which should take a list [‘Button name’, function]:
MDBanner:
text: ["One line string text example without actions."]
left_action: ["CANCEL", lambda x: None]
Or two buttons:
MDBanner:
text: ["One line string text example without actions."]
left_action: ["CANCEL", lambda x: None]
right_action: ["CLOSE", lambda x: None]
If you want to use the icon on the left in the banner, add the prefix ‘-icon’ to the banner type:
MDBanner:
type: "one-line-icon"
icon: f"{images_path}/kivymd.png"
text: ["One line string text example without actions."]
API - kivymd.uix.banner
class kivymd.uix.banner.MDBanner(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
vertical_pad
Indent the banner at the top of the screen.
vertical_pad is an NumericProperty and defaults to dp(68).
opening_transition
The name of the animation transition.
opening_transition is an StringProperty and defaults to ‘in_quad’.
icon
Icon banner.
icon is an StringProperty and defaults to ‘data/logo/kivy-icon-128.png’.
over_widget
The widget that is under the banner. It will be shifted down to the height of the banner.
over_widget is an ObjectProperty and defaults to None.
text
List of lines for banner text. Must contain no more than three lines for a ‘one-line’, ‘two-line’ and ‘three-
line’ banner, respectively.
text is an ListProperty and defaults to [].
left_action
The action of banner.
To add one action, make a list [‘name_action’, callback] where ‘name_action’ is a string that corresponds
to an action name and callback is the function called on a touch release event.
left_action is an ListProperty and defaults to [].
right_action
Works the same way as left_action.
right_action is an ListProperty and defaults to [].
type
Banner type. . Available options are: (“one-line”, “two-line”, “three-line”, “one-line-icon”, “two-line-
icon”, “three-line-icon”).
type is an OptionProperty and defaults to ‘one-line’.
add_actions_buttons(self, box, data)
set_left_action(self )
set_right_action(self )
set_type_banner(self )
add_banner_to_container(self )
show(self )
animation_display_banner(self, i)
hide(self )
See also:
Material Design spec, Image lists
SmartTileWithStar
KV = '''
<MyTile@SmartTileWithStar>
size_hint_y: None
height: "240dp"
ScrollView:
MDGridLayout:
cols: 3
adaptive_height: True
padding: dp(4), dp(4)
spacing: dp(4)
MyTile:
stars: 5
(continues on next page)
MyTile:
stars: 5
source: "cat-2.jpg"
MyTile:
stars: 5
source: "cat-3.jpg"
'''
class MyApp(MDApp):
def build(self):
return Builder.load_string(KV)
MyApp().run()
SmartTileWithLabel
KV = '''
<MyTile@SmartTileWithLabel>
size_hint_y: None
height: "240dp"
ScrollView:
MDGridLayout:
cols: 3
adaptive_height: True
padding: dp(4), dp(4)
spacing: dp(4)
MyTile:
source: "cat-1.jpg"
text: "[size=26]Cat 1[/size]\n[size=14]cat-1.jpg[/size]"
MyTile:
source: "cat-2.jpg"
text: "[size=26]Cat 2[/size]\n[size=14]cat-2.jpg[/size]"
tile_text_color: app.theme_cls.accent_color
MyTile:
source: "cat-3.jpg"
text: "[size=26][color=#ffffff]Cat 3[/color][/size]\n[size=14]cat-3.jpg[/
˓→size]"
tile_text_color: app.theme_cls.accent_color
'''
(continues on next page)
class MyApp(MDApp):
def build(self):
return Builder.load_string(KV)
MyApp().run()
API - kivymd.uix.imagelist
class kivymd.uix.imagelist.SmartTile(**kwargs)
A tile for more complex needs.
Includes an image, a container to place overlays and a box that can act as a header or a footer, as described in
the Material Design specs.
box_color
Sets the color and opacity for the information box.
box_color is a ListProperty and defaults to (0, 0, 0, 0.5).
box_position
Determines wether the information box acts as a header or footer to the image. Available are options:
‘footer’, ‘header’.
box_position is a OptionProperty and defaults to ‘footer’.
lines
Number of lines in the header/footer. As per Material Design specs, only 1 and 2 are valid values. Avail-
able are options: 1, 2.
lines is a OptionProperty and defaults to 1.
overlap
Determines if the header/footer overlaps on top of the image or not.
overlap is a BooleanProperty and defaults to True.
source
Path to tile image. See source.
source is a StringProperty and defaults to ‘’.
reload(self )
class kivymd.uix.imagelist.SmartTileWithLabel(**kwargs)
A tile for more complex needs.
Includes an image, a container to place overlays and a box that can act as a header or a footer, as described in
the Material Design specs.
font_style
Tile font style.
font_style is a StringProperty and defaults to ‘Caption’.
tile_text_color
Tile text color in rgba format.
tile_text_color is a StringProperty and defaults to (1, 1, 1, 1).
text
Determines the text for the box footer/header.
text is a StringProperty and defaults to ‘’.
class kivymd.uix.imagelist.SmartTileWithStar(**kwargs)
A tile for more complex needs.
Includes an image, a container to place overlays and a box that can act as a header or a footer, as described in
the Material Design specs.
stars
Tile stars.
stars is a NumericProperty and defaults to 1.
on_stars(self, *args)
2.3.21 Backdrop
See also:
Material Design spec, Backdrop
Usage
<Root>:
MDBackdrop:
MDBackdropBackLayer:
ContentForBackdropBackLayer:
MDBackdropFrontLayer:
ContentForBackdropFrontLayer:
Example
# Your layouts.
Builder.load_string(
'''
#:import Window kivy.core.window.Window
#:import IconLeftWidget kivymd.uix.list.IconLeftWidget
<ItemBackdropFrontLayer@TwoLineAvatarListItem>
icon: "android"
IconLeftWidget:
icon: root.icon
<MyBackdropFrontLayer@ItemBackdropFrontLayer>
backdrop: None
text: "Lower the front layer"
secondary_text: " by 50 %"
icon: "transfer-down"
on_press: root.backdrop.open(-Window.height / 2)
pos_hint: {"top": 1}
_no_ripple_effect: True
<MyBackdropBackLayer@Image>
size_hint: .8, .8
source: "data/logo/kivy-icon-512.png"
pos_hint: {"center_x": .5, "center_y": .6}
'''
)
MDBackdrop:
id: backdrop
left_action_items: [['menu', lambda x: self.open()]]
title: "Example Backdrop"
radius_left: "25dp"
radius_right: "0dp"
header_text: "Menu:"
MDBackdropBackLayer:
MyBackdropBackLayer:
id: backlayer
MDBackdropFrontLayer:
MyBackdropFrontLayer:
backdrop: backdrop
'''
)
class ExampleBackdrop(Screen):
pass
class TestBackdrop(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def build(self):
return ExampleBackdrop()
TestBackdrop().run()
API - kivymd.uix.backdrop
class kivymd.uix.backdrop.MDBackdrop(**kwargs)
Events
padding
Padding for contents of the front layer.
padding is an ListProperty and defaults to [0, 0, 0, 0].
left_action_items
The icons and methods left of the kivymd.uix.toolbar.MDToolbar in back layer. For more infor-
mation, see the kivymd.uix.toolbar.MDToolbar module and left_action_items parame-
ter.
left_action_items is an ListProperty and defaults to [].
right_action_items
Works the same way as left_action_items.
right_action_items is an ListProperty and defaults to [].
title
See the kivymd.uix.toolbar.MDToolbar.title parameter.
title is an StringProperty and defaults to ‘’.
back_layer_color
Background color of back layer.
back_layer_color is an ListProperty and defaults to [].
front_layer_color
Background color of front layer.
front_layer_color is an ListProperty and defaults to [].
radius_left
The value of the rounding radius of the upper left corner of the front layer.
radius_left is an NumericProperty and defaults to 16dp.
radius_right
The value of the rounding radius of the upper right corner of the front layer.
radius_right is an NumericProperty and defaults to 16dp.
header
Whether to use a header above the contents of the front layer.
header is an BooleanProperty and defaults to True.
header_text
Text of header.
header_text is an StringProperty and defaults to ‘Header’.
close_icon
The name of the icon that will be installed on the toolbar on the left when opening the front layer.
close_icon is an StringProperty and defaults to ‘close’.
on_open(self )
When the front layer drops.
on_close(self )
When the front layer rises.
on_left_action_items(self, instance, value)
on_header(self, instance, value)
open(self, open_up_to=0)
Opens the front layer.
Open_up_to the height to which the front screen will be lowered; if equal to zero - falls to the
bottom of the screen;
close(self )
Opens the front layer.
animtion_icon_menu(self )
animtion_icon_close(self, instance_animation, instance_icon_menu)
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
class kivymd.uix.backdrop.MDBackdropToolbar(**kwargs)
Events
on_action_button Method for the button used for the MDBottomAppBar class.
class kivymd.uix.backdrop.MDBackdropFrontLayer(**kwargs)
Box layout class. See module documentation for more information.
class kivymd.uix.backdrop.MDBackdropBackLayer(**kwargs)
Box layout class. See module documentation for more information.
2.3.22 Card
See also:
Material Design spec, Cards
Note: MDCard inherited from BoxLayout. You can use all parameters and attributes of the BoxLayout class in
the MDCard class.
MDCard
KV = '''
Screen:
MDCard:
size_hint: None, None
size: "280dp", "180dp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class TestCard(MDApp):
def build(self):
return Builder.load_string(KV)
TestCard().run()
KV = '''
Screen:
MDCard:
orientation: "vertical"
(continues on next page)
MDLabel:
text: "Title"
theme_text_color: "Secondary"
size_hint_y: None
height: self.texture_size[1]
MDSeparator:
height: "1dp"
MDLabel:
text: "Body"
'''
class TestCard(MDApp):
def build(self):
return Builder.load_string(KV)
TestCard().run()
MDCardSwipe
To create a card with swipe-to-delete behavior, you must create a new class that inherits from the MDCardSwipe
class:
<SwipeToDeleteItem>:
size_hint_y: None
height: content.height
MDCardSwipeLayerBox:
MDCardSwipeFrontBox:
OneLineListItem:
id: content
text: root.text
_no_ripple_effect: True
class SwipeToDeleteItem(MDCardSwipe):
text = StringProperty()
KV = '''
<SwipeToDeleteItem>:
size_hint_y: None
height: content.height
MDCardSwipeLayerBox:
# Content under the card.
MDCardSwipeFrontBox:
# Content of card.
OneLineListItem:
id: content
text: root.text
_no_ripple_effect: True
Screen:
BoxLayout:
orientation: "vertical"
spacing: "10dp"
MDToolbar:
elevation: 10
title: "MDCardSwipe"
ScrollView:
scroll_timeout : 100
MDList:
id: md_list
padding: 0
'''
class SwipeToDeleteItem(MDCardSwipe):
'''Card with `swipe-to-delete` behavior.'''
text = StringProperty()
(continues on next page)
class TestCard(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
return self.screen
def on_start(self):
'''Creates a list of cards.'''
for i in range(20):
self.screen.ids.md_list.add_widget(
SwipeToDeleteItem(text=f"One-line item {i}")
)
TestCard().run()
<SwipeToDeleteItem>:
# By default, the parameter is "left"
anchor: "right"
Note: You cannot use the left and right swipe at the same time.
Swipe behavior
<SwipeToDeleteItem>:
# By default, the parameter is "hand"
type_swipe: "hand"
<SwipeToDeleteItem>:
type_swipe: "auto"
The map provides the MDCardSwipe.on_swipe_complete event. You can use this event to remove items from
a list:
<SwipeToDeleteItem>:
on_swipe_complete: app.on_swipe_complete(root)
KV = '''
<SwipeToDeleteItem>:
size_hint_y: None
height: content.height
type_swipe: "auto"
on_swipe_complete: app.on_swipe_complete(root)
MDCardSwipeLayerBox:
MDCardSwipeFrontBox:
OneLineListItem:
id: content
text: root.text
_no_ripple_effect: True
Screen:
BoxLayout:
orientation: "vertical"
spacing: "10dp"
MDToolbar:
elevation: 10
title: "MDCardSwipe"
ScrollView:
MDList:
id: md_list
padding: 0
'''
class SwipeToDeleteItem(MDCardSwipe):
(continues on next page)
class TestCard(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
return self.screen
def on_start(self):
for i in range(20):
self.screen.ids.md_list.add_widget(
SwipeToDeleteItem(text=f"One-line item {i}")
)
TestCard().run()
To add content to the bottom layer of the card, use the MDCardSwipeLayerBox class.
<SwipeToDeleteItem>:
MDCardSwipeLayerBox:
padding: "8dp"
MDIconButton:
icon: "trash-can"
pos_hint: {"center_y": .5}
on_release: app.remove_item(root)
KV = '''
<SwipeToDeleteItem>:
size_hint_y: None
height: content.height
MDCardSwipeLayerBox:
(continues on next page)
MDIconButton:
icon: "trash-can"
pos_hint: {"center_y": .5}
on_release: app.remove_item(root)
MDCardSwipeFrontBox:
OneLineListItem:
id: content
text: root.text
_no_ripple_effect: True
Screen:
BoxLayout:
orientation: "vertical"
spacing: "10dp"
MDToolbar:
elevation: 10
title: "MDCardSwipe"
ScrollView:
MDList:
id: md_list
padding: 0
'''
class SwipeToDeleteItem(MDCardSwipe):
text = StringProperty()
class TestCard(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
return self.screen
def on_start(self):
for i in range(20):
self.screen.ids.md_list.add_widget(
SwipeToDeleteItem(text=f"One-line item {i}")
)
TestCard().run()
Focus behavior
MDCard:
focus_behavior: True
Ripple behavior
MDCard:
ripple_behavior: True
KV = '''
<StarButton@MDIconButton>
icon: "star"
on_release: self.icon = "star-outline" if self.icon == "star" else "star"
Screen:
MDCard:
orientation: "vertical"
size_hint: .5, None
height: box_top.height + box_bottom.height
focus_behavior: True
ripple_behavior: True
pos_hint: {"center_x": .5, "center_y": .5}
MDBoxLayout:
id: box_top
spacing: "20dp"
adaptive_height: True
FitImage:
source: "/Users/macbookair/album.jpeg"
size_hint: .3, None
height: text_box.height
MDBoxLayout:
id: text_box
orientation: "vertical"
adaptive_height: True
(continues on next page)
MDLabel:
text: "Ride the Lightning"
theme_text_color: "Primary"
font_style: "H5"
bold: True
size_hint_y: None
height: self.texture_size[1]
MDLabel:
text: "July 27, 1984"
size_hint_y: None
height: self.texture_size[1]
theme_text_color: "Primary"
MDSeparator:
MDBoxLayout:
id: box_bottom
adaptive_height: True
padding: "10dp", 0, 0, 0
MDLabel:
text: "Rate this album"
size_hint_y: None
height: self.texture_size[1]
pos_hint: {"center_y": .5}
theme_text_color: "Primary"
StarButton:
StarButton:
StarButton:
StarButton:
StarButton:
'''
class Test(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
Test().run()
API - kivymd.uix.card
class kivymd.uix.card.MDSeparator(**kwargs)
A separator line.
color
Separator color in rgba format.
color is a ListProperty and defaults to [].
on_orientation(self, *args)
class kivymd.uix.card.MDCard(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
background
Background image path.
background is a StringProperty and defaults to ‘’.
focus_behavior
Using focus when hovering over a card.
focus_behavior is a BooleanProperty and defaults to False.
ripple_behavior
Use ripple effect for card.
ripple_behavior is a BooleanProperty and defaults to False.
elevation
Elevation value.
elevation is an NumericProperty and defaults to 1.
update_md_bg_color(self, instance, value)
on_radius(self, instance, value)
class kivymd.uix.card.MDCardSwipe(**kw)
Events
open_progress
Percent of visible part of side panel. The percent is specified as a floating point number in the range 0-1.
0.0 if panel is closed and 1.0 if panel is opened.
open_progress is a NumericProperty and defaults to 0.0.
opening_transition
The name of the animation transition type to use when animating to the state ‘opened’.
opening_transition is a StringProperty and defaults to ‘out_cubic’.
closing_transition
The name of the animation transition type to use when animating to the state ‘closed’.
closing_transition is a StringProperty and defaults to ‘out_sine’.
anchor
Anchoring screen edge for card. Available options are: ‘left’, ‘right’.
anchor is a OptionProperty and defaults to left.
swipe_distance
The distance of the swipe with which the movement of navigation drawer begins.
swipe_distance is a NumericProperty and defaults to 50.
opening_time
The time taken for the card to slide to the state ‘open’.
opening_time is a NumericProperty and defaults to 0.2.
state
Detailed state. Sets before state. Bind to state instead of status. Available options are: ‘closed’,
‘opened’.
status is a OptionProperty and defaults to ‘closed’.
max_swipe_x
If, after the events of on_touch_up card position exceeds this value - will automatically execute the
method open_card, and if not - will automatically be close_card method.
max_swipe_x is a NumericProperty and defaults to 0.3.
max_opened_x
The value of the position the card shifts to when type_swipe s set to ‘hand’.
max_opened_x is a NumericProperty and defaults to 100dp.
type_swipe
Type of card opening when swipe. Shift the card to the edge or to a set position max_opened_x.
Available options are: ‘auto’, ‘hand’.
type_swipe is a OptionProperty and defaults to auto.
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
on_swipe_complete(self, *args)
Called when a swipe of card is completed.
on_anchor(self, instance, value)
on_open_progress(self, instance, value)
on_touch_move(self, touch)
Receive a touch move event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_touch_down(self, 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.
complete_swipe(self )
open_card(self )
close_card(self )
class kivymd.uix.card.MDCardSwipeFrontBox(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
class kivymd.uix.card.MDCardSwipeLayerBox(**kwargs)
Box layout class. See module documentation for more information.
See also:
Material Design spec, Selection controls
MDCheckbox
KV = '''
FloatLayout:
MDCheckbox:
size_hint: None, None
size: "48dp", "48dp"
pos_hint: {'center_x': .5, 'center_y': .5}
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Note: Be sure to specify the size of the checkbox. By default, it is (dp(48), dp(48)), but the ripple effect takes
up all the available space.
Control state
MDCheckbox:
on_active: app.on_checkbox_active(*args)
KV = '''
<Check@MDCheckbox>:
group: 'group'
(continues on next page)
FloatLayout:
Check:
active: True
pos_hint: {'center_x': .4, 'center_y': .5}
Check:
pos_hint: {'center_x': .6, 'center_y': .5}
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
MDSwitch
KV = '''
FloatLayout:
MDSwitch:
pos_hint: {'center_x': .5, 'center_y': .5}
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Note: For MDSwitch size is not required. By default it is (dp(36), dp(48)), but you can increase the width if
you want.
MDSwitch:
width: dp(64)
API - kivymd.uix.selectioncontrol
class kivymd.uix.selectioncontrol.MDCheckbox(**kwargs)
Class implements a circular ripple effect.
active
Indicates if the checkbox is active or inactive.
active is a BooleanProperty and defaults to False.
checkbox_icon_normal
Background icon of the checkbox used for the default graphical representation when the checkbox is not
pressed.
checkbox_icon_normal is a StringProperty and defaults to ‘checkbox-blank-outline’.
checkbox_icon_down
Background icon of the checkbox used for the default graphical representation when the checkbox is
pressed.
checkbox_icon_down is a StringProperty and defaults to ‘checkbox-marked’.
radio_icon_normal
Background icon (when using the group option) of the checkbox used for the default graphical represen-
tation when the checkbox is not pressed.
radio_icon_normal is a StringProperty and defaults to ‘checkbox-blank-circle-outline’.
radio_icon_down
Background icon (when using the group option) of the checkbox used for the default graphical represen-
tation when the checkbox is pressed.
radio_icon_down is a StringProperty and defaults to ‘checkbox-marked-circle’.
selected_color
Selected color in rgba format.
selected_color is a ListProperty and defaults to [].
unselected_color
Unelected color in rgba format.
unselected_color is a ListProperty and defaults to [].
disabled_color
Disabled color in rgba format.
disabled_color is a ListProperty and defaults to [].
update_primary_color(self, instance, value)
update_icon(self, *args)
update_color(self, *args)
on_state(self, *args)
on_active(self, *args)
class kivymd.uix.selectioncontrol.MDSwitch(**kwargs)
This mixin class provides Button behavior. Please see the button behaviors module documentation
for more information.
Events
on_press Fired when the button is pressed.
on_release Fired when the button is released (i.e. the touch/click that pressed the button goes
away).
active
Indicates if the switch is active or inactive.
active is a BooleanProperty and defaults to False.
thumb_color
Get thumb color rgba format.
thumb_color is an AliasProperty and property is readonly.
thumb_color_disabled
Get thumb color disabled rgba format.
thumb_color_disabled is an AliasProperty and property is readonly.
thumb_color_down
Get thumb color down rgba format.
thumb_color_down is an AliasProperty and property is readonly.
on_size(self, *args)
See also:
Material Design spec, Bottom navigation
Usage
<Root>>:
MDBottomNavigation:
MDBottomNavigationItem:
name: "screen 1"
YourContent:
MDBottomNavigationItem:
name: "screen 2"
YourContent:
MDBottomNavigationItem:
name: "screen 3"
YourContent:
<Root>>:
ScreenManager:
Screen:
name: "screen 1"
YourContent:
Screen:
name: "screen 2"
YourContent:
(continues on next page)
Screen:
name: "screen 3"
YourContent:
Example
class Test(MDApp):
def build(self):
self.theme_cls.primary_palette = "Gray"
return Builder.load_string(
'''
BoxLayout:
orientation:'vertical'
MDToolbar:
title: 'Bottom navigation'
md_bg_color: .2, .2, .2, 1
specific_text_color: 1, 1, 1, 1
MDBottomNavigation:
panel_color: .2, .2, .2, 1
MDBottomNavigationItem:
name: 'screen 1'
text: 'Python'
icon: 'language-python'
MDLabel:
text: 'Python'
halign: 'center'
MDBottomNavigationItem:
name: 'screen 2'
text: 'C++'
icon: 'language-cpp'
MDLabel:
text: 'I programming of C++'
halign: 'center'
MDBottomNavigationItem:
name: 'screen 3'
text: 'JS'
icon: 'language-javascript'
MDLabel:
text: 'JS'
(continues on next page)
Test().run()
__events__ = (
"on_tab_touch_down",
"on_tab_touch_move",
"on_tab_touch_up",
"on_tab_press",
"on_tab_release",
)
See also:
See __events__
Root:
MDBottomNavigation:
MDBottomNavigationItem:
on_tab_touch_down: print("on_tab_touch_down")
on_tab_touch_move: print("on_tab_touch_move")
on_tab_touch_up: print("on_tab_touch_up")
on_tab_press: print("on_tab_press")
on_tab_release: print("on_tab_release")
YourContent:
Use method switch_tab which takes as argument the name of the tab you want to switch to.
MDBottomNavigation:
text_color_active: 1, 0, 1, 1
MDBottomNavigation:
text_color_normal: 1, 0, 1, 1
See also:
See Tab auto switch example
See full example
API - kivymd.uix.bottomnavigation
class kivymd.uix.bottomnavigation.MDTab(**kwargs)
A tab is simply a screen with meta information that defines the content that goes in the tab header.
text
Tab header text.
text is an StringProperty and defaults to ‘’.
icon
Tab header icon.
icon is an StringProperty and defaults to ‘checkbox-blank-circle’.
on_tab_touch_down(self, *args)
on_tab_touch_move(self, *args)
on_tab_touch_up(self, *args)
on_tab_press(self, *args)
on_tab_release(self, *args)
class kivymd.uix.bottomnavigation.MDBottomNavigationItem(**kwargs)
A tab is simply a screen with meta information that defines the content that goes in the tab header.
header
header is an MDBottomNavigationHeader and defaults to None.
on_tab_press(self, *args)
on_leave(self, *args)
class kivymd.uix.bottomnavigation.TabbedPanelBase(**kwargs)
A class that contains all variables a TabPannel must have. It is here so I (zingballyhoo) don’t get mad about
the TabbedPannels not being DRY.
current
Current tab name.
current is an StringProperty and defaults to None.
previous_tab
previous_tab is an MDTab and defaults to None.
panel_color
Panel color of bottom navigation.
panel_color is an ListProperty and defaults to [].
tabs
class kivymd.uix.bottomnavigation.MDBottomNavigation(**kwargs)
A bottom navigation that is implemented by delegating all items to a ScreenManager.
first_widget
first_widget is an MDBottomNavigationItem and defaults to None.
tab_header
tab_header is an MDBottomNavigationHeader and defaults to None.
text_color_normal
Text color of the label when it is not selected.
text_color_normal is an ListProperty and defaults to [1, 1, 1, 1].
text_color_active
Text color of the label when it is selected.
text_color_active is an ListProperty and defaults to [1, 1, 1, 1].
on_panel_color(self, instance, value)
on_text_color_normal(self, instance, value)
on_text_color_active(self, instance, value)
switch_tab(self, name_tab)
Switching the tab by name.
refresh_tabs(self )
Refresh all tabs.
on_size(self, *args)
on_resize(self, instance=None, width=None, do_again=True)
Called when the application window is resized.
add_widget(self, widget, **kwargs)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
remove_widget(self, widget)
Remove a widget from the children of this widget.
Parameters
widget: Widget Widget to remove from our children list.
>>> from kivy.uix.button import Button
>>> root = Widget()
>>> button = Button()
>>> root.add_widget(button)
>>> root.remove_widget(button)
2.3.25 Label
• MDLabel
• MDIcon
MDLabel
Class MDLabel inherited from the Label class but for MDLabel the text_size parameter is (self.width,
None) and default is positioned on the left:
from kivy.lang import Builder
KV = '''
Screen:
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "MDLabel"
MDLabel:
text: "MDLabel"
(continues on next page)
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
MDLabel:
text: "MDLabel"
halign: "center"
MDLabel color:
KV = '''
Screen:
BoxLayout:
id: box
orientation: "vertical"
MDToolbar:
title: "MDLabel"
'''
class Test(MDApp):
def build(self):
screen = Builder.load_string(KV)
# Names of standard color themes.
for name_theme in [
"Primary",
"Secondary",
"Hint",
"Error",
"ContrastParentBackground",
]:
screen.ids.box.add_widget(
(continues on next page)
Test().run()
To use a custom color for MDLabel, use a theme ‘Custom’. After that, you can specify the desired color in the rgba
format in the text_color parameter:
MDLabel:
text: "Custom color"
halign: "center"
theme_text_color: "Custom"
text_color: 0, 0, 1, 1
MDLabel provides standard font styles for labels. To do this, specify the name of the desired style in the
font_style parameter:
KV = '''
Screen:
BoxLayout:
orientation: "vertical"
ScrollView:
MDList:
id: box
'''
class Test(MDApp):
def build(self):
screen = Builder.load_string(KV)
# Names of standard font styles.
for name_style in theme_font_styles[:-1]:
screen.ids.box.add_widget(
MDLabel(
text=f"{name_style} style",
halign="center",
font_style=name_style,
)
)
return screen
Test().run()
MDIcon
You can use labels to display material design icons using the MDIcon class.
See also:
Material Design Icons
Material Design Icon Names
The MDIcon class is inherited from MDLabel and has the same parameters.
Warning: For the MDIcon class, you cannot use text and font_style options!
MDIcon:
halign: "center"
icon: "language-python"
API - kivymd.uix.label
class kivymd.uix.label.MDLabel(**kwargs)
Label class, see module documentation for more information.
Events
on_ref_press Fired when the user clicks on a word referenced with a [ref] tag in a text
markup.
font_style
Label font style.
Available vanilla font_style are: ‘H1’, ‘H2’, ‘H3’, ‘H4’, ‘H5’, ‘H6’, ‘Subtitle1’, ‘Subtitle2’, ‘Body1’,
‘Body2’, ‘Button’, ‘Caption’, ‘Overline’, ‘Icon’.
font_style is an StringProperty and defaults to ‘Body1’.
text
Text of the label.
theme_text_color
Label color scheme name.
Available options are: ‘Primary’, ‘Secondary’, ‘Hint’, ‘Error’, ‘Custom’, ‘ContrastParentBackground’.
theme_text_color is an OptionProperty and defaults to None.
text_color
Label text color in rgba format.
text_color is an ListProperty and defaults to None.
parent_background
can_capitalize
check_font_styles(self, *dt)
update_font_style(self, *args)
on_theme_text_color(self, instance, value)
on_text_color(self, *args)
on_opposite_colors(self, instance, value)
class kivymd.uix.label.MDIcon(**kwargs)
Label class, see module documentation for more information.
Events
on_ref_press Fired when the user clicks on a word referenced with a [ref] tag in a text
markup.
icon
Label icon name.
icon is an StringProperty and defaults to ‘android’.
source
Path to icon.
source is an StringProperty and defaults to None.
2.3.26 Menu
See also:
Material Design spec, Menus
Usage
KV = '''
Screen:
MDRaisedButton:
id: button
text: "PRESS ME"
pos_hint: {"center_x": .5, "center_y": .5}
on_release: app.menu.open()
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
menu_items = [{"text": f"Item {i}"} for i in range(5)]
self.menu = MDDropdownMenu(
caller=self.screen.ids.button,
(continues on next page)
def build(self):
return self.screen
Test().run()
Warning: Do not create the MDDropdownMenu object when you open the menu window. Because on a mobile
device this one will be very slow!
Wrong
You must create a new class that inherits from the RightContent class:
class RightContentCls(RightContent):
pass
Now in the KV rule you can create your own elements that will be displayed in the menu item on the right:
<RightContentCls>
disabled: True
MDIconButton:
icon: root.icon
user_font_size: "16sp"
pos_hint: {"center_y": .5}
MDLabel:
text: root.text
font_style: "Caption"
size_hint_x: None
width: self.texture_size[0]
text_size: None, None
Now create menu items as usual, but add the key right_content_cls whose value is the class
RightContentCls that you created:
menu_items = [
{
"right_content_cls": RightContentCls(
text=f"R+{i}", icon="apple-keyboard-command",
),
"icon": "git",
"text": f"Item {i}",
}
for i in range(5)
]
self.menu = MDDropdownMenu(
caller=self.screen.ids.button, items=menu_items, width_mult=4
)
Full example
KV = '''
<RightContentCls>
disabled: True
MDIconButton:
icon: root.icon
user_font_size: "16sp"
pos_hint: {"center_y": .5}
MDLabel:
text: root.text
font_style: "Caption"
size_hint_x: None
width: self.texture_size[0]
text_size: None, None
Screen:
MDRaisedButton:
id: button
text: "PRESS ME"
pos_hint: {"center_x": .5, "center_y": .5}
on_release: app.menu.open()
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
menu_items = [
{
"right_content_cls": RightContentCls(
text=f"R+{i}", icon="apple-keyboard-command",
),
"icon": "git",
"text": f"Item {i}",
}
for i in range(5)
]
self.menu = MDDropdownMenu(
caller=self.screen.ids.button, items=menu_items, width_mult=4
)
self.menu.bind(on_release=self.menu_callback)
def build(self):
return self.screen
Test().run()
If you do not want to use the icons in the menu items on the left, then do not use the “icon” key when creating menu
items:
menu_items = [
{
"right_content_cls": RightContentCls(
text=f"R+{i}", icon="apple-keyboard-command",
),
"text": f"Item {i}",
}
for i in range(5)
]
menu_items = [
{
"right_content_cls": RightContentCls(
text=f"R+{i}", icon="apple-keyboard-command",
),
"text": f"Item {i}",
"height": "36dp",
"top_pad": "10dp",
"bot_pad": "10dp",
}
for i in range(5)
]
Mixin items
KV = '''
<RightContentCls>
disabled: True
MDIconButton:
icon: root.icon
user_font_size: "16sp"
pos_hint: {"center_y": .5}
MDLabel:
text: root.text
font_style: "Caption"
size_hint_x: None
width: self.texture_size[0]
text_size: None, None
Screen:
MDRaisedButton:
id: button
text: "PRESS ME"
pos_hint: {"center_x": .5, "center_y": .5}
on_release: app.menu.open()
'''
class RightContentCls(RightContent):
pass
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
menu_items = []
data = [
{"": "Open"},
{},
{"open-in-app": "Open in app >"},
{"trash-can-outline": "Move to Trash"},
{"rename-box": "Rename"},
{"zip-box-outline": "Create zip"},
{},
{"": "Properties"},
]
def build(self):
return self.screen
Test().run()
Hover Behavior
self.menu = MDDropdownMenu(
...,
...,
selected_color=self.theme_cls.primary_dark_hue,
)
Create submenu
KV = '''
Screen:
MDRaisedButton:
id: button
text: "PRESS ME"
pos_hint: {"center_x": .5, "center_y": .5}
on_release: app.menu.open()
'''
class Test(MDApp):
submenu = None
def build(self):
return self.screen
Test().run()
Warning: The MDDropdownMenu does not work with the standard MDToolbar. You can use your own
CustomToolbar and bind the menu window output to its elements.
KV = '''
<CustomToolbar>:
size_hint_y: None
height: self.theme_cls.standard_increment
padding: "5dp"
spacing: "12dp"
MDIconButton:
id: button_1
icon: "menu"
pos_hint: {"center_y": .5}
on_release: app.menu_1.open()
MDLabel:
text: "MDDropdownMenu"
pos_hint: {"center_y": .5}
size_hint_x: None
width: self.texture_size[0]
text_size: None, None
font_style: 'H6'
Widget:
MDIconButton:
id: button_2
icon: "dots-vertical"
pos_hint: {"center_y": .5}
on_release: app.menu_2.open()
Screen:
CustomToolbar:
id: toolbar
elevation: 10
pos_hint: {"top": 1}
'''
class CustomToolbar(
ThemableBehavior, RectangularElevationBehavior, MDBoxLayout,
):
(continues on next page)
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
self.menu_1 = self.create_menu(
"Button menu", self.screen.ids.toolbar.ids.button_1,
)
self.menu_2 = self.create_menu(
"Button dots", self.screen.ids.toolbar.ids.button_2,
)
def build(self):
return self.screen
Test().run()
Position menu
Bottom position
See also:
position
KV = '''
Screen
MDTextField:
id: field
pos_hint: {'center_x': .5, 'center_y': .5}
size_hint_x: None
width: "200dp"
(continues on next page)
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
menu_items = [{"icon": "git", "text": f"Item {i}"} for i in range(5)]
self.menu = MDDropdownMenu(
caller=self.screen.ids.field,
items=menu_items,
position="bottom",
width_mult=4,
)
self.menu.bind(on_release=self.set_item)
def build(self):
return self.screen
Test().run()
Center position
KV = '''
Screen
MDDropDownItem:
id: drop_item
pos_hint: {'center_x': .5, 'center_y': .5}
text: 'Item 0'
on_release: app.menu.open()
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
menu_items = [{"icon": "git", "text": f"Item {i}"} for i in range(5)]
(continues on next page)
def build(self):
return self.screen
Test().run()
API - kivymd.uix.menu
class kivymd.uix.menu.RightContent(**kwargs)
Same as IRightBody, but allows the widget to receive touch events instead of triggering the ListItem’s
ripple effect
text
Text item.
text is a StringProperty and defaults to ‘’.
icon
Icon item.
icon is a StringProperty and defaults to ‘’.
class kivymd.uix.menu.MDDropdownMenu(**kwargs)
Events
selected_color
Custom color (rgba format) for list item when hover behavior occurs.
selected_color is a ListProperty and defaults to [].
items
See data.
items is a ListProperty and defaults to [].
width_mult
This number multiplied by the standard increment (56dp on mobile, 64dp on desktop, determines the width
of the menu items.
If the resulting number were to be too big for the application Window, the multiplier will be adjusted for
the biggest possible one.
width_mult is a NumericProperty and defaults to 1.
max_height
The menu will grow no bigger than this number. Set to 0 for no limit.
max_height is a NumericProperty and defaults to 0.
border_margin
Margin between Window border and menu.
border_margin is a NumericProperty and defaults to 4dp.
ver_growth
Where the menu will grow vertically to when opening. Set to None to let the widget pick for you. Available
options are: ‘up’, ‘down’.
ver_growth is a OptionProperty and defaults to None.
hor_growth
Where the menu will grow horizontally to when opening. Set to None to let the widget pick for you.
Available options are: ‘left’, ‘right’.
hor_growth is a OptionProperty and defaults to None.
background_color
Color of the background of the menu.
background_color is a ListProperty and defaults to [].
opening_transition
Type of animation for opening a menu window.
opening_transition is a StringProperty and defaults to ‘out_cubic’.
opening_time
Menu window opening animation time and you can set it to 0 if you don’t want animation of menu opening.
opening_time is a NumericProperty and defaults to 0.2.
caller
The widget object that caller the menu window.
caller is a ObjectProperty and defaults to None.
position
Menu window position relative to parent element. Available options are: ‘auto’, ‘center’, ‘bottom’.
position is a OptionProperty and defaults to ‘auto’.
radius
Menu radius.
radius is a NumericProperty and defaults to ‘7’.
check_position_caller(self, instance, width, height)
set_bg_color_items(self, instance_selected_item)
Called when a Hover Behavior event occurs for a list item.
create_menu_items(self )
Creates menu items.
set_menu_properties(self, interval=0)
Sets the size and position for the menu window.
open(self )
Animate the opening of a menu window.
on_touch_down(self, 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.
on_touch_move(self, touch)
Receive a touch move event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_enter(self, instance)
Call when mouse enter the bbox of the item of menu.
on_leave(self, instance)
Call when the mouse exit the item of menu.
on_release(self, *args)
The method that will be called when you click menu items.
on_dismiss(self )
Called when the menu is closed.
dismiss(self )
Closes the menu.
2.3.27 Toolbar
See also:
Material Design spec, App bars: top
Material Design spec, App bars: bottom
Top
KV = '''
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "MDToolbar"
MDLabel:
text: "Content"
halign: "center"
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
MDToolbar:
title: "MDToolbar"
left_action_items: [["menu", lambda x: app.callback()]]
MDToolbar:
title: "MDToolbar"
right_action_items: [["dots-vertical", lambda x: app.callback()]]
MDToolbar:
title: "MDToolbar"
right_action_items: [["dots-vertical", lambda x: app.callback_1()], ["clock",
˓→lambda x: app.callback_2()]]
MDToolbar:
title: "MDToolbar"
md_bg_color: app.theme_cls.accent_color
MDToolbar:
title: "MDToolbar"
specific_text_color: app.theme_cls.accent_color
MDToolbar:
title: "Elevation 10"
elevation: 10
Bottom
Usage
KV = '''
BoxLayout:
MDToolbar:
title: "Title"
icon: "git"
type: "bottom"
left_action_items: [["menu", lambda x: x]]
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Event on_action_button:
MDBottomAppBar:
MDToolbar:
title: "Title"
icon: "git"
type: "bottom"
left_action_items: [["menu", lambda x: x]]
on_action_button: app.callback(self.icon)
Mode:
• ’free-end’
• ’free-center’
• ’end’
• ’center’
MDBottomAppBar:
MDToolbar:
title: "Title"
icon: "git"
type: "bottom"
left_action_items: [["menu", lambda x: x]]
mode: "end"
MDBottomAppBar:
MDToolbar:
title: "Title"
icon: "git"
type: "bottom"
left_action_items: [["menu", lambda x: x]]
mode: "free-end"
See also:
Components-Bottom-App-Bar
API - kivymd.uix.toolbar
class kivymd.uix.toolbar.MDActionBottomAppBarButton(**kwargs)
Abstract base class for all round buttons, bringing in the appropriate on-touch behavior
class kivymd.uix.toolbar.MDToolbar(**kwargs)
Events
on_action_button Method for the button used for the MDBottomAppBar class.
elevation
Elevation value.
elevation is an NumericProperty and defaults to 6.
left_action_items
The icons on the left of the toolbar. To add one, append a list like the following:
where ‘icon_name’ is a string that corresponds to an icon definition and callback is the function called
on a touch release event.
left_action_items is an ListProperty and defaults to [].
right_action_items
The icons on the left of the toolbar. Works the same way as left_action_items.
right_action_items is an ListProperty and defaults to [].
title
Text toolbar.
title is an StringProperty and defaults to ‘’.
md_bg_color
Color toolbar.
md_bg_color is an ListProperty and defaults to [0, 0, 0, 0].
anchor_title
Position toolbar title. Available options are: ‘left’, ‘center’, ‘right’.
anchor_title is an OptionProperty and defaults to ‘left’.
mode
Floating button position. Only for MDBottomAppBar class. Available options are: ‘free-end’, ‘free-
center’, ‘end’, ‘center’.
mode is an OptionProperty and defaults to ‘center’.
round
Rounding the corners at the notch for a button. Onle for MDBottomAppBar class.
round is an NumericProperty and defaults to ‘10dp’.
icon
Floating button. Onle for MDBottomAppBar class.
icon is an StringProperty and defaults to ‘android’.
icon_color
Color action button. Onle for MDBottomAppBar class.
icon_color is an ListProperty and defaults to [].
type
When using the MDBottomAppBar class, the parameter type must be set to ‘bottom’:
MDBottomAppBar:
MDToolbar:
type: "bottom"
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
2.3.28 Screen
Screen class equivalent. Simplifies working with some widget properties. For example:
Screen
Screen:
canvas:
Color:
rgba: app.theme_cls.primary_color
RoundedRectangle:
pos: self.pos
size: self.size
radius: [25, 0, 0, 0]
MDScreen
MDScreen:
radius: [25, 0, 0, 0]
md_bg_color: app.theme_cls.primary_color
API - kivymd.uix.screen
class kivymd.uix.screen.MDScreen(**kw)
Screen is an element intended to be used with a ScreenManager. Check module documentation for more
information.
Events
on_pre_enter: () Event fired when the screen is about to be used: the entering animation is
started.
on_enter: () Event fired when the screen is displayed: the entering animation is complete.
on_pre_leave: () Event fired when the screen is about to be removed: the leaving animation is
started.
on_leave: () Event fired when the screen is removed: the leaving animation is finished.
Changed in version 1.6.0: Events on_pre_enter, on_enter, on_pre_leave and on_leave were added.
2.3.29 DataTables
See also:
Material Design spec, DataTables
Warning: Data tables are still far from perfect. Errors are possible and we hope you inform us about them.
API - kivymd.uix.datatables
class kivymd.uix.datatables.MDDataTable(**kwargs)
Events
on_row_press Called when a table row is clicked.
on_check_press Called when the check box in the table row is checked.
class Example(MDApp):
def build(self):
layout = AnchorLayout()
self.data_tables = MDDataTable(
size_hint=(0.7, 0.6),
use_pagination=True,
check=True,
(continues on next page)
],
sorted_on="Schedule",
sorted_order="ASC",
elevation=2
)
self.data_tables.bind(on_row_press=self.on_row_press)
self.data_tables.bind(on_check_press=self.on_check_press)
layout.add_widget(self.data_tables)
return layout
print(instance_table, instance_row)
print(instance_table, current_row)
Example().run()
column_data
Data for header columns.
class Example(MDApp):
def build(self):
layout = AnchorLayout()
self.data_tables = MDDataTable(
size_hint=(0.7, 0.6),
use_pagination=True,
check=True,
Example().run()
Note: The functions which will be called for sorting must accept a data argument and return the sorted
data.
Incoming data format will be similar to the provided row_data except that it’ll be all list instead of tuple
like below. Any icon provided initially will also be there in this data so handle accordingly.
[
['1', ['icon', 'No Signal'], 'Astrid: NE shared managed', 'Medium',
˓→ 'Triaged', '0:33', 'Chase Nguyen'],
['2', 'Offline', 'Cosmo: prod shared ares', 'Huge', 'Triaged', '0:39',
˓→'Brie Furman'],
You must sort inner lists in ascending order and return the sorted data in the same format.
row_data
Data for rows. To add icon in addition to a row data, include a tuple with (“icon-name”, [icon-color],
“row-data”). See example below.
from kivy.metrics import dp
from kivy.uix.anchorlayout import AnchorLayout
class Example(MDApp):
def build(self):
layout = AnchorLayout()
data_tables = MDDataTable(
(continues on next page)
Example().run()
class Example(MDApp):
def build(self):
layout = AnchorLayout()
data_tables = MDDataTable(
size_hint=(0.9, 0.6),
use_pagination=True,
column_data=[
("No.", dp(30)),
("Column 1", dp(30)),
("Column 2", dp(30)),
("Column 3", dp(30)),
("Column 4", dp(30)),
("Column 5", dp(30)),
],
row_data=[
(f"{i + 1}", "1", "2", "3", "4", "5") for i in range(50)
],
)
layout.add_widget(data_tables)
return layout
Example().run()
Center
Auto
140dp
240dp
class Example(MDApp):
def build(self):
layout = AnchorLayout()
data_tables = MDDataTable(
size_hint=(0.9, 0.6),
use_pagination=True,
column_data=[
("No.", dp(30)),
("Column 1", dp(30)),
("[color=#52251B]Column 2[/color]", dp(30)),
("Column 3", dp(30)),
("[size=24][color=#C042B8]Column 4[/color][/size]", dp(30)),
("Column 5", dp(30)),
],
row_data=[
(
f"{i + 1}",
"[color=#297B50]1[/color]",
"[color=#C552A1]2[/color]",
"[color=#6C9331]3[/color]",
"4",
"5",
)
for i in range(50)
],
)
layout.add_widget(data_tables)
return layout
Example().run()
2.3.30 Slider
See also:
Material Design spec, Sliders
KV = '''
Screen
MDSlider:
min: 0
max: 100
value: 40
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
MDSlider:
min: 0
max: 100
value: 40
hint: False
MDSlider:
min: 0
max: 100
value: 40
hint: False
humb_color_down: app.theme_cls.accent_color
API - kivymd.uix.slider
class kivymd.uix.slider.MDSlider(**kwargs)
Class for creating a Slider widget.
Check module documentation for more details.
active
If the slider is clicked.
active is an BooleanProperty and defaults to False.
hint
If True, then the current value is displayed above the slider.
hint is an BooleanProperty and defaults to True.
hint_bg_color
Hint rectangle color in rgba format.
hint_bg_color is an ListProperty and defaults to [].
hint_text_color
Hint text color in rgba format.
hint_text_color is an ListProperty and defaults to [].
hint_radius
Hint radius.
hint_radius is an NumericProperty and defaults to 4.
show_off
Show the ‘off’ ring when set to minimum value.
show_off is an BooleanProperty and defaults to True.
thumb_color
Current color slider in rgba format.
thumb_color is an AliasProperty that returns the value of the current color slider, property is
readonly.
thumb_color_down
Color slider in rgba format.
thumb_color_down is an AliasProperty that returns and set the value of color slider.
on_hint(self, instance, value)
on_value_normalized(self, *args)
When the value == min set it to ‘off’ state and make slider a ring.
on_show_off(self, *args)
on__is_off(self, *args)
on_active(self, *args)
on_touch_down(self, 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.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
2.3.31 Pickers
MDTimePicker
Usage
KV = '''
FloatLayout:
MDRaisedButton:
text: "Open time picker"
pos_hint: {'center_x': .5, 'center_y': .5}
on_release: app.show_time_picker()
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
def show_time_picker(self):
'''Open time picker dialog.'''
time_dialog = MDTimePicker()
time_dialog.open()
Test().run()
def show_time_picker(self):
time_dialog = MDTimePicker()
time_dialog.bind(time=self.get_time)
time_dialog.open()
return time
def show_time_picker(self):
from datetime import datetime
MDDatePicker
When creating an instance of the MDDatePicker class, you must pass as a parameter a method that will take one
argument - a datetime object.
def show_date_picker(self):
date_dialog = MDDatePicker(callback=self.get_date)
date_dialog.open()
def show_date_picker(self):
date_dialog = MDDatePicker(
callback=self.get_date,
year=2010,
month=2,
day=12,
)
date_dialog.open()
You can set the time interval from and to the set date. All days of the week that are not included in this range will have
def show_date_picker(self):
min_date = datetime.strptime("2020:02:15", '%Y:%m:%d').date()
max_date = datetime.strptime("2020:02:20", '%Y:%m:%d').date()
date_dialog = MDDatePicker(
callback=self.get_date,
min_date=min_date,
max_date=max_date,
)
date_dialog.open()
MDThemePicker
def show_theme_picker(self):
theme_dialog = MDThemePicker()
theme_dialog.open()
API - kivymd.uix.picker
return time
close_cancel(self )
close_ok(self )
class kivymd.uix.picker.MDThemePicker(**kwargs)
Float layout class. See module documentation for more information.
See also:
Material Design spec, Progress indicators
Progress indicators express an unspecified wait time or display the length of a process.
• Indeterminate
MDProgressBar
KV = '''
BoxLayout:
padding: "10dp"
MDProgressBar:
value: 50
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Vertical orientation
MDProgressBar:
orientation: "vertical"
value: 50
MDProgressBar:
value: 50
color: app.theme_cls.accent_color
Indeterminate
KV = '''
Screen:
MDProgressBar:
id: progress
pos_hint: {"center_y": .6}
type: "indeterminate"
MDRaisedButton:
text: "STOP" if app.state == "start" else "START"
pos_hint: {"center_x": .5, "center_y": .45}
on_press: app.state = "stop" if app.state == "start" else "start"
'''
class Test(MDApp):
state = StringProperty("stop")
def build(self):
return Builder.load_string(KV)
Test().run()
Determinate
MDProgressBar:
type: "determinate"
running_duration: 1
catching_duration: 1.5
API - kivymd.uix.progressbar
class kivymd.uix.progressbar.MDProgressBar(**kwargs)
Class for creating a progress bar widget.
See module documentation for more details.
reversed
Reverse the direction the progressbar moves.
reversed is an BooleanProperty and defaults to False.
orientation
Orientation of progressbar. Available options are: ‘horizontal ‘, ‘vertical’.
orientation is an OptionProperty and defaults to ‘horizontal’.
color
Progress bar color in rgba format.
color is an OptionProperty and defaults to [].
running_transition
Running transition.
running_transition is an StringProperty and defaults to ‘in_cubic’.
catching_transition
Catching transition.
catching_transition is an StringProperty and defaults to ‘out_quart’.
running_duration
Running duration.
running_duration is an NumericProperty and defaults to 0.5.
catching_duration
Catching duration.
running_duration is an NumericProperty and defaults to 0.8.
type
Type of progressbar. Available options are: ‘indeterminate ‘, ‘determinate’.
type is an OptionProperty and defaults to None.
start(self )
Start animation.
stop(self )
Stop animation.
running_away(self, *args)
catching_up(self, *args)
Usage
KV = '''
Screen
MDDropDownItem:
id: drop_item
pos_hint: {'center_x': .5, 'center_y': .5}
text: 'Item'
on_release: self.set_item("New Item")
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
return self.screen
Test().run()
See also:
Work with the class MDDropdownMenu see here
API - kivymd.uix.dropdownitem
class kivymd.uix.dropdownitem.MDDropDownItem(**kwargs)
Class implements a rectangular ripple effect.
text
Text item.
text is a StringProperty and defaults to ‘’.
current_item
Current name item.
current_item is a StringProperty and defaults to ‘’.
font_size
Item font size.
font_size is a NumericProperty and defaults to ’16sp’.
on_text(self, instance, value)
set_item(self, name_item)
Sets new text for an item.
2.3.34 Tooltip
See also:
Material Design spec, Tooltips
Tooltips display informative text when users hover over, focus on, or tap an element.
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:
Warning: MDTooltip only works correctly with button and label classes.
KV = '''
<TooltipMDIconButton@MDIconButton+MDTooltip>
Screen:
TooltipMDIconButton:
(continues on next page)
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
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
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 ‘’.
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 [5,].
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.
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.
2.3.35 List
See also:
Material Design spec, Lists
The class MDList in combination with a BaseListItem like OneLineListItem will create a list that expands
as items are added to it, working nicely with Kivy’s ScrollView.
Due to the variety in sizes and controls in the Material Design spec, this module suffers from a certain level of
complexity to keep the widgets compliant, flexible and performant.
For this KivyMD provides list items that try to cover the most common usecases, when those are insufficient, there’s
a base class called BaseListItem which you can use to create your own list items. This documentation will only
cover the provided ones, for custom implementations please refer to this module’s source code.
KivyMD provides the following list items classes for use:
• OneLineListItem
• TwoLineListItem
• ThreeLineListItem
These widgets will take other widgets that inherit from ILeftBody, ILeftBodyTouch, IRightBody or
IRightBodyTouch and put them in their corresponding container.
As the name implies, ILeftBody and IRightBody will signal that the widget goes into the left or right container,
respectively.
ILeftBodyTouch and IRightBodyTouch do the same thing, except these widgets will also receive touch events
that occur within their surfaces.
KivyMD provides base classes such as ImageLeftWidget, ImageRightWidget, IconRightWidget,
IconLeftWidget, based on the above classes.
• OneLineAvatarListItem
• TwoLineAvatarListItem
• ThreeLineAvatarListItem
• OneLineIconListItem
• TwoLineIconListItem
• ThreeLineIconListItem
It allows the use of elements with custom widgets on the left and the right.
• OneLineAvatarIconListItem
• TwoLineAvatarIconListItem
• ThreeLineAvatarIconListItem
Usage
KV = '''
ScrollView:
MDList:
id: container
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
for i in range(20):
self.root.ids.container.add_widget(
OneLineListItem(text=f"Single-line item {i}")
)
Test().run()
Events of List
KV = '''
ScrollView:
MDList:
OneLineAvatarIconListItem:
on_release: print("Click!")
IconLeftWidget:
icon: "github"
OneLineAvatarIconListItem:
on_release: print("Click 2!")
IconLeftWidget:
icon: "gitlab"
'''
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
MainApp().run()
OneLineListItem
OneLineListItem:
text: "Single-line item"
TwoLineListItem
TwoLineListItem:
text: "Two-line item"
secondary_text: "Secondary text here"
ThreeLineListItem
ThreeLineListItem:
text: "Three-line item"
secondary_text: "This is a multi-line label where you can"
tertiary_text: "fit more text than usual"
OneLineAvatarListItem
OneLineAvatarListItem:
text: "Single-line item with avatar"
ImageLeftWidget:
source: "data/logo/kivy-icon-256.png"
TwoLineAvatarListItem
TwoLineAvatarListItem:
text: "Two-line item with avatar"
secondary_text: "Secondary text here"
ImageLeftWidget:
source: "data/logo/kivy-icon-256.png"
ThreeLineAvatarListItem
ThreeLineAvatarListItem:
text: "Three-line item with avatar"
secondary_text: "Secondary text here"
tertiary_text: "fit more text than usual"
ImageLeftWidget:
source: "data/logo/kivy-icon-256.png"
OneLineIconListItem
OneLineAvatarListItem:
text: "Single-line item with avatar"
IconLeftWidget:
icon: "language-python"
TwoLineIconListItem
TwoLineIconListItem:
text: "Two-line item with avatar"
secondary_text: "Secondary text here"
IconLeftWidget:
icon: "language-python"
ThreeLineIconListItem
ThreeLineIconListItem:
text: "Three-line item with avatar"
secondary_text: "Secondary text here"
tertiary_text: "fit more text than usual"
IconLeftWidget:
icon: "language-python"
OneLineAvatarIconListItem
OneLineAvatarIconListItem:
text: "One-line item with avatar"
IconLeftWidget:
icon: "plus"
IconRightWidget:
icon: "minus"
TwoLineAvatarIconListItem
TwoLineAvatarIconListItem:
text: "Two-line item with avatar"
secondary_text: "Secondary text here"
IconLeftWidget:
icon: "plus"
IconRightWidget:
icon: "minus"
ThreeLineAvatarIconListItem
ThreeLineAvatarIconListItem:
text: "Three-line item with avatar"
secondary_text: "Secondary text here"
tertiary_text: "fit more text than usual"
IconLeftWidget:
icon: "plus"
IconRightWidget:
icon: "minus"
KV = '''
<ListItemWithCheckbox>:
IconLeftWidget:
icon: root.icon
RightCheckbox:
BoxLayout:
ScrollView:
MDList:
id: scroll
'''
class ListItemWithCheckbox(OneLineAvatarIconListItem):
'''Custom list item.'''
icon = StringProperty("android")
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
icons = list(md_icons.keys())
for i in range(30):
self.root.ids.scroll.add_widget(
ListItemWithCheckbox(text=f"Item {i}", icon=icons[i])
)
MainApp().run()
KV = '''
OneLineAvatarIconListItem:
text: "One-line item with avatar"
on_size:
self.ids._right_container.width = container.width
self.ids._right_container.x = container.width
IconLeftWidget:
icon: "cog"
Container:
id: container
MDIconButton:
icon: "minus"
MDIconButton:
icon: "plus"
'''
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
MainApp().run()
API - kivymd.uix.list
class kivymd.uix.list.MDList(**kwargs)
ListItem container. Best used in conjunction with a kivy.uix.ScrollView.
When adding (or removing) a widget, it will resize itself to fit its children, plus top and bottom paddings as
described by the MD spec.
add_widget(self, widget, index=0, canvas=None)
Add a new widget as a child of this widget.
Parameters
widget: Widget Widget to add to our list of children.
index: int, defaults to 0 Index to insert the widget in the list. Notice that the default
of 0 means the widget is inserted at the beginning of the list and will thus be drawn
on top of other sibling widgets. For a full discussion of the index and widget hier-
archy, please see the Widgets Programming Guide.
New in version 1.0.5.
canvas: str, defaults to None Canvas to add widget’s canvas to. Can be ‘before’,
‘after’ or None for the default canvas.
New in version 1.9.0.
remove_widget(self, widget)
Remove a widget from the children of this widget.
Parameters
widget: Widget Widget to remove from our children list.
class kivymd.uix.list.BaseListItem(**kwargs)
Base class to all ListItems. Not supposed to be instantiated on its own.
text
Text shown in the first line.
text is a StringProperty and defaults to ‘’.
text_color
Text color in rgba format used if theme_text_color is set to ‘Custom’.
text_color is a ListProperty and defaults to None.
font_style
Text font style. See kivymd.font_definitions.py.
class kivymd.uix.list.IRightBody
Pseudo-interface for widgets that go in the right container for ListItems that support it.
Implements nothing and requires no implementation, for annotation only.
class kivymd.uix.list.IRightBodyTouch
Same as IRightBody, but allows the widget to receive touch events instead of triggering the ListItem’s
ripple effect
class kivymd.uix.list.ContainerSupport
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
add_widget(self, widget, index=0)
remove_widget(self, widget)
on_touch_down(self, touch)
on_touch_move(self, touch, *args)
on_touch_up(self, touch)
propagate_touch_to_touchable_widgets(self, touch, touch_event, *args)
class kivymd.uix.list.OneLineListItem(**kwargs)
A one line list item.
class kivymd.uix.list.TwoLineListItem(**kwargs)
A two line list item.
class kivymd.uix.list.ThreeLineListItem(**kwargs)
A three line list item.
class kivymd.uix.list.OneLineAvatarListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.TwoLineAvatarListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.ThreeLineAvatarListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.OneLineIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.TwoLineIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.ThreeLineIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.OneLineRightIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.TwoLineRightIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.ThreeLineRightIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.OneLineAvatarIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.TwoLineAvatarIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.ThreeLineAvatarIconListItem(**kwargs)
Overrides add_widget in a ListItem to include support for I*Body widgets when the appropiate con-
tainers are present.
class kivymd.uix.list.ImageLeftWidget(**kwargs)
Pseudo-interface for widgets that go in the left container for ListItems that support it.
Implements nothing and requires no implementation, for annotation only.
class kivymd.uix.list.ImageRightWidget(**kwargs)
Same as IRightBody, but allows the widget to receive touch events instead of triggering the ListItem’s
ripple effect
class kivymd.uix.list.IconRightWidget(**kwargs)
Same as IRightBody, but allows the widget to receive touch events instead of triggering the ListItem’s
ripple effect
class kivymd.uix.list.IconLeftWidget(**kwargs)
Same as ILeftBody, but allows the widget to receive touch events instead of triggering the ListItem’s ripple
effect.
class kivymd.uix.list.CheckboxLeftWidget(**kwargs)
Same as ILeftBody, but allows the widget to receive touch events instead of triggering the ListItem’s ripple
effect.
See also:
Material Design spec, Text fields
Note: MDTextField inherited from TextInput. Therefore, most parameters and all events of the TextInput
class are also available in the MDTextField class.
MDTextField
MDTextField:
hint_text: "No helper text"
MDTextField:
hint_text: "Helper text on focus"
helper_text: "This will disappear when you click off"
helper_text_mode: "on_focus"
MDTextField:
hint_text: "Persistent helper text"
helper_text: "Text is always here"
helper_text_mode: "persistent"
To display an error in a text field when using the helper_text_mode: "on_error" parameter, set the “error”
text field parameter to True:
from kivy.lang import Builder
KV = '''
BoxLayout:
padding: "10dp"
MDTextField:
id: text_field_error
hint_text: "Helper text on error (press 'Enter')"
helper_text: "There will always be a mistake"
helper_text_mode: "on_error"
pos_hint: {"center_y": .5}
'''
class Test(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_string(KV)
def build(self):
self.screen.ids.text_field_error.bind(
on_text_validate=self.set_error_message,
on_focus=self.set_error_message,
)
return self.screen
Test().run()
MDTextField:
hint_text: "required = True"
required: True
helper_text_mode: "on_error"
helper_text: "Enter text"
MDTextField:
hint_text: "Max text length = 5"
max_text_length: 5
MDTextField:
multiline: True
hint_text: "Multi-line text"
Color mode
MDTextField:
hint_text: "color_mode = 'accent'"
color_mode: 'accent'
MDTextField:
hint_text: "color_mode = 'custom'"
color_mode: 'custom'
helper_text_mode: "on_focus"
helper_text: "Color is defined by 'line_color_focus' property"
line_color_focus: 1, 0, 1, 1
MDTextField:
hint_text: "Line color normal"
line_color_normal: app.theme_cls.accent_color
Rectangle mode
MDTextField:
hint_text: "Rectangle mode"
mode: "rectangle"
Fill mode
MDTextField:
hint_text: "Fill mode"
mode: "fill"
fill_color: 0, 0, 0, .4
MDTextFieldRect
Note: MDTextFieldRect inherited from TextInput. You can use all parameters and attributes of the
TextInput class in the MDTextFieldRect class.
MDTextFieldRect:
size_hint: 1, None
height: "30dp"
MDTextFieldRound
Without icon
MDTextFieldRound:
hint_text: 'Empty field'
Warning: The icons in the MDTextFieldRound are static. You cannot bind events to them.
MDTextFieldRound:
icon_left: "email"
hint_text: "Field with left icon"
MDTextFieldRound:
icon_left: 'key-variant'
icon_right: 'eye-off'
hint_text: 'Field with left and right icons'
MDTextFieldRound:
icon_left: 'key-variant'
normal_color: app.theme_cls.accent_color
MDTextFieldRound:
icon_left: 'key-variant'
normal_color: app.theme_cls.accent_color
color_active: 1, 0, 0, 1
KV = '''
<ClickableTextFieldRound>:
size_hint_y: None
height: text_field.height
MDTextFieldRound:
id: text_field
hint_text: root.hint_text
text: root.text
password: True
color_active: app.theme_cls.primary_light
icon_left: "key-variant"
padding:
self._lbl_icon_left.texture_size[1] + dp(10) if self.icon_left else
˓→dp(15), (self.height / 2) - (self.line_height / 2),
˓→self._lbl_icon_right.texture_size[1] + dp(20), 0
MDIconButton:
icon: "eye-off"
ripple_scale: .5
pos_hint: {"center_y": .5}
pos: text_field.width - self.width + dp(8), 0
on_release:
self.icon = "eye" if self.icon == "eye-off" else "eye-off"
text_field.password = False if text_field.password is True else True
MDScreen:
ClickableTextFieldRound:
size_hint_x: None
width: "300dp"
hint_text: "Password"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class ClickableTextFieldRound(MDRelativeLayout):
text = StringProperty()
hint_text = StringProperty()
# Here specify the required parameters for MDTextFieldRound:
# [...]
class Test(MDApp):
def build(self):
(continues on next page)
Test().run()
Note: The icon on the right is available for use in all text fields.
MDTextField:
hint_text: "Name"
mode: "fill"
fill_color: 0, 0, 0, .4
icon_right: "arrow-down-drop-circle-outline"
icon_right_color: app.theme_cls.primary_color
MDTextField:
hint_text: "Name"
icon_right: "arrow-down-drop-circle-outline"
icon_right_color: app.theme_cls.primary_color
MDTextField:
hint_text: "Name"
mode: "rectangle"
icon_right: "arrow-down-drop-circle-outline"
icon_right_color: app.theme_cls.primary_color
See also:
See more information in the MDTextFieldRect class.
API - kivymd.uix.textfield
class kivymd.uix.textfield.MDTextFieldRect(**kwargs)
TextInput class. See module documentation for more information.
Events
on_text_validate Fired only in multiline=False mode when the user hits ‘enter’. This will also
unfocus the textinput.
on_double_tap Fired when a double tap happens in the text input. The default behavior selects
the text around the cursor position. More info at on_double_tap().
on_triple_tap Fired when a triple tap happens in the text input. The default behavior selects the
line around the cursor position. More info at on_triple_tap().
on_quad_touch Fired when four fingers are touching the text input. The default behavior selects
the whole text. More info at on_quad_touch().
Warning: When changing a TextInput property that requires re-drawing, e.g. modifying the text, the
updates occur on the next clock cycle and not instantly. This might cause any changes to the TextInput
that occur between the modification and the next cycle to be ignored, or to use previous values. For example,
after a update to the text, changing the cursor in the same clock frame will move it using the previous text
and will likely end up in an incorrect position. The solution is to schedule any updates to occur on the next
clock cycle using schedule_once().
Note: Selection is cancelled when TextInput is focused. If you need to show selection when TextInput is fo-
cused, you should delay (use Clock.schedule) the call to the functions for selecting text (select_all, select_text).
on_quad_touch Fired when four fingers are touching the text input. The default behavior selects
the whole text. More info at on_quad_touch().
Warning: When changing a TextInput property that requires re-drawing, e.g. modifying the text, the
updates occur on the next clock cycle and not instantly. This might cause any changes to the TextInput
that occur between the modification and the next cycle to be ignored, or to use previous values. For example,
after a update to the text, changing the cursor in the same clock frame will move it using the previous text
and will likely end up in an incorrect position. The solution is to schedule any updates to occur on the next
clock cycle using schedule_once().
Note: Selection is cancelled when TextInput is focused. If you need to show selection when TextInput is fo-
cused, you should delay (use Clock.schedule) the call to the functions for selecting text (select_all, select_text).
line_anim
If True, then text field shows animated line when on focus.
line_anim is an BooleanProperty and defaults to True.
error_color
Error color in rgba format for required = True.
error_color is an ListProperty and defaults to [].
fill_color
The background color of the fill in rgba format when the mode parameter is “fill”.
fill_color is an ListProperty and defaults to (0, 0, 0, 0).
active_line
Show active line or not.
active_line is an BooleanProperty and defaults to True.
error
If True, then the text field goes into error mode.
error is an BooleanProperty and defaults to False.
current_hint_text_color
hint_text text color.
current_hint_text_color is an ListProperty and defaults to [].
icon_right
Right icon.
icon_right is an StringProperty and defaults to ‘’.
icon_right_color
Color of right icon in rgba format.
icon_right_color is an ListProperty and defaults to (0, 0, 0, 1).
text_color
Text color in rgba format.
text_color is an ListProperty and defaults to [].
set_objects_labels(self )
Creates labels objects for the parameters helper_text,`hint_text`, etc.
on_icon_right(self, instance, value)
on_icon_right_color(self, instance, value)
on_width(self, instance, width)
Called when the application window is resized.
on_focus(self, *args)
on_disabled(self, *args)
on_text(self, instance, text)
on_text_validate(self )
on_color_mode(self, instance, mode)
on_line_color_focus(self, *args)
on__hint_text(self, instance, value)
class kivymd.uix.textfield.MDTextFieldRound(**kwargs)
TextInput class. See module documentation for more information.
Events
on_text_validate Fired only in multiline=False mode when the user hits ‘enter’. This will also
unfocus the textinput.
on_double_tap Fired when a double tap happens in the text input. The default behavior selects
the text around the cursor position. More info at on_double_tap().
on_triple_tap Fired when a triple tap happens in the text input. The default behavior selects the
line around the cursor position. More info at on_triple_tap().
on_quad_touch Fired when four fingers are touching the text input. The default behavior selects
the whole text. More info at on_quad_touch().
Warning: When changing a TextInput property that requires re-drawing, e.g. modifying the text, the
updates occur on the next clock cycle and not instantly. This might cause any changes to the TextInput
that occur between the modification and the next cycle to be ignored, or to use previous values. For example,
after a update to the text, changing the cursor in the same clock frame will move it using the previous text
and will likely end up in an incorrect position. The solution is to schedule any updates to occur on the next
clock cycle using schedule_once().
Note: Selection is cancelled when TextInput is focused. If you need to show selection when TextInput is fo-
cused, you should delay (use Clock.schedule) the call to the functions for selecting text (select_all, select_text).
normal_color
Field color if focus is False.
normal_color is an ListProperty and defaults to [].
color_active
Field color if focus is True.
color_active is an ListProperty and defaults to [].
on_focus(self, instance, value)
on_icon_left(self, instance, value)
on_icon_left_color(self, instance, value)
on_icon_right(self, instance, value)
on_icon_right_color(self, instance, value)
on_color_active(self, instance, value)
GridLayout class equivalent. Simplifies working with some widget properties. For example:
GridLayout
GridLayout:
size_hint_y: None
height: self.minimum_height
canvas:
Color:
rgba: app.theme_cls.primary_color
Rectangle:
pos: self.pos
size: self.size
MDGridLayout
MDGridLayout:
adaptive_height: True
md_bg_color: app.theme_cls.primary_color
• adaptive_height
• adaptive_width
• adaptive_size
adaptive_height
adaptive_height: True
Equivalent
size_hint_y: None
height: self.minimum_height
adaptive_width
adaptive_width: True
Equivalent
size_hint_x: None
height: self.minimum_width
adaptive_size
adaptive_size: True
Equivalent
API - kivymd.uix.gridlayout
class kivymd.uix.gridlayout.MDGridLayout(**kwargs)
Grid layout class. See module documentation for more information.
2.4 Behaviors
2.4.1 Hover
To apply hover behavior, you must create a new class that is inherited from the widget to which you apply the behavior
and from the HoverBehavior class.
In KV file:
<HoverItem@MDBoxLayout+ThemableBehavior+HoverBehavior>
In python file:
After creating a class, you must define two methods for it: HoverBehavior.on_enter and HoverBehavior.
on_leave, which will be automatically called when the mouse cursor is over the widget and when the mouse cursor
goes beyond the widget.
KV = '''
Screen
MDBoxLayout:
id: box
pos_hint: {'center_x': .5, 'center_y': .5}
size_hint: .8, .8
md_bg_color: app.theme_cls.bg_darkest
'''
self.md_bg_color = (1, 1, 1, 1)
self.md_bg_color = self.theme_cls.bg_darkest
Test().run()
API - kivymd.uix.behaviors.hover_behavior
class kivymd.uix.behaviors.hover_behavior.HoverBehavior(**kwargs)
Events
hovered
True, if the mouse cursor is within the borders of the widget.
hovered is an BooleanProperty and defaults to False.
border_point
Contains the last relevant point received by the Hoverable. This can be used in on_enter or on_leave
in order to know where was dispatched the event.
border_point is an ObjectProperty and defaults to None.
on_mouse_pos(self, *args)
on_enter(self )
Call when mouse enter the bbox of the widget.
on_leave(self )
Call when the mouse exit the widget.
2.4.2 Magic
To apply magic effects, you must create a new class that is inherited from the widget to which you apply the effect and
from the MagicBehavior class.
In KV file:
<MagicButton@MagicBehavior+MDRectangleFlatButton>
In python file:
• MagicBehavior.wobble
• MagicBehavior.grow
• MagicBehavior.shake
• MagicBehavior.twist
• MagicBehavior.shrink
Example:
from kivymd.app import MDApp
from kivy.lang import Builder
KV = '''
#:import MagicBehavior kivymd.uix.behaviors.MagicBehavior
<MagicButton@MagicBehavior+MDRectangleFlatButton>
FloatLayout:
MagicButton:
text: "WOBBLE EFFECT"
on_release: self.wobble()
pos_hint: {"center_x": .5, "center_y": .3}
MagicButton:
text: "GROW EFFECT"
on_release: self.grow()
pos_hint: {"center_x": .5, "center_y": .4}
MagicButton:
text: "SHAKE EFFECT"
on_release: self.shake()
pos_hint: {"center_x": .5, "center_y": .5}
MagicButton:
text: "TWIST EFFECT"
on_release: self.twist()
pos_hint: {"center_x": .5, "center_y": .6}
MagicButton:
text: "SHRINK EFFECT"
on_release: self.shrink()
pos_hint: {"center_x": .5, "center_y": .7}
'''
class Example(MDApp):
def build(self):
(continues on next page)
Example().run()
API - kivymd.uix.behaviors.magic_behavior
class kivymd.uix.behaviors.magic_behavior.MagicBehavior
magic_speed
Animation playback speed.
magic_speed is a NumericProperty and defaults to 1.
grow(self )
Grow effect animation.
shake(self )
Shake effect animation.
wobble(self )
Wobble effect animation.
twist(self )
Twist effect animation.
shrink(self )
Shrink effect animation.
on_touch_up(self, *args)
2.4.3 ToggleButton
This behavior must always be inherited after the button’s Widget class since it works with the inherited properties of
the button class.
example:
KV = '''
Screen:
MDBoxLayout:
adaptive_size: True
(continues on next page)
MyToggleButton:
text: "Show ads"
group: "x"
MyToggleButton:
text: "Do not show ads"
group: "x"
MyToggleButton:
text: "Does not matter"
group: "x"
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
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.MDToggleButton(**kwargs)
This mixin class provides togglebutton behavior. Please see the togglebutton behaviors
module documentation for more information.
New in version 1.8.0.
background_normal
Color of the button in rgba format for the ‘normal’ state.
background_normal is a ListProperty and is defaults to [].
background_down
Color of the button in rgba format for the ‘down’ state.
background_down is a ListProperty and is defaults to [].
font_color_normal
Color of the font’s button in rgba format for the ‘normal’ state.
font_color_normal is a ListProperty and is defaults to [].
font_color_down
Color of the font’s button in rgba format for the ‘down’ state.
font_color_down is a ListProperty and is defaults to [1, 1, 1, 1].
2.4.4 Touch
Usage
KV = '''
Screen:
MyButton:
text: "PRESS ME"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class MainApp(MDApp):
def build(self):
return Builder.load_string(KV)
MainApp().run()
API - kivymd.uix.behaviors.touch_behavior
class kivymd.uix.behaviors.touch_behavior.TouchBehavior(**kwargs)
duration_long_touch
Time for a long touch.
duration_long_touch is an NumericProperty and defaults to 0.4.
create_clock(self, widget, touch, *args)
delete_clock(self, widget, touch, *args)
on_long_touch(self, touch, *args)
Called when the widget is pressed for a long time.
on_double_tap(self, touch, *args)
Called by double clicking on the widget.
on_triple_tap(self, touch, *args)
Called by triple clicking on the widget.
2.4.5 Ripple
To create a widget with ircular ripple effect, you must create a new class that inherits from the
CircularRippleBehavior class.
For example, let’s create an image button with a circular ripple effect:
from kivy.lang import Builder
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.image import Image
Screen:
CircularRippleButton:
source: f"{images_path}/kivymd.png"
size_hint: None, None
size: "250dp", "250dp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Example(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
Example().run()
To create a widget with rectangular ripple effect, you must create a new class that inherits from the
RectangularRippleBehavior class:
from kivy.lang import Builder
from kivy.uix.behaviors import ButtonBehavior
KV = '''
Screen:
RectangularRippleButton:
size_hint: None, None
size: "250dp", "50dp"
pos_hint: {"center_x": .5, "center_y": .5}
'''
class RectangularRippleButton(
RectangularRippleBehavior, ButtonBehavior, BackgroundColorBehavior
):
md_bg_color = [0, 0, 1, 1]
class Example(MDApp):
def build(self):
(continues on next page)
Example().run()
API - kivymd.uix.behaviors.ripplebehavior
class kivymd.uix.behaviors.ripplebehavior.CommonRipple
Base class for ripple effect.
ripple_rad_default
Default value of the ripple effect radius.
abstract lay_canvas_instructions(self )
start_ripple(self )
finish_ripple(self )
fade_out(self, *args)
anim_complete(self, *args)
on_touch_down(self, touch)
on_touch_move(self, touch, *args)
on_touch_up(self, touch)
class kivymd.uix.behaviors.ripplebehavior.RectangularRippleBehavior
Class implements a rectangular ripple effect.
ripple_scale
See ripple_scale.
ripple_scale is an NumericProperty and defaults to 2.75.
lay_canvas_instructions(self )
class kivymd.uix.behaviors.ripplebehavior.CircularRippleBehavior
Class implements a circular ripple effect.
ripple_scale
See ripple_scale.
ripple_scale is an NumericProperty and defaults to 1.
lay_canvas_instructions(self )
2.4.6 Focus
To apply focus behavior, you must create a new class that is inherited from the widget to which you apply the behavior
and from the FocusBehavior class.
Usage
KV = '''
MDScreen:
md_bg_color: 1, 1, 1, 1
FocusWidget:
size_hint: .5, .3
pos_hint: {"center_x": .5, "center_y": .5}
md_bg_color: app.theme_cls.bg_light
(continues on next page)
MDLabel:
text: "Label"
theme_text_color: "Primary"
pos_hint: {"center_y": .5}
halign: "center"
'''
class Test(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
Test().run()
FocusWidget:
focus_color: 1, 0, 1, 1
unfocus_color: 0, 0, 1, 1
API - kivymd.uix.behaviors.focus_behavior
class kivymd.uix.behaviors.focus_behavior.FocusBehavior(**kwargs)
Events
focus_behavior
Using focus when hovering over a widget.
focus_behavior is a BooleanProperty and defaults to False.
focus_color
The color of the widget when the mouse enters the bbox of the widget.
focus_color is a ListProperty and defaults to [].
unfocus_color
The color of the widget when the mouse exits the bbox widget.
unfocus_color is a ListProperty and defaults to [].
on_enter(self )
Called when mouse enter the bbox of the widget.
on_leave(self )
Called when the mouse exit the widget.
Note: The following classes are intended for in-house use of the library.
API - kivymd.uix.behaviors.backgroundcolorbehavior
class kivymd.uix.behaviors.backgroundcolorbehavior.BackgroundColorBehavior(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
r
The value of red in the rgba palette.
r is an BoundedNumericProperty and defaults to 1.0.
g
The value of green in the rgba palette.
g is an BoundedNumericProperty and defaults to 1.0.
b
The value of blue in the rgba palette.
b is an BoundedNumericProperty and defaults to 1.0.
a
The value of alpha channel in the rgba palette.
a is an BoundedNumericProperty and defaults to 0.0.
radius
Canvas radius.
Widget:
canvas:
Color:
rgba: 0, 1, 1, 1
Rectangle:
size: self.size
pos: self.pos
similar to code:
<MyWidget@BackgroundColorBehavior>
md_bg_color: 0, 1, 1, 1
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
background_palette
See kivymd.color_definitions.palette.
background_palette is an OptionProperty and defaults to ‘Primary’.
background_hue
See kivymd.color_definitions.hue.
background_hue is an OptionProperty and defaults to ‘500’.
specific_text_color
specific_text_color is an ListProperty and defaults to [0, 0, 0, 0.87].
specific_secondary_text_color
specific_secondary_text_color`is an :class:`~kivy.properties.
ListProperty and defaults to [0, 0, 0, 0.87].
2.4.8 Elevation
To create a widget with rectangular or circular elevation effect, you must create a new class that inherits from the
RectangularElevationBehavior or CircularElevationBehavior class.
For example, let’s create an button with a rectangular elevation effect:
KV = '''
<RectangularElevationButton>:
size_hint: None, None
size: "250dp", "50dp"
Screen:
class RectangularElevationButton(
RectangularRippleBehavior,
RectangularElevationBehavior,
(continues on next page)
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
KV = '''
#:import images_path kivymd.images_path
<CircularElevationButton>:
size_hint: None, None
size: "100dp", "100dp"
source: f"{images_path}/kivymd.png"
Screen:
class CircularElevationButton(
CircularRippleBehavior,
CircularElevationBehavior,
ButtonBehavior,
Image,
):
(continues on next page)
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
API - kivymd.uix.behaviors.elevation
class kivymd.uix.behaviors.elevation.CommonElevationBehavior(**kwargs)
Common base class for rectangular and circular elevation behavior.
elevation
Elevation value.
elevation is an NumericProperty and defaults to 1.
class kivymd.uix.behaviors.elevation.RectangularElevationBehavior(**kwargs)
Base class for rectangular elevation behavior. Controls the size and position of the shadow.
class kivymd.uix.behaviors.elevation.CircularElevationBehavior(**kwargs)
Base class for circular elevation behavior. Controls the size and position of the shadow.
2.5 Changelog
2.5.1 Unreleased
2.5.2 0.104.1
2.5.3 0.104.0
2.5.4 0.103.0
2.5.5 0.102.1
2.5.6 0.102.0
2.5.7 0.101.8
2.5.8 0.101.7
• Fixed colors and position of the buttons in the Buttons demo screen ([Kitchen Sink demo](https://github.com/
kivymd/KivyMD/tree/master/demos/kitchen_sink)).
• Displaying percent of loading kv-files ([Kitchen Sink demo](https://github.com/kivymd/KivyMD/tree/master/
demos/kitchen_sink)).
2.5.9 0.101.6
2.5.10 0.101.5
• Added feature to see source code of current example ([Kitchen Sink demo](https://github.com/kivymd/KivyMD/
tree/master/demos/kitchen_sink)).
• Added names of authors of this fork ([Kitchen Sink demo](https://github.com/kivymd/KivyMD/tree/master/
demos/kitchen_sink)).
• Bug fixes and other minor improvements.
2.5.11 0.101.4
2.5.12 0.101.3
2.5.13 0.101.2
2.5.14 0.101.1
2.5.15 0.101.0
2.5.16 0.100.2
• [Black](https://github.com/psf/black) formatting.
2.5.17 0.100.1
2.5.18 0.100.0
2.5.19 0.99.99.01
• Fixed MDNavigationDrawer.use_logo.
2.5.20 0.99.99
2.5.21 0.99.98
2.5.22 0.99.97
2.5.23 0.99.96
2.5.24 0.99.95
2.5.25 0.99.94
2.5.26 0.99.93
2.5.27 0.99.92
2.6 About
2.6.1 License
Refer to LICENSE.
MIT License
Copyright (c) 2015 Andrés Rodríguez and other contributors - KivyMD library up to
˓→version 0.1.2
Copyright (c) 2020 KivyMD Team and other contributors - KivyMD library version 0.1.3
˓→and higher
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
2.7 KivyMD
Is a collection of Material Design compliant widgets for use with, Kivy cross-platform graphical framework a frame-
work for cross-platform, touch-enabled graphical applications. The project’s goal is to approximate Google’s Material
Design spec as close as possible without sacrificing ease of use or application performance.
This library is a fork of the KivyMD project the author of which stopped supporting this project three years ago. We
found the strength and brought this project to a new level. Currently we’re in beta status, so things are changing all
the time and we cannot promise any kind of API stability. However it is safe to vendor now and make use of what’s
currently available.
Join the project! Just fork the project, branch out and submit a pull request when your patch is ready. If any changes
are necessary, we’ll guide you through the steps that need to be done via PR comments or access to your for may
be requested to outright submit them. If you wish to become a project developer (permission to create branches on
the project without forking for easier collaboration), have at least one PR approved and ask for it. If you contribute
regularly to the project the role may be offered to you without asking too.
kivymd.release = False
kivymd.path
Path to KivyMD package directory.
kivymd.fonts_path
Path to fonts directory.
kivymd.images_path
Path to images directory.
2.7.2 Submodules
API - kivymd.factory_registers
kivymd.factory_registers.r
Material Resources
API - kivymd.material_resources
kivymd.material_resources.dp
kivymd.material_resources.DEVICE_IOS
kivymd.material_resources.DEVICE_TYPE = desktop
kivymd.material_resources.MAX_NAV_DRAWER_WIDTH
kivymd.material_resources.TOUCH_TARGET_HEIGHT
Two implementations. The first is based on color brightness obtained from- https://www.w3.org/TR/AERT#
color-contrast The second is based on relative luminance calculation for sRGB obtained from- https://www.w3.
org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef and contrast ratio calculation obtained from- https:
//www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
Preliminary testing suggests color brightness more closely matches the Material Design spec suggested text colors,
but the alternative implementation is both newer and the current ‘correct’ recommendation, so is included here as an
option.
API - kivymd.theming_dynamic_text
kivymd.theming_dynamic_text.get_contrast_text_color(color,
use_color_brightness=True)
kivymd.theming_dynamic_text.color
An Effect to be used with ScrollView to prevent scrolling beyond the bounds, but politely.
A ScrollView constructed with StiffScrollEffect, eg. ScrollView(effect_cls=StiffScrollEffect), will get harder to scroll
as you get nearer to its edges. You can scroll all the way to the edge if you want to, but it will take more finger-
movement than usual.
Unlike DampedScrollEffect, it is impossible to overscroll with StiffScrollEffect. That means you cannot push the
contents of the ScrollView far enough to see what’s beneath them. This is appropriate if the ScrollView contains, eg.,
a background image, like a desktop wallpaper. Overscrolling may give the impression that there is some reason to
overscroll, even if just to take a peek beneath, and that impression may be misleading.
StiffScrollEffect was written by Zachary Spector. His other stuff is at: https://github.com/LogicalDash/ He can be
reached, and possibly hired, at: [email protected]
API - kivymd.stiffscroll
class kivymd.stiffscroll.StiffScrollEffect(**kwargs)
Kinetic effect class. See module documentation for more information.
drag_threshold
Minimum distance to travel before the movement is considered as a drag.
drag_threshold is an NumericProperty and defaults to ’20sp’.
min
Minimum boundary to stop the scrolling at.
min is an NumericProperty and defaults to 0.
max
Maximum boundary to stop the scrolling at.
max is an NumericProperty and defaults to 0.
max_friction
How hard should it be to scroll, at the worst?
max_friction is an NumericProperty and defaults to 1.
body
Proportion of the range in which you can scroll unimpeded.
body is an NumericProperty and defaults to 0.7.
scroll
Computed value for scrolling
scroll is an NumericProperty and defaults to 0.0.
transition_min
The AnimationTransition function to use when adjusting the friction near the minimum end of the effect.
transition_min is an ObjectProperty and defaults to kivy.animation.
AnimationTransition.
transition_max
The AnimationTransition function to use when adjusting the friction near the maximum end of the effect.
transition_max is an ObjectProperty and defaults to kivy.animation.
AnimationTransition.
target_widget
The widget to apply the effect to.
target_widget is an ObjectProperty and defaults to None.
displacement
The absolute distance moved in either direction.
displacement is an NumericProperty and defaults to 0.
update_velocity(self, dt)
Before actually updating my velocity, meddle with self.friction to make it appropriate to where
I’m at, currently.
on_value(self, *args)
Prevent moving beyond my bounds, and update self.scroll
start(self, val, t=None)
Start movement with self.friction = self.base_friction
update(self, val, t=None)
Reduce the impact of whatever change has been made to me, in proportion with my current friction.
stop(self, val, t=None)
Work out whether I’ve been flung.
kivymd.toast
API - kivymd.toast
Submodules
API - kivymd.toast.androidtoast
Submodules
AndroidToast
KV = '''
BoxLayout:
orientation:'vertical'
MDToolbar:
(continues on next page)
FloatLayout:
MDRaisedButton:
text: 'TEST KIVY TOAST'
on_release: app.show_toast()
pos_hint: {'center_x': .5, 'center_y': .5}
'''
class Test(MDApp):
def show_toast(self):
'''Displays a toast on the screen.'''
def build(self):
return Builder.load_string(KV)
Test().run()
API - kivymd.toast.androidtoast.androidtoast
kivymd.toast.androidtoast.androidtoast.toast(text, length_long=False)
Displays a toast.
Length_long The amount of time (in seconds) that the toast is visible on the screen.
kivymd.toast.kivytoast
API - kivymd.toast.kivytoast
Submodules
KivyToast
KV = '''
BoxLayout:
orientation:'vertical'
(continues on next page)
MDToolbar:
id: toolbar
title: 'Test Toast'
md_bg_color: app.theme_cls.primary_color
left_action_items: [['menu', lambda x: '']]
FloatLayout:
MDRaisedButton:
text: 'TEST KIVY TOAST'
on_release: app.show_toast()
pos_hint: {'center_x': .5, 'center_y': .5}
'''
class Test(MDApp):
def show_toast(self):
'''Displays a toast on the screen.'''
def build(self):
return Builder.load_string(KV)
Test().run()
API - kivymd.toast.kivytoast.kivytoast
class kivymd.toast.kivytoast.kivytoast.Toast(**kwargs)
ModalView class. See module documentation for more information.
Events
on_pre_open: Fired before the ModalView is opened. When this event is fired ModalView is
not yet added to window.
on_open: Fired when the ModalView is opened.
on_pre_dismiss: Fired before the ModalView is closed.
on_dismiss: Fired when the ModalView is closed. If the callback returns True, the dismiss will
be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
duration
The amount of time (in seconds) that the toast is visible on the screen.
duration is an NumericProperty and defaults to 2.5.
label_check_texture_size(self, instance, texture_size)
toast(self, text_toast)
on_open(self )
fade_in(self )
fade_out(self, interval)
on_touch_down(self, 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.
kivymd.toast.kivytoast.kivytoast.toast(text='', background=None, duration=2.5)
Displays a toast.
Attr duration the amount of time (in seconds) that the toast is visible on the screen
Attr background color rgba in Kivy format
kivymd.tools
API - kivymd.tools
Submodules
kivymd.tools.packaging
API - kivymd.tools.packaging
Submodules
PyInstaller hooks
import sys
import os
path = os.path.abspath(".")
a = Analysis(
["main.py"],
pathex=[path],
hookspath=[kivymd_hooks_path],
win_no_prefer_redirects=False,
(continues on next page)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
debug=False,
strip=False,
upx=True,
name="app_name",
console=True,
)
API - kivymd.tools.packaging.pyinstaller
kivymd.tools.packaging.pyinstaller.hooks_path
Path to hook directory to use with PyInstaller. See kivymd.tools.packaging.pyinstaller for more
information.
kivymd.tools.packaging.pyinstaller.get_hook_dirs()
kivymd.tools.packaging.pyinstaller.get_pyinstaller_tests()
Submodules
API - kivymd.tools.packaging.pyinstaller.hook-kivymd
kivymd.tools.release
API - kivymd.tools.release
Submodules
kivymd.tools.release.argument_parser
API - kivymd.tools.release.argument_parser
class kivymd.tools.release.argument_parser.ArgumentParserWithHelp(prog=None,
us-
age=None,
descrip-
tion=None,
epi-
log=None,
parents=[],
format-
ter_class=HelpFormatter,
prefix_chars='-
', from-
file_prefix_chars=None,
argu-
ment_default=None,
con-
flict_handler='error',
add_help=True,
al-
low_abbrev=True)
Object for parsing command line strings into Python objects.
Keyword Arguments:
• prog – The name of the program (default: sys.argv[0])
• usage – A usage message (default: auto-generated from arguments)
• description – A description of what the program does
• epilog – Text following the argument descriptions
• parents – Parsers whose arguments should be copied into this one
• formatter_class – HelpFormatter class for printing help messages
• prefix_chars – Characters that prefix optional arguments
• fromfile_prefix_chars – Characters that prefix files containing additional arguments
• argument_default – The default value for all arguments
• conflict_handler – String indicating how to handle conflicts
• add_help – Add a -h/-help option
• allow_abbrev – Allow long options to be abbreviated unambiguously
parse_args(self, args=None, namespace=None)
error(self, message)
error(message: string)
Prints a usage message incorporating the message to stderr and exits.
If you override this in a subclass, it should not return – it should either exit or raise an exception.
format_help(self )
kivymd.tools.release.git_commands
API - kivymd.tools.release.git_commands
API - kivymd.tools.release.make_release
kivymd.tools.release.make_release.run_pre_commit()
Run pre-commit.
kivymd.tools.release.make_release.replace_in_file(pattern, repl, file)
Replace one pattern match to repl in file file.
kivymd.tools.release.make_release.update_init_py(version, is_release, test: bool =
False)
Change version in kivymd/__init__.py.
kivymd.tools.release.make_release.update_readme(previous_version, version, test: bool =
False)
Change version in README.
kivymd.tools.release.make_release.move_changelog(index_file, unreleased_file, previ-
ous_version, version_file, version,
test: bool = False)
Edit unreleased.rst and rename to <version>.rst.
kivymd.tools.release.make_release.create_unreleased_changelog(index_file, un-
released_file,
version, ask: bool
= True, test: bool
= False)
Create unreleased.rst by template.
kivymd.tools.release.make_release.main()
kivymd.tools.release.make_release.create_argument_parser()
API - kivymd.tools.release.update_icons
kivymd.tools.release.update_icons.kivymd_path
kivymd.tools.release.update_icons.font_path
kivymd.tools.release.update_icons.icon_definitions_path
kivymd.tools.release.update_icons.font_version = master
kivymd.tools.release.update_icons.url
kivymd.tools.release.update_icons.temp_path
kivymd.tools.release.update_icons.temp_repo_path
kivymd.tools.release.update_icons.temp_font_path
kivymd.tools.release.update_icons.temp_preview_path
kivymd.tools.release.update_icons.re_icons_json
kivymd.tools.release.update_icons.re_additional_icons
kivymd.tools.release.update_icons.re_version
kivymd.tools.release.update_icons.re_quote_keys
kivymd.tools.release.update_icons.re_icon_definitions
kivymd.tools.release.update_icons.re_version_in_file
kivymd.tools.release.update_icons.download_file(url, path)
kivymd.tools.release.update_icons.unzip_archive(archive_path, dir_path)
kivymd.tools.release.update_icons.get_icons_list()
kivymd.tools.release.update_icons.make_icon_definitions(icons)
kivymd.tools.release.update_icons.export_icon_definitions(icon_definitions, ver-
sion)
kivymd.tools.release.update_icons.update_icons(make_commit: bool = False)
kivymd.tools.release.update_icons.main()
kivymd.uix
API - kivymd.uix
class kivymd.uix.MDAdaptiveWidget(**kwargs)
Widget class. See module documentation for more information.
Events
on_touch_down: (touch, ) Fired when a new touch event occurs. touch is the touch object.
on_touch_move: (touch, ) Fired when an existing touch moves. touch is the touch object.
on_touch_up: (touch, ) Fired when an existing touch disappears. touch is the touch object.
on_kv_post: (base_widget, ) Fired after all the kv rules associated with the widget and all other
widgets that are in any of those rules have had all their kv rules applied. base_widget is
the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated
from Python, e.g. MyWidget()).
Changed in version 1.11.0.
Warning: Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable
automatic garbage collection for instances of that class. This is because the Widget class creates reference
cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the EventDispatcher.
Event properties can now be used when contructing a simple class without subclassing Widget.
Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to
properties or events, as in the Kv language.
adaptive_height
If True, the following properties will be applied to the widget:
size_hint_y: None
height: self.minimum_height
adaptive_width
If True, the following properties will be applied to the widget:
size_hint_x: None
width: self.minimum_width
Submodules
kivymd.uix.carousel
API - kivymd.uix.carousel
class kivymd.uix.carousel.MDCarousel(**kwargs)
Carousel class. See module documentation for more information.
on_slide_progress(self, *args)
on_slide_complete(self, *args)
on_touch_down(self, 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.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
Behaviors
API - kivymd.uix.behaviors
Submodules
kivymd.utils
API - kivymd.utils
Submodules
asynckivy
API - kivymd.utils.asynckivy
kivymd.utils.asynckivy.start(coro)
kivymd.utils.asynckivy.sleep(duration)
class kivymd.utils.asynckivy.event(ed, name)
bind(self, step_coro)
callback(self, *args, **kwargs)
Crop Image
API - kivymd.utils.cropimage
Fit Image
Feature to automatically crop a Kivy image to fit your layout Write by Benedikt Zwölfer
Referene - https://gist.github.com/benni12er/95a45eb168fc33a4fcd2d545af692dad
Example:
BoxLayout:
size_hint_y: None
height: "200dp"
orientation: 'vertical'
FitImage:
size_hint_y: 3
source: 'images/img1.jpg'
FitImage:
size_hint_y: 1
source: 'images/img2.jpg'
Builder.load_string(
'''
<Card>:
elevation: 10
(continues on next page)
FitImage:
id: bg_image
source: "images/bg.png"
size_hint_y: .35
pos_hint: {"top": 1}
radius: [36, 36, 0, 0, ]
''')
class Card(MDCard):
pass
class Example(MDApp):
def build(self):
modal = ModalView(
size_hint=(0.4, 0.8),
background=f"{images_path}/transparent.png",
overlay_color=(0, 0, 0, 0),
)
modal.add_widget(Card())
modal.open()
Example().run()
API - kivymd.utils.fitimage
class kivymd.utils.fitimage.FitImage(**kwargs)
Box layout class. See module documentation for more information.
source
container
radius
mipmap
Monitor module
The Monitor module is a toolbar that shows the activity of your current application :
• FPS
API - kivymd.utils.fpsmonitor
class kivymd.utils.fpsmonitor.FpsMonitor(**kwargs)
Label class, see module documentation for more information.
Events
on_ref_press Fired when the user clicks on a word referenced with a [ref] tag in a text
markup.
updated_interval
FPS refresh rate.
start(self )
update_fps(self, *args)
HotReloadViewer
HotReloadViewer, for KV-Viewer, is a simple tool allowing you to dynamically display a KV file, taking its
changes into account (thanks to watchdog). The idea is to facilitate design using the KV language.
Usage
KV = '''
#:import KivyLexer kivy.extras.highlight.KivyLexer
#:import HotReloadViewer kivymd.utils.hot_reload_viewer.HotReloadViewer
BoxLayout:
CodeInput:
lexer: KivyLexer()
style_name: "native"
on_text: app.update_kv_file(self.text)
size_hint_x: .7
HotReloadViewer:
size_hint_x: .3
path: app.path_to_kv_file
errors: True
errors_text_color: 1, 1, 0, 1
errors_background_color: app.theme_cls.bg_dark
'''
class Example(MDApp):
path_to_kv_file = "kv_file.kv"
(continues on next page)
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
Example().run()
This will display the test.kv and automatically update the display when the file changes.
This scripts uses watchdog to listen for file changes. To install watchdog.
API - kivymd.utils.hot_reload_viewer
class kivymd.utils.hot_reload_viewer.HotReloadErrorText(**kwargs)
ScrollView class. See module documentation for more information.
Events
on_scroll_start Generic event fired when scrolling starts from touch.
on_scroll_move Generic event fired when scrolling move from touch.
on_scroll_stop Generic event fired when scrolling stops from touch.
Changed in version 1.9.0: on_scroll_start, on_scroll_move and on_scroll_stop events are now dispatched when
scrolling to handle nested ScrollViews.
Changed in version 1.7.0: auto_scroll, scroll_friction, scroll_moves, scroll_stoptime’ has been deprecated, use
:attr:`effect_cls instead.
text
Text errors.
text is an StringProperty and defaults to ‘’.
errors_text_color
Error text color.
errors_text_color is an ListProperty and defaults to [].
class kivymd.utils.hot_reload_viewer.HotReloadHandler(callback, target, **kwargs)
on_any_event(self, event)
class kivymd.utils.hot_reload_viewer.HotReloadViewer(**kwargs)
Events
on_error Called when an error occurs in the KV-file that the user is editing.
path
Path to KV file.
path is an StringProperty and defaults to ‘’.
errors
Show errors while editing KV-file.
errors is an BooleanProperty and defaults to False.
errors_background_color
Error background color.
errors_background_color is an ListProperty and defaults to [].
errors_text_color
Error text color.
errors_text_color is an ListProperty and defaults to [].
update(self, *args)
Updates and displays the KV-file that the user edits.
show_error(self, error)
Displays text with a current error.
on_error(self, *args)
Called when an error occurs in the KV-file that the user is editing.
on_errors_text_color(self, instance, value)
on_path(self, instance, value)
kivymd.vendor
API - kivymd.vendor
Submodules
CircularLayout
size_hint
size_hint_x is used as an angle-quota hint (widget with higher size_hint_x will be farther from each other, and vice
versa), while size_hint_y is used as a widget size hint (widgets with a higher size hint will be bigger).size_hint_x
cannot be None.
Widgets are all squares, unless you set size_hint_y to None (in that case you’ll be able to specify your own size), and
their size is the difference between the outer and the inner circle’s radii. To make the widgets bigger you can just
decrease inner_radius_hint.
API - kivymd.vendor.circleLayout
class kivymd.vendor.circleLayout.CircularLayout(**kwargs)
Circular layout class. See module documentation for more information.
padding
Padding between the layout box and it’s children: [padding_left, padding_top, padding_right,
padding_bottom].
padding also accepts a two argument form [padding_horizontal, padding_vertical] and a one argument
form [padding].
padding is a VariableListProperty and defaults to [0, 0, 0, 0].
start_angle
Angle (in degrees) at which the first widget will be placed. Start counting angles from the X axis, going
counterclockwise.
start_angle is a NumericProperty and defaults to 0 (start from the right).
circle_quota
Size (in degrees) of the part of the circumference that will actually be used to place widgets.
circle_quota is a BoundedNumericProperty and defaults to 360 (all the circumference).
direction
Direction of widgets in the circle.
direction is an OptionProperty and defaults to ‘ccw’. Can be ‘ccw’ (counterclockwise) or ‘cw’
(clockwise).
outer_radius_hint
Sets the size of the outer circle. A number greater than 1 will make the widgets larger than the actual
widget, a number smaller than 1 will leave a gap.
outer_radius_hint is a NumericProperty and defaults to 1.
inner_radius_hint
Sets the size of the inner circle. A number greater than outer_radius_hint will cause glitches. The
closest it is to outer_radius_hint, the smallest will be the widget in the layout.
outer_radius_hint is a NumericProperty and defaults to 1.
radius_hint
Combined outer_radius_hint and inner_radius_hint in a list for convenience. See their
documentation for more details.
radius_hint is a ReferenceListProperty.
delta_radii
do_layout(self, *largs)
This function is called when a layout is called by a trigger. If you are writing a new Layout subclass, don’t
call this function directly but use _trigger_layout() instead.
The function is by default called before the next frame, therefore the layout isn’t updated immediately.
Anything depending on the positions of e.g. children should be scheduled for the next frame.
New in version 1.0.8.
Simple usage
class Example(MDApp):
def build(self):
box = MDScreen(md_bg_color=self.theme_cls.bg_darkest)
box.add_widget(CircularTimePicker())
return box
Example().run()
in Kv language:
<TimeChooserPopup@Popup>:
MDBoxLayout:
orientation: "vertical"
CircularTimePicker:
Button:
text: "Dismiss"
size_hint_y: None
height: "40dp"
on_release: root.dismiss()
API - kivymd.vendor.circularTimePicker
shown_items
dot_is_none(self, *args)
on_touch_down(self, 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.
on_touch_move(self, touch)
Receive a touch move event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
on_selected(self, *a)
pos_for_number(self, n)
Returns the center x, y coordinates for a given number.
number_at_pos(self, x, y)
Returns the number at a given x, y position. The number is found using the widget’s center as a starting
point for angle calculations.
Not thoroughly tested, may yield wrong results.
class kivymd.vendor.circularTimePicker.CircularMinutePicker(**kw)
CircularNumberPicker implementation for minutes.
class kivymd.vendor.circularTimePicker.CircularHourPicker(**kw)
CircularNumberPicker implementation for hours.
class kivymd.vendor.circularTimePicker.CircularTimePicker(**kw)
Widget that makes use of CircularHourPicker and CircularMinutePicker to create a user-friendly,
animated time picker like the one seen on Android.
See module documentation for more details.
primary_dark
hours
The hours, in military format (0-23).
hours is a NumericProperty and defaults to 0 (12am).
minutes
The minutes.
minutes is a NumericProperty and defaults to 0.
time_list
Packs hours and minutes in a list for convenience.
time_list is a ReferenceListProperty.
time_format
String that will be formatted with the time and shown in the time label. Can be any-
thing supported by str.format(). Make sure you don’t remove the refs. See the de-
fault for the arguments passed to format. time_format is a StringProperty and defaults
to “[color={hours_color}][ref=hours]{hours}[/ref][/color]:[color={minutes_color}][ref=minutes] {min-
utes:02d}[/ref][/color]”.
ampm_format
String that will be formatted and shown in the AM/PM label. Can be anything supported by str.
format(). Make sure you don’t remove the refs. See the default for the arguments passed to format.
ampm_format is a StringProperty and defaults to “[color={am_color}][ref=am]AM[/ref][/color]
[color={pm_color}][ref=pm]PM[/ref][/color]”.
picker
Currently shown time picker. Can be one of “minutes”, “hours”.
picker is a OptionProperty and defaults to “hours”.
selector_color
Color of the number selector and of the highlighted text. RGB.
selector_color is a ListProperty and defaults to [.337, .439, .490] (material green).
color
Color of the number labels and of the center dot. RGB.
color is a ListProperty and defaults to [1, 1, 1] (white).
selector_alpha
Alpha value for the transparent parts of the selector.
selector_alpha is a BoundedNumericProperty and defaults to 0.3 (min=0, max=1).
time
Selected time as a datetime.time object.
time is an AliasProperty.
time_text
ampm_text
set_time(self, dt)
on_ref_press(self, ign, ref )
on_selected(self, *a)
on_time_list(self, *a)
on_ampm(self, *a)
is_animating(self, *args)
is_not_animating(self, *args)
on_touch_down(self, 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.
on_touch_up(self, touch)
Receive a touch up event. The touch is in parent coordinates.
See on_touch_down() for more information.
class kivymd.vendor.circularTimePicker.Example(**kwargs)
Application class, see module documentation for more information.
Events
on_start: Fired when the application is being started (before the runTouchApp() call.
on_stop: Fired when the application stops.
on_pause: Fired when the application is paused by the OS.
on_resume: Fired when the application is resumed from pause by the OS. Beware: you have
no guarantee that this event will be fired after the on_pause event has been called.
Changed in version 1.7.0: Parameter kv_file added.
Changed in version 1.8.0: Parameters kv_file and kv_directory are now properties of App.
build(self )
Initializes the application; it will be called only once. If this method returns a widget (tree), it will be used
as the root widget and added to the window.
Returns None or a root Widget instance if no self.root exists.
THREE
• genindex
• modindex
• search
295
KivyMD, Release 0.104.2.dev0
k kivymd.uix.bottomnavigation, 156
kivymd, 268 kivymd.uix.bottomsheet, 81
kivymd.app, 16 kivymd.uix.boxlayout, 35
kivymd.color_definitions, 18 kivymd.uix.button, 55
kivymd.factory_registers, 269 kivymd.uix.card, 139
kivymd.font_definitions, 23 kivymd.uix.carousel, 280
kivymd.icon_definitions, 21 kivymd.uix.chip, 98
kivymd.material_resources, 269 kivymd.uix.datatables, 190
kivymd.stiffscroll, 269 kivymd.uix.dialog, 101
kivymd.theming, 6 kivymd.uix.dropdownitem, 213
kivymd.theming_dynamic_text, 269 kivymd.uix.expansionpanel, 51
kivymd.toast, 271 kivymd.uix.filemanager, 71
kivymd.toast.androidtoast, 271 kivymd.uix.floatlayout, 96
kivymd.toast.androidtoast.androidtoast, kivymd.uix.gridlayout, 242
271 kivymd.uix.imagelist, 132
kivymd.toast.kivytoast, 272 kivymd.uix.label, 162
kivymd.toast.kivytoast.kivytoast, 272 kivymd.uix.list, 217
kivymd.tools, 274 kivymd.uix.menu, 167
kivymd.tools.packaging, 274 kivymd.uix.navigationdrawer, 113
kivymd.tools.packaging.pyinstaller, 274 kivymd.uix.navigationrail, 121
kivymd.uix.picker, 202
kivymd.tools.packaging.pyinstaller.hook-kivymd,
275 kivymd.uix.progressbar, 208
kivymd.tools.release, 276 kivymd.uix.refreshlayout, 49
kivymd.tools.release.argument_parser, kivymd.uix.relativelayout, 95
276 kivymd.uix.screen, 189
kivymd.tools.release.git_commands, 277 kivymd.uix.selectioncontrol, 152
kivymd.tools.release.make_release, 277 kivymd.uix.slider, 199
kivymd.tools.release.update_icons, 278 kivymd.uix.snackbar, 89
kivymd.uix, 279 kivymd.uix.spinner, 69
kivymd.uix.backdrop, 135 kivymd.uix.stacklayout, 96
kivymd.uix.banner, 128 kivymd.uix.swiper, 75
kivymd.uix.behaviors, 281 kivymd.uix.tab, 24
kivymd.uix.taptargetview, 37
kivymd.uix.behaviors.backgroundcolorbehavior,
255 kivymd.uix.textfield, 230
kivymd.uix.behaviors.elevation, 257 kivymd.uix.toolbar, 181
kivymd.uix.behaviors.focus_behavior, 253 kivymd.uix.tooltip, 214
kivymd.uix.behaviors.hover_behavior, 244 kivymd.utils, 281
kivymd.uix.behaviors.magic_behavior, 245 kivymd.utils.asynckivy, 281
kivymd.uix.behaviors.ripplebehavior, 250 kivymd.utils.cropimage, 281
kivymd.uix.behaviors.toggle_behavior, kivymd.utils.fitimage, 282
247 kivymd.utils.fpsmonitor, 284
kivymd.uix.behaviors.touch_behavior, 249 kivymd.utils.hot_reload_viewer, 285
297
KivyMD, Release 0.104.2.dev0
kivymd.vendor, 287
kivymd.vendor.circleLayout, 287
kivymd.vendor.circularTimePicker, 289
A 131
add_banner_to_container()
a (kivymd.uix.behaviors.backgroundcolorbehavior.BackgroundColorBehavior
attribute), 255 (kivymd.uix.banner.MDBanner method),
accent_color (kivymd.theming.ThemeManager at- 131
tribute), 10 add_blur() (in module kivymd.utils.cropimage), 281
accent_dark (kivymd.theming.ThemeManager at- add_corners() (in module kivymd.utils.cropimage),
tribute), 10 281
accent_dark_hue (kivymd.theming.ThemeManager add_item() (kivymd.uix.bottomsheet.MDGridBottomSheet
attribute), 10 method), 89
accent_hue (kivymd.theming.ThemeManager at- add_item() (kivymd.uix.bottomsheet.MDListBottomSheet
tribute), 10 method), 88
accent_light (kivymd.theming.ThemeManager at- add_scrim() (kivymd.uix.navigationdrawer.NavigationLayout
tribute), 10 method), 118
accent_light_hue (kivymd.theming.ThemeManager add_widget() (kivymd.uix.backdrop.MDBackdrop
attribute), 10 method), 139
accent_palette (kivymd.theming.ThemeManager add_widget() (kivymd.uix.bottomnavigation.MDBottomNavigation
attribute), 10 method), 161
action_color_button add_widget() (kivymd.uix.bottomsheet.MDBottomSheet
(kivymd.uix.navigationrail.MDNavigationRail method), 87
attribute), 126 add_widget() (kivymd.uix.card.MDCardSwipe
action_icon_button method), 150
(kivymd.uix.navigationrail.MDNavigationRail add_widget() (kivymd.uix.chip.MDChooseChip
attribute), 125 method), 101
action_text_button add_widget() (kivymd.uix.expansionpanel.MDExpansionPanel
(kivymd.uix.navigationrail.MDNavigationRail method), 55
attribute), 126 add_widget() (kivymd.uix.list.ContainerSupport
active (kivymd.uix.selectioncontrol.MDCheckbox at- method), 229
tribute), 155 add_widget() (kivymd.uix.list.MDList method), 227
active (kivymd.uix.selectioncontrol.MDSwitch at- add_widget() (kivymd.uix.navigationdrawer.NavigationLayout
tribute), 156 method), 118
active (kivymd.uix.slider.MDSlider attribute), 201 add_widget() (kivymd.uix.navigationrail.MDNavigationRail
active (kivymd.uix.spinner.MDSpinner attribute), 71 method), 126
active_line (kivymd.uix.textfield.MDTextField at- add_widget() (kivymd.uix.swiper.MDSwiper
tribute), 240 method), 80
adaptive_height (kivymd.uix.MDAdaptiveWidget add_widget() (kivymd.uix.tab.MDTabs method), 34
attribute), 279 add_widget() (kivymd.uix.toolbar.MDBottomAppBar
adaptive_size (kivymd.uix.MDAdaptiveWidget at- method), 188
tribute), 280 adjust_tooltip_position()
adaptive_width (kivymd.uix.MDAdaptiveWidget at- (kivymd.uix.tooltip.MDTooltip method), 217
tribute), 279 allow_stretch (kivymd.uix.tab.MDTabs attribute),
add_actions_buttons() 33
(kivymd.uix.banner.MDBanner method), ampm_format (kivymd.vendor.circularTimePicker.CircularTimePicker
299
KivyMD, Release 0.104.2.dev0
300 Index
KivyMD, Release 0.104.2.dev0
Index 301
KivyMD, Release 0.104.2.dev0
302 Index
KivyMD, Release 0.104.2.dev0
Index 303
KivyMD, Release 0.104.2.dev0
304 Index
KivyMD, Release 0.104.2.dev0
Index 305
KivyMD, Release 0.104.2.dev0
kivymd.material_resources kivymd.uix.behaviors.ripplebehavior
module, 269 module, 250
kivymd.stiffscroll kivymd.uix.behaviors.toggle_behavior
module, 269 module, 247
kivymd.theming kivymd.uix.behaviors.touch_behavior
module, 6 module, 249
kivymd.theming_dynamic_text kivymd.uix.bottomnavigation
module, 269 module, 156
kivymd.toast kivymd.uix.bottomsheet
module, 271 module, 81
kivymd.toast.androidtoast kivymd.uix.boxlayout
module, 271 module, 35
kivymd.toast.androidtoast.androidtoast kivymd.uix.button
module, 271 module, 55
kivymd.toast.kivytoast kivymd.uix.card
module, 272 module, 139
kivymd.toast.kivytoast.kivytoast kivymd.uix.carousel
module, 272 module, 280
kivymd.tools kivymd.uix.chip
module, 274 module, 98
kivymd.tools.packaging kivymd.uix.datatables
module, 274 module, 190
kivymd.tools.packaging.pyinstaller kivymd.uix.dialog
module, 274 module, 101
kivymd.tools.packaging.pyinstaller.hook-kivymd
kivymd.uix.dropdownitem
module, 275 module, 213
kivymd.tools.release kivymd.uix.expansionpanel
module, 276 module, 51
kivymd.tools.release.argument_parser kivymd.uix.filemanager
module, 276 module, 71
kivymd.tools.release.git_commands kivymd.uix.floatlayout
module, 277 module, 96
kivymd.tools.release.make_release kivymd.uix.gridlayout
module, 277 module, 242
kivymd.tools.release.update_icons kivymd.uix.imagelist
module, 278 module, 132
kivymd.uix kivymd.uix.label
module, 279 module, 162
kivymd.uix.backdrop kivymd.uix.list
module, 135 module, 217
kivymd.uix.banner kivymd.uix.menu
module, 128 module, 167
kivymd.uix.behaviors kivymd.uix.navigationdrawer
module, 281 module, 113
kivymd.uix.behaviors.backgroundcolorbehavior
kivymd.uix.navigationrail
module, 255 module, 121
kivymd.uix.behaviors.elevation kivymd.uix.picker
module, 257 module, 202
kivymd.uix.behaviors.focus_behavior kivymd.uix.progressbar
module, 253 module, 208
kivymd.uix.behaviors.hover_behavior kivymd.uix.refreshlayout
module, 244 module, 49
kivymd.uix.behaviors.magic_behavior kivymd.uix.relativelayout
module, 245 module, 95
306 Index
KivyMD, Release 0.104.2.dev0
Index 307
KivyMD, Release 0.104.2.dev0
308 Index
KivyMD, Release 0.104.2.dev0
Index 309
KivyMD, Release 0.104.2.dev0
kivymd.uix.stacklayout, 96 188
kivymd.uix.swiper, 75 on_active() (kivymd.uix.selectioncontrol.MDCheckbox
kivymd.uix.tab, 24 method), 156
kivymd.uix.taptargetview, 37 on_active() (kivymd.uix.slider.MDSlider method),
kivymd.uix.textfield, 230 202
kivymd.uix.toolbar, 181 on_active() (kivymd.uix.spinner.MDSpinner
kivymd.uix.tooltip, 214 method), 71
kivymd.utils, 281 on_adaptive_height()
kivymd.utils.asynckivy, 281 (kivymd.uix.MDAdaptiveWidget method),
kivymd.utils.cropimage, 281 280
kivymd.utils.fitimage, 282 on_adaptive_size()
kivymd.utils.fpsmonitor, 284 (kivymd.uix.MDAdaptiveWidget method),
kivymd.utils.hot_reload_viewer, 285 280
kivymd.vendor, 287 on_adaptive_width()
kivymd.vendor.circleLayout, 287 (kivymd.uix.MDAdaptiveWidget method),
kivymd.vendor.circularTimePicker, 280
289 on_ampm() (kivymd.vendor.circularTimePicker.CircularTimePicker
month (kivymd.uix.picker.MDDatePicker attribute), 207 method), 292
move_changelog() (in module on_anchor() (kivymd.uix.card.MDCardSwipe
kivymd.tools.release.make_release), 278 method), 151
multiples_of (kivymd.vendor.circularTimePicker.CircularNumberPicker
on_any_event() (kivymd.utils.hot_reload_viewer.HotReloadHandler
attribute), 290 method), 286
on_bg_color_root_button()
N (kivymd.uix.button.MDFloatingActionButtonSpeedDial
NavigationLayout (class in method), 69
kivymd.uix.navigationdrawer), 118 on_bg_color_stack_button()
normal_color (kivymd.uix.textfield.MDTextFieldRound (kivymd.uix.button.MDFloatingActionButtonSpeedDial
attribute), 241 method), 69
Number (class in kivymd.vendor.circularTimePicker), on_bg_hint_color()
289 (kivymd.uix.button.MDFloatingActionButtonSpeedDial
method), 69
number_at_pos() (kivymd.vendor.circularTimePicker.CircularNumberPicker
method), 291 on_carousel_index() (kivymd.uix.tab.MDTabs
number_format_string method), 35
on_check_press() (kivymd.uix.datatables.MDDataTable
(kivymd.vendor.circularTimePicker.CircularNumberPicker
attribute), 290 method), 199
number_size_factor on_close() (kivymd.uix.backdrop.MDBackdrop
(kivymd.vendor.circularTimePicker.CircularNumberPicker method), 138
attribute), 290 on_close() (kivymd.uix.button.MDFloatingActionButtonSpeedDial
method), 69
O on_close() (kivymd.uix.expansionpanel.MDExpansionPanel
ok_click() (kivymd.uix.picker.MDDatePicker method), 54
method), 207 on_close() (kivymd.uix.navigationrail.MDNavigationRail
on__hint_text() (kivymd.uix.textfield.MDTextField method), 127
method), 240 on_close() (kivymd.uix.taptargetview.MDTapTargetView
on__is_off() (kivymd.uix.slider.MDSlider method), method), 48
202 on_color_active()
on__rotation_angle() (kivymd.uix.textfield.MDTextFieldRound
(kivymd.uix.spinner.MDSpinner method), method), 242
71 on_color_icon_root_button()
on_action_button() (kivymd.uix.button.MDFloatingActionButtonSpeedDial
(kivymd.uix.navigationrail.MDNavigationRail method), 69
method), 127 on_color_icon_stack_button()
on_action_button() (kivymd.uix.button.MDFloatingActionButtonSpeedDial
(kivymd.uix.toolbar.MDToolbar method), method), 69
310 Index
KivyMD, Release 0.104.2.dev0
Index 311
KivyMD, Release 0.104.2.dev0
312 Index
KivyMD, Release 0.104.2.dev0
Index 313
KivyMD, Release 0.104.2.dev0
314 Index
KivyMD, Release 0.104.2.dev0
Index 315
KivyMD, Release 0.104.2.dev0
316 Index
KivyMD, Release 0.104.2.dev0
S selector_color (kivymd.vendor.circularTimePicker.CircularNumberPi
scale (kivymd.vendor.circularTimePicker.CircularNumberPicker attribute), 290
attribute), 290 selector_color (kivymd.vendor.circularTimePicker.CircularTimePicke
screen (kivymd.uix.bottomsheet.MDCustomBottomSheet attribute), 292
attribute), 88 set_action_color_button()
scrim_alpha_transition (kivymd.uix.navigationrail.MDNavigationRail
(kivymd.uix.navigationdrawer.MDNavigationDrawer method), 127
attribute), 120 set_action_icon_button()
scrim_color (kivymd.uix.navigationdrawer.MDNavigationDrawer(kivymd.uix.navigationrail.MDNavigationRail
attribute), 119 method), 127
scroll (kivymd.stiffscroll.StiffScrollEffect attribute), set_action_text_button()
270 (kivymd.uix.navigationrail.MDNavigationRail
search (kivymd.uix.filemanager.MDFileManager at- method), 127
tribute), 74 set_bg_color_items()
secondary_font_style (kivymd.uix.menu.MDDropdownMenu
(kivymd.uix.list.BaseListItem attribute), 228 method), 180
secondary_text (kivymd.uix.list.BaseListItem set_box_title_size()
attribute), 228 (kivymd.uix.navigationrail.MDNavigationRail
secondary_text_color method), 127
(kivymd.theming.ThemeManager attribute), 13 set_chevron_down()
secondary_text_color (kivymd.uix.expansionpanel.MDExpansionPanel
(kivymd.uix.list.BaseListItem attribute), 228 method), 55
secondary_theme_text_color set_chevron_up() (kivymd.uix.expansionpanel.MDExpansionPanel
(kivymd.uix.list.BaseListItem attribute), 228 method), 55
sel_day (kivymd.uix.picker.MDDatePicker attribute), set_clearcolor (kivymd.theming.ThemeManager
207 attribute), 14
sel_month (kivymd.uix.picker.MDDatePicker at- set_clearcolor_by_theme_style()
tribute), 207 (kivymd.theming.ThemeManager method),
sel_year (kivymd.uix.picker.MDDatePicker attribute), 15
207 set_color() (kivymd.uix.chip.MDChip method), 100
select_dir_or_file() set_color_menu_item()
(kivymd.uix.filemanager.MDFileManager (kivymd.uix.navigationrail.MDNavigationRail
method), 75 method), 127
select_directory_on_press_button() set_current() (kivymd.uix.swiper.MDSwiper
(kivymd.uix.filemanager.MDFileManager method), 80
method), 75 set_date() (kivymd.uix.picker.MDDatePicker
select_path (kivymd.uix.filemanager.MDFileManager method), 207
attribute), 74 set_item() (kivymd.uix.dropdownitem.MDDropDownItem
selected (kivymd.vendor.circularTimePicker.CircularNumberPickermethod), 214
attribute), 290 set_items_color()
selected_chip_color (kivymd.uix.chip.MDChip (kivymd.uix.navigationrail.MDNavigationRail
attribute), 100 method), 127
selected_color (kivymd.uix.menu.MDDropdownMenuset_items_visible()
attribute), 179 (kivymd.uix.navigationrail.MDNavigationRail
selected_color (kivymd.uix.selectioncontrol.MDCheckbox method), 128
attribute), 155 set_left_action() (kivymd.uix.banner.MDBanner
selection (kivymd.uix.filemanager.MDFileManager method), 131
attribute), 75 set_menu_properties()
selector (kivymd.uix.filemanager.MDFileManager at- (kivymd.uix.menu.MDDropdownMenu
tribute), 75 method), 181
selector_alpha (kivymd.vendor.circularTimePicker.CircularNumberPicker (kivymd.uix.picker.MDDatePicker
set_month_day()
attribute), 290 method), 207
set_normal_height()
selector_alpha (kivymd.vendor.circularTimePicker.CircularTimePicker
attribute), 292 (kivymd.uix.dialog.MDDialog method), 112
Index 317
KivyMD, Release 0.104.2.dev0
318 Index
KivyMD, Release 0.104.2.dev0
Index 319
KivyMD, Release 0.104.2.dev0
320 Index
KivyMD, Release 0.104.2.dev0
tooltip_text_color 207
(kivymd.uix.tooltip.MDTooltipViewClass update_color() (kivymd.uix.selectioncontrol.MDCheckbox
attribute), 217 method), 156
TOUCH_TARGET_HEIGHT (in module update_font_style() (kivymd.uix.label.MDLabel
kivymd.material_resources), 269 method), 166
TouchBehavior (class in update_fps() (kivymd.utils.fpsmonitor.FpsMonitor
kivymd.uix.behaviors.touch_behavior), 250 method), 285
transition_duration update_height() (kivymd.uix.dialog.MDDialog
(kivymd.uix.swiper.MDSwiper attribute), method), 112
79 update_icon() (kivymd.uix.selectioncontrol.MDCheckbox
transition_max (kivymd.stiffscroll.StiffScrollEffect method), 156
attribute), 270 update_icons() (in module
transition_min (kivymd.stiffscroll.StiffScrollEffect kivymd.tools.release.update_icons), 279
attribute), 270 update_init_py() (in module
twist() (kivymd.uix.behaviors.magic_behavior.MagicBehavior kivymd.tools.release.make_release), 278
method), 247 update_md_bg_color()
TwoLineAvatarIconListItem (class in (kivymd.uix.button.MDFillRoundFlatButton
kivymd.uix.list), 230 method), 66
TwoLineAvatarListItem (class in kivymd.uix.list), update_md_bg_color()
229 (kivymd.uix.button.MDFillRoundFlatIconButton
TwoLineIconListItem (class in kivymd.uix.list), method), 66
229 update_md_bg_color()
TwoLineListItem (class in kivymd.uix.list), 229 (kivymd.uix.button.MDRectangleFlatButton
TwoLineRightIconListItem (class in method), 65
kivymd.uix.list), 229 update_md_bg_color()
type (kivymd.uix.banner.MDBanner attribute), 131 (kivymd.uix.button.MDRoundFlatButton
type (kivymd.uix.dialog.MDDialog attribute), 110 method), 65
type (kivymd.uix.navigationdrawer.MDNavigationDrawer update_md_bg_color() (kivymd.uix.card.MDCard
attribute), 119 method), 149
type (kivymd.uix.progressbar.MDProgressBar at- update_pos() (kivymd.uix.navigationdrawer.NavigationLayout
tribute), 212 method), 118
type (kivymd.uix.toolbar.MDToolbar attribute), 188 update_primary_color()
type_swipe (kivymd.uix.card.MDCardSwipe at- (kivymd.uix.selectioncontrol.MDCheckbox
tribute), 150 method), 156
update_readme() (in module
U kivymd.tools.release.make_release), 278
update_scrim_rectangle()
unfocus_color (kivymd.uix.behaviors.focus_behavior.FocusBehavior
attribute), 254 (kivymd.uix.navigationdrawer.NavigationLayout
unselected_color (kivymd.uix.selectioncontrol.MDCheckbox method), 118
attribute), 155 update_status() (kivymd.uix.navigationdrawer.MDNavigationDrawer
unzip_archive() (in module method), 120
kivymd.tools.release.update_icons), 279 update_velocity()
update() (kivymd.stiffscroll.StiffScrollEffect method), (kivymd.stiffscroll.StiffScrollEffect method),
271 270
update() (kivymd.utils.hot_reload_viewer.HotReloadViewer update_width() (kivymd.uix.dialog.MDDialog
method), 287 method), 112
update_action_bar() updated_interval (kivymd.utils.fpsmonitor.FpsMonitor
(kivymd.uix.toolbar.MDToolbar method), attribute), 285
188 url (in module kivymd.tools.release.update_icons), 278
update_action_bar_text_colors() use_access (kivymd.uix.filemanager.MDFileManager
(kivymd.uix.toolbar.MDToolbar method), attribute), 74
188 use_action_button
update_cal_matrix() (kivymd.uix.navigationrail.MDNavigationRail
(kivymd.uix.picker.MDDatePicker method), attribute), 125
Index 321
KivyMD, Release 0.104.2.dev0
use_hover_behavior
(kivymd.uix.navigationrail.MDNavigationRail
attribute), 123
use_pagination (kivymd.uix.datatables.MDDataTable
attribute), 195
use_resizeable (kivymd.uix.navigationrail.MDNavigationRail
attribute), 124
use_title (kivymd.uix.navigationrail.MDNavigationRail
attribute), 125
V
value_transparent
(kivymd.uix.bottomsheet.MDBottomSheet
attribute), 87
ver_growth (kivymd.uix.menu.MDDropdownMenu at-
tribute), 180
vertical_pad (kivymd.uix.banner.MDBanner at-
tribute), 131
visible (kivymd.uix.navigationrail.MDNavigationRail
attribute), 126
W
widget (kivymd.uix.taptargetview.MDTapTargetView
attribute), 45
widget_position (kivymd.uix.taptargetview.MDTapTargetView
attribute), 48
width_mult (kivymd.uix.menu.MDDropdownMenu at-
tribute), 179
width_mult (kivymd.uix.swiper.MDSwiper attribute),
80
width_offset (kivymd.uix.dialog.MDDialog at-
tribute), 110
wobble() (kivymd.uix.behaviors.magic_behavior.MagicBehavior
method), 247
X
xrange() (in module
kivymd.vendor.circularTimePicker), 289
Y
year (kivymd.uix.picker.MDDatePicker attribute), 207
322 Index