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>
}

Alternatively you can also do this

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


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