style Attribute

This is CSS in JavaScript also called React Style.
Notice the double curly brackets
Notice the attribute names are slightly different, no dashes.


index.jsx

const Button = () => { 
   return <button style = {{ backgroundColor : 'red' }}>My Button</button>
}


const Button = () => { 
   const button_style = {
      backgroundColor : 'red'
   }
   return <button style={button_style}>My Button</button>
}

Using a property as part of the style

const Button = () => { 
   const button_style = {
      backgroundColor : prop_
   }
   return <button style={button_style}>My Button</button>
}




© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext