Issue #2502Opened January 11, 2020by electrotype0 reactions

Setting the initial color of the color picker

Question

I'm trying to set an inital color different than black for the color picker:

grapesjs.init({
    // ...
    colorPicker: { 
        color: '#3777B4',
        showAlpha: false,
        showPalette: false,
        preferredFormat: "hex",
        appendTo: 'parent', 
        offset: { 
            top: 26, 
            left: -190 
        }
    }
));

This doesn't work, even if color is a valid option.

Is there a way to set this initial color?

I'm open to solutions even if they don't use the config directly but involve some hacky code.

Answers (3)

artfJanuary 12, 20200 reactions

It doesn't make sense setting a default value on it, the color picker takes the color from the selected target (probably you want to change the color on the component level)

electrotypeJanuary 12, 20200 reactions

Well, black doesn't make sense either. I would prefere the selected color on the picker to be something else by default, when the component doesn't have any color.

artfJanuary 12, 20200 reactions

Try to see if changing the defaults color of the property from the Style Manager works for you. You can do it from initialization or via API

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.