Set of widgets for Kivy inspired by Google's Material Design
—
Material Design layout containers that provide structure and organization for user interfaces. These layouts follow Material Design spacing and elevation guidelines while providing the flexibility needed for responsive design across different screen sizes and orientations.
Standard layout containers with Material Design styling and adaptive sizing capabilities.
class MDBoxLayout:
"""
Material Design box layout container.
Arranges children in a vertical or horizontal line with Material Design
spacing and adaptive sizing options.
"""
orientation: str # "vertical" or "horizontal"
adaptive_height: bool # Adapt height to children's minimum height
adaptive_width: bool # Adapt width to children's minimum width
adaptive_size: bool # Adapt both width and height
spacing: str | int # Spacing between children (e.g., "10dp" or 10)
padding: str | list # Padding around container
class MDGridLayout:
"""
Material Design grid layout container.
Arranges children in a grid with specified columns and rows.
"""
cols: int # Number of columns
rows: int # Number of rows (optional, calculated if not set)
spacing: str | int # Spacing between grid items
padding: str | list # Padding around container
class MDFloatLayout:
"""
Material Design float layout container.
Allows absolute positioning of children with pos_hint for relative positioning.
"""
class MDRelativeLayout:
"""
Material Design relative layout container.
Positions children relative to the layout or other children.
"""
class MDStackLayout:
"""
Material Design stack layout container.
Arranges children in rows or columns, wrapping to new lines as needed.
"""
orientation: str # Layout orientation
spacing: str | int # Spacing between items
class MDAnchorLayout:
"""
Material Design anchor layout container.
Anchors children to edges or center of the layout.
"""
anchor_x: str # "left", "center", "right"
anchor_y: str # "bottom", "center", "top"Advanced layout containers for specific Material Design patterns and responsive design.
class MDCircularLayout:
"""
Circular layout that arranges children in a circle.
Useful for creating circular menus, radial layouts, and decorative arrangements.
"""
start_from: float # Starting angle in degrees
max_degree: float # Maximum degree span
class MDResponsiveLayout:
"""
Responsive layout that adapts to different screen sizes.
Automatically adjusts layout and sizing based on device type and orientation.
"""
mobile_view: object # Layout for mobile devices
tablet_view: object # Layout for tablet devices
desktop_view: object # Layout for desktop devicesScreen and screen manager components for managing multiple views in applications.
class MDScreen:
"""
Material Design screen container.
Represents a single screen in a multi-screen application with Material Design styling.
"""
name: str # Unique screen name
manager: object # Reference to screen manager
class MDScreenManager:
"""
Material Design screen manager.
Manages multiple screens with smooth transitions and Material Design animations.
"""
transition: object # Transition animation between screens
current: str # Name of currently displayed screen
def add_widget(self, screen: MDScreen):
"""
Add a screen to the manager.
Args:
screen (MDScreen): Screen to add
"""
def get_screen(self, name: str) -> MDScreen:
"""
Get screen by name.
Args:
name (str): Screen name
Returns:
MDScreen: Screen instance
"""Card-based containers that provide elevated surfaces for content grouping.
class MDCard:
"""
Material Design card container.
Provides an elevated surface for grouping related content with consistent
Material Design styling including shadows, rounded corners, and theming.
"""
elevation: float # Card elevation (shadow depth)
radius: list # Corner radius [top-left, top-right, bottom-right, bottom-left]
md_bg_color: str | list # Background color
line_color: str | list # Border line color
style: str # Card style: "elevated" or "outlined"
# Ripple effect properties
ripple_behavior: bool # Enable ripple effect on touch
class MDCardSwipe:
"""
Swipeable card container with reveal actions.
Card that can be swiped to reveal action buttons or additional content.
"""
type_swipe: str # "auto" or "hand" - swipe type
open_progress: float # Swipe open progress (0-1)
def open_card(self):
"""Open the swipe card to reveal actions."""
def close_card(self):
"""Close the swipe card."""
class MDCardSwipeFrontBox:
"""Front content box for swipeable card."""
class MDCardSwipeLayerBox:
"""Layer content box (revealed on swipe) for swipeable card."""Visual separator components for organizing content within layouts.
class MDSeparator:
"""
Material Design separator line.
Provides visual separation between content sections with consistent
Material Design styling and theming.
"""
color: str | list # Separator color
height: str # Separator height (e.g., "1dp")
orientation: str # "horizontal" or "vertical"Scrollable layout containers for content that exceeds screen bounds.
class MDScrollView:
"""
Material Design scroll view container.
Provides scrollable viewport for content larger than the container with
Material Design scroll indicators and behavior.
"""
scroll_type: list # Scroll directions: ["bars", "content"]
bar_width: str # Scrollbar width
effect_cls: object # Scroll effect class
def scroll_to(self, widget):
"""
Scroll to make widget visible.
Args:
widget: Widget to scroll to
"""Base behavior that provides adaptive sizing capabilities to layout containers.
class MDAdaptiveWidget:
"""
Base widget with adaptive sizing behaviors.
Provides automatic size adaptation based on content with Material Design
spacing and layout guidelines.
"""
adaptive_height: bool # Adapt height to minimum height
adaptive_width: bool # Adapt width to minimum width
adaptive_size: bool # Adapt both dimensions
def on_adaptive_height(self, instance, value: bool):
"""Handle adaptive height changes."""
def on_adaptive_width(self, instance, value: bool):
"""Handle adaptive width changes."""
def on_adaptive_size(self, instance, value: bool):
"""Handle adaptive size changes."""from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.card import MDCard
from kivymd.uix.label import MDLabel
# Create main layout
layout = MDBoxLayout(
orientation="vertical",
adaptive_height=True,
spacing="16dp",
padding="16dp"
)
# Create cards with content
for i in range(3):
card = MDCard(
elevation=4,
radius=[8, 8, 8, 8],
md_bg_color="white",
size_hint_y=None,
height="100dp",
padding="16dp"
)
label = MDLabel(
text=f"Card {i + 1}",
theme_text_color="Primary"
)
card.add_widget(label)
layout.add_widget(card)from kivymd.uix.gridlayout import MDGridLayout
from kivymd.uix.card import MDCard
# Create responsive grid
grid = MDGridLayout(
cols=2, # Will adapt based on screen size
spacing="16dp",
adaptive_height=True,
padding="16dp"
)
# Add cards to grid
for i in range(6):
card = MDCard(
elevation=2,
size_hint_y=None,
height="120dp"
)
grid.add_widget(card)Install with Tessl CLI
npx tessl i tessl/pypi-kivymd