Support Topics Documentation Slack YouTube Blog

Set the background color of a block programmatically?

Hello

is it possible to set the background color of a Block programmatically during run time?

Thanks

Hi, @Joerg

Yes, it is possible to do it dynamically. For this you need to use a block of styles.
Instead of the background you can use any css property. As the desired color you can choose any color.


Regards,
Marina

Perfect, thanks @Marina.Rudenko,

I haven’t found the documentation of this. Like how do you know which properties you can set and what their names are.

Could you perhaps send me a link.

Thank you and best regards

Joerg

Hello, @Joerg.

You can learn about “Codeless” using the documentation, and we also have video tutorials on YouTube.
Regards, Nikita.

Thanks, @Nikita_Fedorishchev,

I know about the documentation and I have searched in it. However, I still couldn’t find the style parameters of a Block. Could you please be more specific on where to find those.

Thank you and best regards,

Joerg

Hello @Joerg

Our Block component is a usual div, so you can apply all styles what can be applied to the div

But you must remember, these styles be applied by the JavaScript, so parameters like a ‘background-color’ need to write using ‘camelCase’ (ex. ‘backgroundColor’, ‘objectFit’,‘borderBottom’)

Regards, Dima.