Set of widgets for Kivy inspired by Google's Material Design
npx @tessl/cli install tessl/pypi-kivymd@1.1.0KivyMD is a comprehensive Material Design component library for Kivy that provides a collection of Material Design compliant widgets and components for building cross-platform, touch-enabled graphical applications. The library includes over 40 UI components including buttons, cards, navigation drawers, app bars, text fields, and complex widgets like data tables and date pickers, all following Google's Material Design specifications.
pip install kivymdkivy>=2.0.0, pillowimport kivymdCommon application setup:
from kivymd.app import MDApp
from kivymd.theming import ThemeManagerWidget imports:
from kivymd.uix.button import MDRaisedButton, MDFlatButton, MDIconButton
from kivymd.uix.label import MDLabel
from kivymd.uix.textfield import MDTextField
from kivymd.uix.card import MDCard
from kivymd.uix.list import MDList, OneLineListItem
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.gridlayout import MDGridLayoutColor and theming imports:
from kivymd.color_definitions import colors, palette
from kivymd.theming import ThemableBehaviorUtility imports:
from kivymd.toast import toastfrom kivymd.app import MDApp
from kivymd.uix.label import MDLabel
from kivymd.uix.button import MDRaisedButton
from kivymd.uix.boxlayout import MDBoxLayout
class MainApp(MDApp):
def build(self):
# Create main layout
layout = MDBoxLayout(
orientation="vertical",
adaptive_height=True,
spacing="20dp",
pos_hint={"center_x": 0.5, "center_y": 0.5}
)
# Add label
label = MDLabel(
text="Hello, Material Design!",
halign="center",
theme_text_color="Primary"
)
# Add button
button = MDRaisedButton(
text="Click Me",
pos_hint={"center_x": 0.5}
)
layout.add_widget(label)
layout.add_widget(button)
return layout
MainApp().run()KivyMD follows a structured architecture built on Kivy's foundation:
This architecture ensures consistent Material Design aesthetics across all platforms while maintaining Kivy's cross-platform capabilities and performance characteristics.
Core application classes and theming system for Material Design applications, including the main app class, theme management, and Material Design resource definitions.
class MDApp:
"""Main application class with Material Design theming."""
def build(self): ...
class ThemeManager:
"""Central theme management system."""
primary_palette: str
accent_palette: str
theme_style: str # "Light" or "Dark"
class ThemableBehavior:
"""Mixin behavior for themed widgets."""
theme_cls: ThemeManagerMaterial Design layout containers including box layouts, grid layouts, cards, and responsive layouts that follow Material Design spacing and elevation guidelines.
class MDBoxLayout:
"""Material Design box layout."""
orientation: str
adaptive_height: bool
adaptive_width: bool
spacing: str
class MDCard:
"""Material Design card container."""
elevation: float
radius: list
md_bg_color: strComplete set of Material Design buttons including raised buttons, flat buttons, icon buttons, floating action buttons, and speed dial components.
class MDRaisedButton:
"""Material Design raised button with elevation."""
text: str
theme_text_color: str
md_bg_color: str
class MDIconButton:
"""Material Design icon-only button."""
icon: str
theme_icon_color: str
class MDFloatingActionButton:
"""Material Design floating action button."""
icon: str
type: str # "standard" or "large"Buttons & Interactive Elements
Text display and input components including labels, icons, text fields, and selection controls following Material Design text and input specifications.
class MDLabel:
"""Material Design label."""
text: str
theme_text_color: str
font_style: str
class MDTextField:
"""Material Design text input field."""
hint_text: str
text: str
helper_text: str
error: bool
class MDCheckbox:
"""Material Design checkbox."""
active: bool
disabled: boolComprehensive list components including various list item types, data tables, and image lists for displaying structured data with Material Design styling.
class MDList:
"""Material Design list container."""
class OneLineListItem:
"""Single line list item."""
text: str
class MDDataTable:
"""Material Design data table."""
column_data: list
row_data: list
sorted_on: strNavigation components including app bars, navigation drawers, bottom navigation, tabs, and navigation rails for Material Design navigation patterns.
class MDTopAppBar:
"""Material Design top app bar."""
title: str
left_action_items: list
right_action_items: list
class MDNavigationDrawer:
"""Material Design navigation drawer."""
type: str # "standard" or "modal"
class MDBottomNavigation:
"""Material Design bottom navigation."""
panel_color: strDialog and overlay components including dialogs, bottom sheets, menus, snackbars, and tooltips for Material Design interaction patterns.
class MDDialog:
"""Material Design dialog."""
title: str
text: str
buttons: list
class MDBottomSheet:
"""Material Design bottom sheet."""
class MDDropdownMenu:
"""Material Design dropdown menu."""
items: list
width_mult: floatAdvanced UI components including date/time pickers, expansion panels, chips, segmented controls, and specialized widgets for complex interactions.
class MDDatePicker:
"""Material Design date picker."""
year: int
month: int
day: int
class MDExpansionPanel:
"""Material Design expansion panel."""
content: object
panel_cls: object
class MDChip:
"""Material Design chip."""
text: str
icon: str
check: boolAnimation and visual effect components including transitions, hero animations, ripple effects, and elevation behaviors for Material Design motion.
class MDFadeSlideTransition:
"""Fade slide transition for screen manager."""
class MDHeroFrom:
"""Hero animation source widget."""
tag: str
class CircularRippleBehavior:
"""Circular ripple effect behavior."""
ripple_color: str
ripple_alpha: floatUtility functions for common operations and cross-platform functionality.
def toast(text: str = "", background: list = None, duration: float = 2.5):
"""
Display cross-platform toast notification.
Shows a brief message to the user that disappears automatically
after the specified duration. Implementation varies by platform.
Args:
text (str): Message text to display (default: "")
background (list): Background color as [r, g, b, a] values (default: None)
duration (float): Display duration in seconds (default: 2.5)
"""# Common type definitions used across KivyMD components
# Color specifications
ColorType = str | tuple | list # Color as string name, hex, or RGB/RGBA values
# Spacing and sizing
SpacingType = str | int | float # Spacing as dp string or numeric value
# Icon specifications
IconType = str # Material Design icon name from md_icons
# Theme specifications
ThemeStyle = str # "Light" or "Dark"
PaletteType = str # Color palette name (e.g., "Red", "Blue", "Green")
FontStyle = str # Font style name (e.g., "H1", "H2", "Body1", "Caption")
# Widget sizing
SizeHintType = tuple | None # Size hint as (width, height) or None
AdaptiveSizeType = bool # Whether widget should adapt to content size
# Touch and interaction
RippleColorType = str | tuple # Ripple effect color specification
ElevationType = int | float # Elevation level (0-24)
# List and menu item data
ListItemType = dict # Dictionary with "text", "icon", and callback keys
MenuItemType = dict # Dictionary with "text", "icon", "on_release" keys
# Transition types
TransitionType = str # Transition name for screen manager