simonh1000 / elm-colorpicker / ColorPicker

An Elm library to help you implement a color picker tool.


type State

Opaque type. Needs to be added to your model. You will also need to store a Color in your model

type alias Model =
    { myColour : Color
    , colorPicker : ColorPicker.Model
    }


type Msg

Opaque type. These messages are handled by ColorPicker.update

empty : State

Initial ColorPicker state

init =
    { myColour = Color.red
    , colorPicker = ColorPicker.empty
    }

update : Msg -> Color -> State -> ( State, Maybe Color )

On each update, ColorPicker returns its model and (where appropriate) the new selected colo(u)r.

ColorPickerMsg msg ->
    let
        (cp, col) =
            ColorPicker.update msg model.colorPicker
    in
        { model | colorPicker = cp, myColor = Maybe.withDefault model.myColor col }