Reputation: 29566
To set a color in a React inline style to an RGBA value I can at least use string interpolation in ES6:
<div style={{color: `rgba(${r}, ${g}, ${b}, ${a})`}}>test</div
Does React support objects instead of a string here? Something similar to it supporting numbers where pixel units are assumed for styles like width
etc. For example:
<div style={{color: {r, g, b, a}}}>test</div
Upvotes: 12
Views: 16025
Reputation: 11
Make your color a constant, and put it in backticks, for example: const blueColor = `rgba(64, 107, 169, 1)`;
Upvotes: 1
Reputation: 24815
No. React supports no such function. I suggest either:
Upvotes: 6