Styling components with Emotion
In this section, we're going to style the App
, Header
, and HomePage
components with a popular CSS-in-JS library called Emotion. Along the way, we will discover the benefits of CSS-in-JS over CSS modules.
Installing Emotion
With our frontend project open in Visual Studio Code, let's install Emotion into our project by carrying out the following steps:
- Open the terminal, make sure you are in the
frontend
folder, and execute the following command:> npm install @emotion/react @emotion/styled
- There is a nice Visual Studio Code extension that will provide CSS syntax highlighting and IntelliSense for Emotion. Open the Extensions area (Ctrl + Shift + X on Windows or Cmd + Shift + X on Mac) and type
styled components
in the search box at the top left. The extension we are looking for is calledvscode-styled-components
and was published by Julien Poissonnier:Important...