Issue #3119💬 AnsweredOpened November 6, 2020by makkaronis4e0 reactions

How to create custom block made of grapesjs components?

Quick answerby artf

You should be able to do something like this:

Read full answer below ↓

Question

Hi, i want to have custom blocks made of grapesjs components.

I found solution how to add components: https://github.com/artf/grapesjs/issues/1334#issuecomment-411519845 but i'm struggling with adding CSS (eaiher as string or as object).

Answers (4)

artfNovember 9, 2020

You should be able to do something like this:

...
components: [
  { tagName: 'h1', components: 'Some <b>content</b>', },
  '<style>....</style>'
]
makkaronis4eNovember 9, 2020

@artf thanks it works, but i found bug there. When you drop this block on canvas it works ok, but if you delete this element from canvas or clear whole canvas, then drop this block on canvas 2nd time, it will lose css. 2nd time, 3rd time.. doesnt matter, If you removed element from canvas once, it...

artfNovember 18, 2020

@makkaronis4e for such a case, I'd ask you a reproducible demo, please

GJSBlockMay 17, 2026

Thanks for reporting this, @makkaronis4e. Great question about [QUESTION] How to create custom block made of grapesjs components?. 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...

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.