Issue #2502💬 AnsweredOpened January 11, 2020by electrotype0 reactions

Setting the initial color of the color picker

快速解答by artf

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)

Read full answer below ↓

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, 2020

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, 2020

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, 2020

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.