Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

inline styling react

//double brackets, quotations around both key and value in css
<span style={{"font-weight": "750"}}>React Inline Styling </span>
Comment

use style in react

// use inline style in react
const myFunction = () => {
	return (
     <p style={{ fontSize: 24, margin: '0 auto', textAlign: 'center'}}>
       Hello world
    </p>
    );
}
Comment

inline styling in react

render() {
    return (
         <p style={{color: 'red'}}>
            Example Text
        </p>
    );
}
Comment

using inline styling in React

function MyComponent(){
2
3return <div style={{ color: 'blue', lineHeight : 10, padding: 20 }}> Inline Styled Component</div>
4
5}
Comment

jsx style styling

style={{color: "white",
        backgroundColor: '#f1356d',
        borderRadius: '8px'
       }}
Comment

css react

import "./FileName.css"; // import your css file

// or css inside your react file
//for example:
const MyDiv = React.createClass({
  render: function() {
    const style = {
      color: 'white',
      fontSize: 200
    };
    
    return <div style={style}> Have a good and productive day! </div>;
  }
});
Comment

Styling React Using CSS

//Use backgroundColor instead of background-color:
const Header = () => {
  return (
    <>
      <h1 style={{backgroundColor: "lightblue"}}>Hello Style!</h1>
      <p>Add a little style!</p>
    </>
  );
}
Comment

inline styling in react

style={ someCondition ? { textAlign:'center', paddingTop: '50%'} : {}}
Comment

react style

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
Comment

inline styling react

// Change the background color to red
document.body.style.backgroundColor = "red"; 
Comment

css in reactjs

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
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript check table not empty 
Javascript :: node cron schedule specific time 
Javascript :: vue component lifecycle 
Javascript :: momentjs docs 
Javascript :: one component to another component in vuejs trigger function 
Javascript :: how to return argument in javascript 
Javascript :: React native calender date picker 
Javascript :: how sum all array element with for 
Javascript :: js html editor 
Javascript :: New JSDOM and querySelector elems textContent 
Javascript :: instanceof javascript 
Javascript :: react router reload page not found 
Javascript :: js overflowx 
Javascript :: array includes javascript 
Javascript :: how to remove first element from array in javascript 
Javascript :: js remove escape characters from json 
Javascript :: angular property value does not exist on type Event 
Javascript :: create callback function javascript 
Javascript :: findoneandupdate mongoose 
Javascript :: setup react app from cpanel 
Javascript :: function that search a biggest value in array javascript 
Javascript :: mean stack tutorial 
Javascript :: JSX Conditionals: && 
Javascript :: selected dropdown value 
Javascript :: javascript access nested property by string 
Javascript :: remove object from array of object 
Javascript :: how to handle errors with xmlhttprequest 
Javascript :: how to pass sequelize transaction to save method 
Javascript :: how to make an event listener only work once 
Javascript :: how to check for unused dependencies in my react project 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =