...

/

Create Styled Components

Create Styled Components

Let’s learn how to use CSS in JS to make styled-components.

We'll cover the following...

Creating a styled component

Currently, the <img> created by CarouselSlide is unstyled, which means that it scales to whatever the original size of the image is. That means that the carousel jarringly expands and contracts as users move from slide to slide. Worse, it’ll push other page content around in the process.

  • To do that, we’ll replace the unstyled <img> element with a component generated by styled-components:

    // src/CarouselSlide.js
    import React from
...
Access this course and 1400+ top-rated courses and projects.