React & CSS
Because React components are "drag and drop" they must contain all the information about appearance. There are several different ways to write CSS in React including external stylesheets, inline styles <div className="main" style={{color:"red"}}>
, and (what appears to be the most common) using styles inside objects:
import { React } from "react";
function App() {
const styles = {
main: {
backgroundColor: "#f1f1f1",
},
inputText: {
color: "red",
},
};
return (
<div className="main" style={styles.main}>
<input type="text" style={styles.inputText}></input>
</div>
);
}
export default App;