beamui icon indicating copy to clipboard operation
beamui copied to clipboard

How to change background color for Button and other ui elements ?

Open aquaratixc opened this issue 4 years ago • 3 comments

I used background-color to change color for Button. but its not working. How ti change background color and other "visual properties" for UI elements ?

aquaratixc avatar Oct 18 '20 12:10 aquaratixc

Hi. This is because background-image is also set to a gradient. Just set it to none. It might not remove backgrounds in pressed state, but you can fix it by using a more powerful selector.

See common (this is SASS actually) and default styles for examples and to know, what is already set.

dayllenger avatar Oct 18 '20 16:10 dayllenger

And how to make this from onClick event ?

aquaratixc avatar Oct 18 '20 19:10 aquaratixc

Well, you need to change state. Then, using this state, you either:

  • set an attribute, see basic example
  • or use inline styles:
InlineStyle style;
style.backgroundColor = color;
b.style = style;

Use the first approach if it covers your needs. It gives hot reload, better syntax, better performance, etc. The second method is for dynamically changing values.

dayllenger avatar Oct 19 '20 00:10 dayllenger