Issue #2544✓ SolvedOpened February 2, 2020by gentritabazi3 reactions

Get CSS of selected component ?

快速解答by longdoan74213

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)

👍 Most helpfullongdoan7421February 3, 2020

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)
})
artfFebruary 3, 2020

You can also get the currently selected component by doing editor.getSelected()

alemencionesMarch 9, 2020

How to get/setStyle() of hover state from a component? this is posible?

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

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.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.