Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a gradient background in React with single color?

I want to make a Gradient Background for a Component in React like shown in the image below

Gradient of the same colour

I want to do it like: <Box colour ="blue"></Box> where the styles for these components will be like

backgroundColor="this.props.colour"

now I just want to pass the colour prop, I don't want to pass two colours also the colour will be in hex code.

like image 919
Himanshu Avatar asked Jan 29 '23 03:01

Himanshu


1 Answers

Why you don't use the gradient as a layer above the background-color to achieve this:

.box{
  height:200px;
  width:200px;
  background:linear-gradient(rgba(250,0,0,0.5),transparent);
  background-color:orange /*this your primary color*/
}
<div class="box">
</div>
like image 72
Temani Afif Avatar answered Jan 30 '23 15:01

Temani Afif