Skip to content

Palette Picker

The palette picker selects a color from a predefined palette. The field shows the current color, a click opens a dialog with the palette. colorpicker.DefaultPalette contains a balanced set of colors.

Palette Picker

func view(wnd core.Window) core.View {
    color := core.AutoState[Color](wnd).Init(func() Color { return colorpicker.DefaultPalette[3] })

    return colorpicker.PalettePicker("Label color", colorpicker.DefaultPalette).
        Value(color.Get()).
        State(color).
        Title("Choose a color").
        SupportingText("Used for the label in the calendar").
        Frame(Frame{Width: L320})
}

Constructors

func PalettePicker(label string, p Palette) TPalettePicker

PalettePicker creates a color picker with the given label which offers the colors of the palette, e.g. colorpicker.DefaultPalette.

Methods

MethodDescription
AccessibilityLabel(label string) ui.DecoredViewAccessibilityLabel sets the label for screen readers.
Border(border ui.Border) ui.DecoredViewBorder sets the border.
Dialog(pickerPresented *core.State[bool]) core.ViewDialog returns the dialog view as if pressed on the actual button.
Disabled(disabled bool) TPalettePickerDisabled disables the user interaction.
ErrorText(text string) TPalettePickerErrorText sets a validation message below the field.
Frame(frame ui.Frame) ui.DecoredViewFrame sets the layout frame.
Padding(padding ui.Padding) ui.DecoredViewPadding sets the inner padding.
State(state *core.State[ui.Color]) TPalettePickerState attaches the given state to the interaction process of selecting a value.
SupportingText(text string) TPalettePickerSupportingText sets a hint below the field.
Title(title string) TPalettePickerTitle sets the title of the palette dialog.
Value(color ui.Color) TPalettePickerValue sets the selected value.
Visible(visible bool) ui.DecoredViewVisible shows or hides the component.
WithFrame(fn func(ui.Frame) ui.Frame) ui.DecoredViewWithFrame transforms the current frame with the given function.

Related