React
Css In Jsx
#react
Inline styling in React:
- Inside 2 curly braces
- { .. } evaluates to an expression in JSX.
- { key: value } implies a javascript object.
<p style={{ color: "red" }}>artists</p>Dynamic Inline styling
style={{ backgroundColor: emailNotValid ? "#fed2d2" : "#d1d5db" }}- Use Ternary operator when applying styles dynamically, since falsy isn’t a value
className={emailNotValid ? "invalid" : undefined}Apply some classes dynamically
<label className={`label ${emailNotValid ? "invalid" : ""}`}>