Issue #2728💬 AnsweredOpened April 22, 2020by ajumell0 reactions

How can I set the background image of a component programtically.

快速解答by artf

@ajumell when, for example, you select the background to apply you can change the component background in this way

Read full answer below ↓

Question

Hello,

I want to create an option to change background of a component by double clicking it. I could open the modal when double clicking it. But how can I se the background-image property using it. I checked the codebase couldn't find a clue. Have any one done something similar. Please provide some suggestions or leads.

Answers (1)

artfApril 23, 2020

@ajumell when, for example, you select the background to apply you can change the component background in this way

component.addStyle({ 'background-image': `url('${url}')` })

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 →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.