0%

Color picker

A color picker is a widget that allows users to input colors using three sliders for the components of the HCT color system: hue, chroma, and tone. The tooltip for each slider contains more information about each component.

Properties

You can make a color picker and set its starting color to any color:

core.NewColorPicker(b).SetColor(colors.Orange)

Events

You can detect when a user changes the color:

cp := core.NewColorPicker(b).SetColor(colors.Green)
cp.OnChange(func(e events.Event) {
    core.MessageSnackbar(cp, colors.AsHex(cp.Color))
})

You can detect when a user changes the color as they slide (input):

cp := core.NewColorPicker(b).SetColor(colors.Green)
cp.OnInput(func(e events.Event) {
    core.MessageSnackbar(cp, colors.AsHex(cp.Color))
})

Color button

You can make a button that opens a color picker dialog:

core.NewColorButton(b).SetColor(colors.Purple)

You can detect when a user changes the color using the dialog:

cb := core.NewColorButton(b).SetColor(colors.Gold)
cb.OnChange(func(e events.Event) {
    core.MessageSnackbar(cb, colors.AsHex(cb.Color))
})