Closed Petapton closed 1 week ago
I found out that Chip cannot use different label colors for selected and unselected states.
Make the changes in your callback function:
import flet as ft
def main(page: ft.Page):
def chip_callback(e):
x.label_style.color = ft.colors.YELLOW if x.selected else ft.colors.RED
page.update()
x = ft.Chip(
label=ft.Text(
"Chip",
# color=ft.colors.AMBER
),
label_style=ft.TextStyle(weight=ft.FontWeight.BOLD, italic=True, color=ft.colors.RED),
selected_color=ft.colors.PRIMARY,
check_color=ft.colors.ON_PRIMARY,
on_select=chip_callback,
)
page.add(x)
ft.app(target=main)
Hello, I found out that
Chip
cannot use different label colors for selected and unselected states. Instead, the check mark color can be changed.Here is an example:
Result:
It would be nice if there were a way to set also the label to
colors.PRIMARY
when selected. I think an option could be aselected_label_color
-ish argument. Alternatively, thecheck_color
could be used on label when selected.