//double brackets, quotations around both key and value in css
<span style={{"font-weight": "750"}}>React Inline Styling </span>
// use inline style in react
const myFunction = () => {
return (
<p style={{ fontSize: 24, margin: '0 auto', textAlign: 'center'}}>
Hello world
</p>
);
}
render() {
return (
<p style={{color: 'red'}}>
Example Text
</p>
);
}
function MyComponent(){
2
3return <div style={{ color: 'blue', lineHeight : 10, padding: 20 }}> Inline Styled Component</div>
4
5}
style={{color: "white",
backgroundColor: '#f1356d',
borderRadius: '8px'
}}
<div style={{ width: '200px', backgroundColor: 'red' }}>Something</div>
return <div style={{display: 'inline-block'}}>
//Use backgroundColor instead of background-color:
const Header = () => {
return (
<>
<h1 style={{backgroundColor: "lightblue"}}>Hello Style!</h1>
<p>Add a little style!</p>
</>
);
}
style={ someCondition ? { textAlign:'center', paddingTop: '50%'} : {}}
marginHorizontal
alignContent
alignSelf
aspectRatio
borderBottomWidth
borderEndWidth
borderLeftWidth
borderRightWidth
borderStartWidth
borderTopWidth
borderWidth
bottom
display
end
flex
flexBasis
flexDirection
flexGrow
flexShrink
flexWrap
height
justifyContent
left
margin
marginBottom
marginEnd
alignItems
marginLeft
marginRight
marginStart
marginTop
marginVertical
maxHeight
maxWidth
minHeight
minWidth
overflow
padding
paddingBottom
paddingEnd
paddingHorizontal
paddingLeft
paddingRight
paddingStart
paddingTop
paddingVertical
position
right
start
top
width
zIndex
direction
// Change the background color to red
document.body.style.backgroundColor = "red";
Assuming you have 2 separate files: Example.css and Example.js
Use the '.' to reference a className that you'll use later
.primary{
color: red;
}
<h1 className="primary"> Hello, World </h1>
In this case "primary" in the className is referencing .primary in the CSS file