Styles by ID in components
Question
How do I make the styles of the components I take them by id and not by class
Answers (2)
You can toggle classes, this will change the style selector

The main problem that i have is I'm trying to do a resize in a component that I made, but if I have Two Components equals, when I do the resize one of them the other do the same resize. So, I think that I would need manage the style of them by id and not by class.
This is my code:
`const buttonComponent = {
name: "button-bk",
data: {
id: "button",
label: `Button`,
category: "Basic Components",
draggable: true,
content: `<button class="btn-builder" data-gjs-draggable=".cell" data-gjs-resizable='{"tl":0,"tc":0,"tr":0,"cl":0,"cr":1,"bl":0,"br":0,"minDim":1,"bc":0,"currentUnit":1,"step":0.2}' data-gjs-name="Button">Send</button>`,
},
};
editor.BlockManager.add('button', buttonComponent);
`
View Example https://cl.ly/c4bfaf626adcRelated Questions and Answers
Continue research with similar issue discussions.
Issue #2742
[QUESTION] How to prevent unique ids generation?
Hi! Thanks for your work @artf. This is a simplified code of how I use grapesjs, I want to save the styles and then want to apply them agai...
Issue #2388
[Question] - How to import styles from <link> to be rendered when dragging block to canvas
My situation: I'm slowly importing some of my custom made UI components in ReactJS to GrapesJS. Now, I am able to render the component prop...
Issue #2238
[QUESTION] How to get style for header & footer components only
Hi @artf, can you please tell me what is the fastest and easies way to extract component styles. I have template and in this template you c...
Issue #1323
Loading HTML content inject ids belongs to styles
@artf When I load the html content, this is including in all the components a random identifier that in your examples "Websites" and "Newsl...
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.