BUG / Feature? Applying background color to body component isn't part of the exported HTML.
Question
Hi Art, thanks for creating such a fantastic project!
I'm not sure if this would be considered a bug or feature request...but I'm having issues deciding how to hande the background color on the body while using the newsletter plugin with GrapesJS.
Steps to Reproduce:
- Select the body (root element) in the canvas.
- In the style palette under "decorations" >> "Background" -- select a color to fill the body with
- Click export HTML, only the children elements are provided, so when the output HTML is used, it has no wrapper to apply the background color with.
If there is a way to handle this correctly that I'm missing, I'm not sure. I am considering manually wrapping the HTML in a table or div that applies the color or something like that??
Thanks in Advance for any and all assistance.

Answers (3)
@mhowey I have seen this also, but I always assumed that the body is just the placeholder canvas for the content. Changes to the body do not export since the content placed in the body is the only thing being exported. In my application use, the body color change is used just to visualize what the content will look like when I place it on my site if the site has a background color.
You can use this option
grapesjs.init({
exportWrapper: true,
})
Thanks for the reply @JoshLucio . I'm using the newsletter preset plugin, which I believe is more targeted toward HTML email, rather than site building. I was actually thinking what you said to be the case, and I've explored all the getWrapper and getWrapperEl methods that Grapes provides, but they do not seem to carry any styling with them.
@artf - is the only way to accomplish this by manually wrapping the exported html? Thanks!
> @mhowey I have seen this also, but I always assumed that the body is just the placeholder canvas for the content. Changes to the body do not export since the content placed in the body is the only thing being exported. In my application use, the body color change is used just to visualize what the content will look like when I place it on my site if the site has a background color.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2928
BUG: Select the initial background color doesn't work
Version: 0.16.18 Bug: Select the initial background color is not working How to reproduce it: https://imgur.com/xqkt46E Actually:Component'...
Issue #2069
[BUG] `allowScripts: true` still deletes <script> tags
Hi all. Thanks for creating and maintaining this amazing project. 🙏 Bug Description I have a block that inserts a script as specified here...
Issue #4447
BUG: Style manager does not accurately reflect inherited color
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? 103.0.5060.114 Reproducible demo link http...
Issue #1745
[Feature]: Allow to import HTML documents
Hi Team, We are using grapesjs newsletter plugin in our project for importing and preview the template. We are facing some difficulty in re...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.