0

So I want to use a Swiper library for react. I have multiple movie elements, and I want to swipe through them. I import it like this:

import Swiper from 'react-id-swiper';

And I use it that way:

<div className="carousel-container">
        <Swiper>
                  {movies.map(movie =>
                      <MovieItem movie={movie} key={movie.title}/>
                    )}
        </Swiper>
    </div>

So it should make a horizontal slider with movie items, but on the page it looks like this: enter image description here

So it's like I just put all the movies inside of a common div, although when I open the code in the browser, all movies are inside of swiper div with all the classes, so I'm not sure why it doesn't work the way it should. Maybe the problem is because I use .tsx file?

1
  • imported swiper.css correctly? Commented Feb 24, 2022 at 11:34

1 Answer 1

3
+50

The issue is lack of css/styling.

The documentation on react-id-swiper is old. According to the documentation on the main module it uses (swiperjs) you need to add the styling/css like so:

import "swiper/css";

I've created a sandbox for you to see it working here

Sign up to request clarification or add additional context in comments.

1 Comment

typescript? This is js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.