Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why my colors is not output on the screen under a rafce react environtment

I am using react rafce function and I want to decorate my color icons ,I decided to create a rounded icons with colors inside but it ended up not showing any colors.

This is my css styling

const FilterColor = styled.div`
    width:20px;
    height:20px;
    border-radius:50%;
    background-color:$props{props=>props.color};
    margin:0px 5px;
    cursor:pointer;
`  

This is my html code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    <FilterTitle>Color: </FilterTitle>
    <FilterColor color= 'red' />
    <FilterColor  color ='darkblue'/>
    <FilterColor color='orange' />

This is my output

This is what it should look

>Solution :

Assuming, you are using styled-components, change your FilterColor component to:

const FilterColor = styled.div`
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: ${(props) => props.color}; // <-- this got changed
  margin: 0px 5px;
  cursor: pointer;
`;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading