Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing color as prop

I'm creating a "profile card" component using an array and the map() function to render data dynamically instead of hardcoding it. I'd like each person's profile to have a different border color, so I'm attempting to pass the color as a prop to the styling of the component. In the array, there is a color key with one HEX value per person. I'm passing it down as a prop from the array. What I'd like to do is make something like style={{border: '1px solid props.color' but I'm not sure how to do so. Please let me know if you have any ideas!

like image 690
JM223 Avatar asked Dec 09 '25 18:12

JM223


1 Answers

Use template literals. Something like this: style={{border: `1px solid ${props.color}`}}

like image 69
Siosaia Fonua Avatar answered Dec 11 '25 10:12

Siosaia Fonua



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!