Files
Dipto Karmakar 3dc8f10ae8 Update add-inline-style-in-react (#35739)
- Add my solution in the hint.
2019-05-18 23:02:46 -05:00

706 B

title
title
Add Inline Styles in React

Add Inline Styles in React

You can declare a component style passing the object directly as a prop 'style'. Just remember that each property of the style object is camelcased. So properties like 'font-size' is declared 'fontSize' to be a valid javascript object property.

Spoiler

const styles = {
  color: 'purple',
  fontSize: 40,
  border: "2px solid purple",
};

class Colorful extends React.Component {
  render() {
    // change code below this line
    return (
      <div style={styles}>Style Me!</div>
    );
    // change code above this line
  }
};

Resources

DOM Elements Style