Get CSS of selected component ?
You could listen the event component:selected, then you could get the component's DOM element from that. Afterwards, you could simply use javascript to get style of that component. About getting style by javascript, you can check this link How to get CSS values in JavaScript Here is an example:
Read full answer below ↓Question
Hello how can i get css of selected component ?
Answers (3)
You could listen the event component:selected, then you could get the component's DOM element from that. Afterwards, you could simply use javascript to get style of that component. About getting style by javascript, you can check this link How to get CSS values in JavaScript
Here is an example:
editor.on('component:selected', (component) => {
const domElement = component.getEl();
const style = window.getComputedStyle(domElement)
})
You can also get the currently selected component by doing editor.getSelected()
How to get/setStyle() of hover state from a component? this is posible?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3421
[QUESTION] How to remove class selector css rule
I'm using componentFirst set to true to let my users apply needed style to component they selected. Selecting a component which is applied...
Issue #2861
[HELP] Get css of selected component and its children
Hi, i'm trying to implement possibility to save elements as custom blocks. How can i get css of component and its children? I can recursive...
Issue #3200
Help needed: Get the component that a block being dropped onto?
Hello, If I drag and drop a block on a dynamically added component, how can I get/access the component that the block is dropped onto? I se...
Issue #2922
[QUESTION]: Get all css without specific component and it's children
Hi, so, in this issue #2861 we can get all the css of a selected element and it's children with: But if I want to get all the css but witho...
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
GrapesJS Inline RTE Plugins Update: CKEditor 5 v0.1.4 and Froala Inline Text Editor
CKEditor 5 Inline for GrapesJS v0.1.4 fixes Studio SDK toolbar clipping, iframe injection and link balloon bugs. Compare with Froala Inline — both $69.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.