Issue #1739✓ SolvedOpened January 22, 2019by Soharab-Shaikh2 reactions

How to load dynamic CSS style(Not Link) into the Canvas head

Quick answerby artf2

Do this

Read full answer below ↓

Question

Hi, First of all thanks for your great Work !!!!! I am trying to load a dynamic style into the canvas head. Is there any way to load dynamic object or string into the canvas head. var customeCss = "h1 { color:#000000; font-family:Courier; font-style:italic;; }" var editor = grapesjs.init({ ............................................................ canvas: { scripts: [ "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"], styles: [customeCss] //Is there any way to do so. } ............................................................ }); I need your help. Thanks,

Answers (2)

👍 Most helpfulartfJanuary 22, 2019

Do this

const head = editor.Canvas.getDocument().head;
head.insertAdjacentHTML('beforeend', `<style>YOUR CSS</style>`)
lock[bot]January 24, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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.