c8r / lab

React UI component design tool
https://compositor.io/lab
349 stars 14 forks source link

Using props to determine styles #30

Closed fazouane-marouane closed 6 years ago

fazouane-marouane commented 6 years ago

Hi,

Is there a way to use props values to determine styles? I would have expected the following to work color: this.props.stuff? 'red': 'blue'. But it doesn't.

Can you explain how would one can achieve such a thing? Thanks.

mrmrs commented 6 years ago

Hi @fazouane-marouane,

That concept does work, but you need some additional syntax. Here is your example rewritten. Let me know if you have any additional questions!

color: '${ props.stuff? "red" : "blue" }'
fazouane-marouane commented 6 years ago

Thanks it works like a charm!