Canvas style css
Question
Hi guys instead of styling in the init in this way...
it's possibile to use a scss file in canvas? canvas { style:['__FILE__.SCSS'] }
or simple make it cleaner with a single init css?
Thank you!
` myComponent.append(<style>
body {
background: rgb(204,204,204);
}
.footer {
position: absolute;
bottom: 5mm;
width: auto;
left: 5mm;
right: 5mm;
}
.footer-container {
padding: 7px 88px 7px 96px;
}
.footer-text:nth-child(2) {
float:right;
}
.footer-text {
font-size: 11px;
}
.logo-noovle img{
height: 41px;
width: 211px;
}
.logo-placeholder img{
float: right;
height: 68px;
width: 191px;
}
.page {
background: white;
display: block;
margin: 0 auto;
margin-bottom: 0.5cm;
position: relative;
padding: 5mm;
overflow:hidden;
}
.page[size="A4"] {
width: 21cm;
height: 29.7cm;
}
@media print {
body, .page {
margin: 0;
box-shadow: 0;
}
}
.gjs-pn-buttons {
display: none;
}
.gjs-logo{
height:25px;
}
.gjs-cell {
min-height: 75px;
flex-grow: 1;
flex-basis: 100%;
}
.gjs-row {
display: flex;
justify-content: flex-start;
align-items: stretch;
flex-wrap: nowrap;
padding: 10px;
}
</style>);`Answers (3)
You can use canvasCSS option if you don't want to use files.
Thank you very much! This config file is gonna help me a lot!
Thanks for reporting this, @devtechk.
Great question about canvas style css. 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 listener method - Most operations can be achieved by listening to editor and component events
Common patterns:
// Listen for changes
editor.on('change', () => console.log('something changed'));
// Component lifecycle
editor.on('component:mount', (c) => console.log('component ready', c));
editor.on('component:update', (c) => console.log('component updated', c));
If you're still stuck:
- Share a minimal CodeSandbox reproduction
- Include what you've already tried
- Mention your GrapesJS version
- The community is here to help!
Related Questions and Answers
Continue research with similar issue discussions.
Issue #4138
Unexpected behavior in style manager
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Version 1.35.101 Chromium: 98.0.4758.87 (Off...
Issue #4116
Flex Property not working in style manager
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Version 1.34.81 Chromium: 97.0.4692.99 (Of...
Issue #3222
How to refresh/re-render after new node added?
I manually add a new node into a rendered component. The visual result is OK, but impossible to save, because my style isn't with the auto-...
Issue #4739
css class name with '/' converted to '-'
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Edge Version 107.0.1418.52 (Official build)...
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 →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.