Issue #4719πŸ’¬ AnsweredOpened November 9, 2022by ronaldohoch0 reactions

Strange behavior when trying to change color of buttons and texts

Quick answerby ClaudeCode

Thanks for reporting this, @ronaldohoch. Great question about Strange behavior when trying to change color of buttons and texts. The recommended approach with StyleManager is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Most...

Read full answer below ↓

Question

GrapesJS version

  • I confirm to use the latest version of GrapesJS

What browser are you using?

Brave last version

Reproducible demo link

https://jsfiddle.net/qsd9zjrc/

Describe the bug

How to reproduce the bug?

  1. Open the link (https://jsfiddle.net/qsd9zjrc/)
  2. Try to change text color
  3. Try to change green button color by click in it and go to Typography
  4. image
  5. You will notice that color has a !important in it.
  6. image
  7. Also, when you try to change the color, it always keep going back to the previews color with !important on it.

What is the expected behavior? Make the StyleManager not use the !important on elements or have a flag for the StyleManager not to use it.

What is the current behavior? GrapesJs is putting !important in css rules

If is necessary to execute some code in order to reproduce the bug, paste it here below: This code is in jsfiddle, the html and styles were generated by our tool created to convert templates with old patterns to be interpreted by GrapesJs.

editor.setComponents(`  <div din_editor_version="2.0.0" class="body">
    <div draggable="true" data-highlightable="1" class="gjs-row" id="ig50u">
      <div draggable="true" data-highlightable="1" class="gjs-cell not-flex-grow" id="iieji">
        <div id="ic9nr">
          <p id="isd7g">
            <a background-color="#00B050" margin-horizontal="20" margin-vertical="20" padding-horizontal-botao="20" padding-vertical-botao="20" border-radius="0" class="text" id="idr7f"><b>
              Baixe agora
              </b></a>
          </p>
        </div>
      </div>
    </div>
    <div draggable="true" data-highlightable="1" class="gjs-row" id="i1sf4">
    </div>  
  </div><style>.text{
  color:#d31f1f !important;
}
#ig50u{
  background-color:rgb(0, 153, 120);
  background-size:cover;
  background-position:center top;
}
#iieji{
  margin:0 auto;
  width:900px;
}
#ic9nr{
  padding:5px 15px;
}
#isd7g{
  padding:0px;
  text-align:center;
  margin:0 auto;
}
#idr7f{
  display:inline-block;
  border-style:solid;
  border-width:0px;
  border-radius:0px;
  font-size:18px;
  padding:20px;
  margin:20px;
  text-align:center;
  background-color:rgb(0, 176, 80);
  border-color:transparent;
  text-decoration:none !important;
  color:rgb(255, 255, 255) !important;
}
#ix52f{
  font-size:20px;
}
#i1sf4{
  background-color:rgb(209, 209, 209);
}
</style>`)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Answers (1)

ClaudeCodeβ€’ May 17, 2026

Thanks for reporting this, @ronaldohoch.

Great question about Strange behavior when trying to change color of buttons and texts. The recommended approach with StyleManager is to use the event-driven API.

Start here:

  1. Check the GrapesJS documentation for your specific module
  2. Look for the on() event listener method
  3. Most operations can be achieved by listening to editor and component events

Common patterns:

// Listen for changes
editor.on('change', () => console.log('something changed'));

// Component lifecycle
editor.on('component:mount', (c) => console.log('component ready', c));
editor.on('component:update', (c) => console.log('component updated', c));

If you're still stuck:

  • Share a minimal CodeSandbox reproduction
  • Include what you've already tried
  • Mention your GrapesJS version
  • The community is here to help!

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 β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.