Assign style to class not ID
Just create blocks/components with classes and, by default, the Style Manager will apply styles to them
Read full answer below ↓Question
What I'm trying to achieve is whenever the "block" inside of the canvas is edited the style isn't added to an #id but instead added to a class. My logic is to take the current ID that is used - the random string and remove it as the ID and make it a class and then assign styles to that class instead of the ID, yes it'll result in lots of classes but it'll mean I won't have issues with ID's on the frontend. I can't seem to find how to do this though, whenever I do it on: editor.on('component:update', component => {}) It just doesn't work. The ID is always undefined. component.getAttributes()['...
Answers (3)
Just create blocks/components with classes and, by default, the Style Manager will apply styles to them
Just create blocks/components with classes and, by default, the Style Manager will apply styles to them Hi! Can you please tell if we can switch off this behaviour. I want to editor to setup CSS style to element id instead of class names. As same class can be assigned to different elements, which c...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2706
[QUESTION] Unique ID on block content without inline style
Hi All, I made a custom block manager element, but when the element is edited, it applies the style to the class, which means all the same...
Issue #3252
Does getHtml() remove the inline style property?
I was fiddling with ways that you could change the style of elements inside the canvas and i noticed that by using the color-picker trait t...
Issue #4273
How to trigger the 'Import Template (modal)' on page load
Hello, Please i'm in need of the logic on how to the import template modal on initialization of the page... I'm using the newsletter preset...
Issue #3674
Invisible webcomponents
Version: 0.17.19 What is the current behavior? That the added webcomponent is visible: When adding web components inside grapesjs container...
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.