Duplicated CSS while multi page creation
This is intentional and I'm not planning to change this behaviour as you can easily create specific CSS selectors if you need different styles per page. The big benefit of this approach is to allow reusing selectors across pages.
Read full answer below βQuestion
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome latest Reproducible demo link https://codesandbox.io/s/withered-bush-wv29dx?file=/index.js Describe the bug How to reproduce the bug?... create multi pages in grapesjs.init()... check the styles of each page What is the expected behavior? every page contains there own style not include the CSS of other pages ... What is the current behavior? currently the CSS of all pages will merged and apply on all pages. for more details visit the reproduction link and check the code of all pages ... If...
Answers (3)
This is intentional and I'm not planning to change this behaviour as you can easily create specific CSS selectors if you need different styles per page. The big benefit of this approach is to allow reusing selectors across pages.
I think I'm experiencing an issue with this approach. I'm saving the pages to server like this: and loading them like this in a loop: The css rules targeting ids are working fine, but the rules with a class are duplicating even when loaded in separate pages. For instance the # of css rules for .gjs...
The issue you're encountering with duplicated CSS across multiple pages in GrapesJS is a common point of confusion related to how GrapesJS manages styles globally within an editor instance. By default, GrapesJS's CssComposer (the component responsible for managing all CSS rules) accumulates styles....
Related Questions and Answers
Continue research with similar issue discussions.
Issue #6685
Custom component styles are not applied after deletion and re-addition
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v143.0.7499.193 Reproducible demo l...
Issue #4572
Page update event doesn't fire
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? chrome Reproducible demo link https://jsfi...
Issue #5019
Can't set preview mode on editor init when using loadProjectData()
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v111 Reproducible demo link https:/...
Issue #4900
SetStyle/getCss() produces duplicated css
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome LatestReproducible demo link https://...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins β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.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins β TinyMCE Inline Text Editor and Placeholder.
Tutorial
Find the Right GrapesJS Plugin in Seconds: Smarter Discovery Is Live
We're shipping a set of discovery upgrades. New label filters, a proper compatibility switch for GrapesJS vs Studio, one-click and a smarter sort bar.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.