Skip to main content

ColorPicker

A Fluent color picker: a color spectrum with sliders and text fields to pick a color.

Example:

fluent.ColorPicker(value="#0078d4", show_more_button=False)
ColorPicker
ColorPicker

Inherits: LayoutControl

Properties

Events

  • on_change - Called when the user changes the color.

Example​

Fluent ColorPicker​

Sourceplay_arrowTry Online
import flet_fluent_ui as fluent

import flet as ft


def main(page: ft.Page):
page.title = "Fluent ColorPicker"

def handle_change(e: ft.Event[fluent.ColorPicker]):
swatch.bgcolor = e.control.value
label.value = e.control.value

swatch = ft.Container(width=80, height=80, border_radius=8, bgcolor="#ff0078d4")
label = ft.Text("#ff0078d4")

page.add(
ft.SafeArea(
content=ft.Row(
vertical_alignment=ft.CrossAxisAlignment.START,
controls=[
fluent.ColorPicker(
key="picker",
value="#ff0078d4",
show_more_button=False,
on_change=handle_change,
),
ft.Column(controls=[swatch, label]),
],
)
)
)


if __name__ == "__main__":
ft.run(main)
color_picker
Picking a red from the spectrum

Properties​

alpha_enabledclass-attributeinstance-attribute​

alpha_enabled: bool = True

Whether the color can be partly transparent.

horizontalclass-attributeinstance-attribute​

horizontal: bool = False

Whether the inputs are shown next to the spectrum, instead of below it.

max_brightnessclass-attributeinstance-attribute​

max_brightness: int = 100

The largest brightness offered, from 0 to 100.

max_hueclass-attributeinstance-attribute​

max_hue: int = 359

The largest hue offered, from 0 to 359.

max_saturationclass-attributeinstance-attribute​

max_saturation: int = 100

The largest saturation offered, from 0 to 100.

min_brightnessclass-attributeinstance-attribute​

min_brightness: int = 0

The smallest brightness offered, from 0 to 100.

min_hueclass-attributeinstance-attribute​

min_hue: int = 0

The smallest hue offered, from 0 to 359.

min_saturationclass-attributeinstance-attribute​

min_saturation: int = 0

The smallest saturation offered, from 0 to 100.

show_alpha_inputclass-attributeinstance-attribute​

show_alpha_input: bool = True

Whether an opacity field is shown, when alpha_enabled.

show_alpha_sliderclass-attributeinstance-attribute​

show_alpha_slider: bool = True

Whether an opacity slider is shown, when alpha_enabled.

show_channel_inputsclass-attributeinstance-attribute​

show_channel_inputs: bool = True

Whether fields for the red, green and blue (or hue, saturation and value) channels are shown.

show_color_sliderclass-attributeinstance-attribute​

show_color_slider: bool = True

Whether a brightness slider is shown below the spectrum.

show_hex_inputclass-attributeinstance-attribute​

show_hex_input: bool = True

Whether a field for the hexadecimal color code is shown.

show_more_buttonclass-attributeinstance-attribute​

show_more_button: bool = True

Whether the color channel inputs are hidden behind a "More" button.

If False, the inputs are always shown (if enabled by show_channel_inputs and show_hex_input).

show_previewclass-attributeinstance-attribute​

show_preview: bool = True

Whether a swatch of the selected color is shown next to the spectrum.

spectrum_shapeclass-attributeinstance-attribute​

The shape of the color spectrum.

valueclass-attributeinstance-attribute​

value: ColorValue | None = None

The selected color.

If None, the picker starts at Fluent blue (#0078D4). After the user picks a color, it holds a #aarrggbb string.

Events​

on_changeclass-attributeinstance-attribute​

on_change: ControlEventHandler[ColorPicker] | None = None

Called when the user changes the color.

value holds the new color.