how to change the font color, font size, and button color in React

36,204

Solution 1

You write inline style...

<Panel style={{color:'red'}}>

or

<Panel className="sample"> 

in your style.css file just use

.sample {
 your style here....
}

or else

<Panel className={styles.sample}>

then write your style inside

.sample{style here...}

Solution 2

Remember in react you are writing JSX and not html. For inline styling the p element you have to do this

On line 22 of panel.js,

<p className = "Autoprice" style = {{color:color}}>{price}</p>

On Botton.js

on line 6

const styles = {
  color:'blue',
  background-color:'blue'
}

Solution 3

The color attribute doesn't work in HTML5. You should use style="color: red;" or wrap the content in <font color="red">.

<p style={"color: " + color}>
  Blah blah blah
</p>

or

<p>
  <font color={color}>
    Blah blah blah
  </font>
</p>

As for the button, your backgroundColor is bule. I'm guessing it should be blue?

Your CSS file also won't be applied since there is no backgroundColor class on your button and no fontStyle class on your paragraph.

Share:
36,204
Peishi Long
Author by

Peishi Long

Updated on December 10, 2020

Comments