Skip to content
Advertisement

Trouble installing Swiper in my React project

I’m trying to add Swiper to my React Web App, I’m having trouble with the regular plugin, so I decided to use this framework instead: swiper-react specifically designed for React.

Following the getting started tutorial:

JavaScript

It says that I need to import these CSS files but when I try to import them in my Component, at runtime I’m getting:

JavaScript

without them the result on the page is the following:

SCREENSHOT

Here is the code of the page:

JavaScript

What am I doing wrong? Thanks.

Advertisement

Answer

It says in the Styling section of readme.

For version <=2.3.2

You can import direct from react-id-swiper/lib/styles/ (supporting css, scss)

css

JavaScript

scss

JavaScript

For version >=3.0.0

You should import directly from Swiper packages which supports css, scss and less

css

JavaScript

scss

JavaScript

less

JavaScript

You should try importing for v3.0.0 because that is the current version on npm.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement