Skip to main content

MaterialPicker

A material palette picker for selecting primary and shade colors, with optional shade labels.

MaterialPicker
Basic MaterialPicker

Inherits: LayoutControl

Properties

Events

Example

import flet as ft
from flet_color_pickers import MaterialPicker


def main(page: ft.Page):
page.title = "MaterialPicker"
page.padding = 20

def on_color_change(e: ft.ControlEvent):
print(f"color: {e.data}")

def on_primary_change(e: ft.ControlEvent):
print(f"primary: {e.data}")

picker = MaterialPicker(
color="#ff9800",
on_color_change=on_color_change,
on_primary_change=on_primary_change,
)

page.add(ft.SafeArea(content=picker))


if __name__ == "__main__":
ft.run(main)

Properties

colorclass-attributeinstance-attribute

color: Optional[ColorValue] = None

The currently selected color.

enable_labelclass-attributeinstance-attribute

enable_label: bool = False

Whether to show color shade labels.

portrait_onlyclass-attributeinstance-attribute

portrait_only: bool = False

Whether to force portrait layout.

Events

on_color_changeclass-attributeinstance-attribute

on_color_change: Optional[ControlEventHandler[MaterialPicker]] = None

Called when the picker color is changed.

The data property of the event handler argument contains the color value as a hex string.

on_primary_changeclass-attributeinstance-attribute

on_primary_change: Optional[ControlEventHandler[MaterialPicker]] = None

Called when the primary color is changed.

The data property of the event handler argument contains the color value as a hex string.