Issue #442πŸ’¬ AnsweredOpened October 21, 2017by roytang0 reactions

Is it possible to include an external stylesheet in the grapesjs canvas?

Quick answerby roytang

Please ignore. I ended up injecting the stylesheet link using javascript into Grapes' canvas' iframe // insert external stylesheet into the grapesjs window var iframes = Utilities_GetElementsByClass("gjs-frame", "IFRAME", document.body); for (var i=0; i<iframes.length; i++) { var iframe = iframes[i]; var doc = iframe....

Read full answer below ↓

Question

We want to create some custom components whose style changes according to an external theme css (there can be different themes), and we want those styles to appear in the canvas while editing.

Answers (3)

roytangβ€’ October 21, 2017

Please ignore. I ended up injecting the stylesheet link using javascript into Grapes' canvas' iframe // insert external stylesheet into the grapesjs window var iframes = Utilities_GetElementsByClass("gjs-frame", "IFRAME", document.body); for (var i=0; i<iframes.length; i++) { var iframe = iframes[i...

artfβ€’ October 23, 2017

You can inject scripts/styles via canvas config option

const editor = grapesjs.init({
  ...
  canvas: {
    styles: ['https://...', '...'],
    scripts: ['https://...'],
  }
});
roytangβ€’ October 23, 2017

Thanks!

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.