How to control the height of the editor dynamically to avoid clunky scrolling
try to work with vh instead of px. eg: give the editor height: '80vh', your navbar height: '20vh'. This way, the vertical scroll will never be shown or needed as long as the sum of all elements's vh ≤ 100 Hope this helps.
Read full answer below ↓Question
I've noticed if in the initialise function I set a height it will set based on a specific pixel amount e.g. height: "500px". However if you try to set with a percentage e.g. height: "90%" the editor has no height at all.
Also I'm wondering what is setting the height if nothing is set because it appears to be automatically calculating a pixel amount that consumes the entire page (e.g. 100%).
I actually have the editor wrapped inside a standard page template we have in the back-end of our CMS, and this page template actually has more content in side menu bars which forces the page to become a scrollable page (i.e. the content from the page template always goes below the fold of the screen). This makes the editor function really poorly, because if you want to scroll beneath the editor you have to move the cursor outside of the editor and scroll, and it leads to poor user experience.
I also have a "save" button which submits to a form and this is not part of the editor, so in order to get to the save button you have to again move the cursor out of the editor area and scroll - it's not ideal.
I have considered dropping my page template on the editor and allowing it to go almost full screen if you like, but I still have the issue of the save button needing to be directly below the editor. What is my best option here? I had thought if I dynamically set the height of the editor to say 80-90% that would leave room beneath it but it doesn't work.
Any insight would be greatly appreciated as I have been wrapping my brain on this one for days.
Answers (4)
try to work with vh instead of px.
eg: give the editor height: '80vh', your navbar height: '20vh'. This way, the vertical scroll will never be shown or needed as long as the sum of all elements's vh ≤ 100
Hope this helps.
try to work with
vhinstead ofpx.eg: give the editor
height: '80vh', your navbarheight: '20vh'. This way, the vertical scroll will never be shown or needed as long as the sum of all elements'svh≤ 100Hope this helps.
thanks this is useful!
This is more a layout issue and not related to the GrapesJS editor itself.
Thanks for reporting this, @samichamoun.
Great suggestion about How to control the height of the editor dynamically to avoid clunky scrolling! While this specific feature isn't yet in the core API, there are several ways to achieve similar behavior.
Using the event system:
editor.on('component:update', (component) => {
// your logic here
});
Alternative approaches:
- Listen to
selector:addfor CSS selector changes - Use
selector:customfor custom rules - Tap into the
change:*events for fine-grained tracking - Build a plugin that extends the editor with this capability
Making it official: If this feature would benefit many users, consider opening a formal Feature Request on the GrapesJS repo with:
- A detailed use case
- Code example showing the desired behavior
- Why this matters for your workflow
The core team is receptive to well-motivated feature requests backed by real use cases.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3558
FEAT: Support Content-Security-Policy
To reduce the possible attack surface if the editor is used in "hostile" environments (e.g. in SaaS platforms) support for CSP is required....
Issue #3269
Translating html string
Great library! It meets all the requirements but one: website text translation. I've searched high and low through the issue queue and docs...
Issue #4250
init() method typings error
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v 100.0.4896.75 Reproducible demo l...
Issue #3194
How do I repurpose the Spectrum Color Picker?
I would like to repurpose the color picker used in GrapesJS. I have to use a color picker for some project level settings. These settings a...
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.