Load blocks closed by default?
That should be enough editor.Blocks.getCategories().forEach(ct => ct.set('open', false)) but categories are not created until the render of blocks (which happens, by default, when you click the Blocks tab) so you just need to execute that script once are rendered.
Read full answer below ↓Question
I am using the following bit of code to collapse all the block categories, unfortunately, this is not working
const categories = editor.BlockManager.getCategories();
categories.each(category => {
category.set('open', false).on('change:open', opened => {
opened.get('open') && categories.each(category => {
category !== opened && category.set('open', false)
})
})
})
live demo : https://jsfiddle.net/d4702yoh/2/
What is wrong here?
Answers (4)
That should be enough editor.Blocks.getCategories().forEach(ct => ct.set('open', false)) but categories are not created until the render of blocks (which happens, by default, when you click the Blocks tab) so you just need to execute that script once are rendered.
Hello, i have made it to close all blocks in one plugin, try to adapt to you.:
still the same here jsfidle : https://jsfiddle.net/46mfqeht/
Thanks for reporting this, @throne1986. Great question about load blocks closed by default?. The recommended approach with GrapesJS 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 ac...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2569
[QUESTION] Show all block categories
Hi all, I am using the following bit of code to collapse all the block categories, what would the code be to expand them all?
Issue #3282
CleanId function not working with MJML code
CleanID is still not working for MJML code, even on latest version of grapesJS (0.16.41) It's related to this closed issue : https://github...
Issue #4094
When drag and drop block into editor in Chrome, not able to drag and drop block
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Version 97.0.4692.71 (Official Build) (64-...
Issue #3203
Custom block category question
Hi, I want add attributes to the category of blocks but the don’t apply.
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
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.
Tutorial
GrapesJS vs Webflow vs Tilda (2026): Honest Comparison, Pricing & Which to Pick
GrapesJS vs Webflow vs Tilda compared head-to-head: real 2026 pricing, SEO features, code export, and which one actually fits your project
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.