๐ ๐ผ Styled Components
It's all bout fashun and making your components look good.
Styled components is an external, open source library for, well, creating styled components, or components that have inline, scoped styles.
To use it in a file, just import it to the required file:
The unusual back ticks ``
here are a new JavaScript feature called tagged template literals.
Styled components lets us write actual CSS in JS. This means we can use all the features of CSS - media queries, all pseudo selectors, nesting, etc.
Conditional Styling in styled-components
Since inside the back-ticks of the styled components is basically a string template, we can manipulate the CSS values inside of it:
We render the StyledPara
like so:
We use the props to render the content conditionally, or ideally add the style properties based on the dynamic content inside the callback function, which is inside CSS styling of the styled-component.
Last updated