Issue with Swiper.js in Next.js: swiper-slide class won’t change width and height

I’m trying to integrate Swiper.js into my Next.js project, but I’m encountering an issue where the swiper-slide class doesn’t adjust its width and height as expected. I’ve tried various configurations and options, but the slider seems to ignore the styles I apply to it.

Here’s a simplified version of my code:

TSX

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><Swiper
effect={"coverflow"}
spaceBetween={1}
grabCursor={true}
centeredSlides={true}
loop={true}
slidesPerView={"auto"}
coverflowEffect={{
rotate: 0,
stretch: 0,
depth: 100,
modifier: 2.5,
slideShadows: false,
}}
pagination={{ el: ".swiper-pagination", clickable: true }}
navigation={{
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
clickable: true,
}}
modules={[EffectCoverflow, Pagination, Navigation]}
className="swiper_container"
>
<SwiperSlide className="swiper-slide">
<div className=""></div>
</SwiperSlide>
<SwiperSlide className="swiper-slide">
<div className=""></div>
</SwiperSlide>
<SwiperSlide className="swiper-slide">
<div className=""></div>
</SwiperSlide>
<SwiperSlide className="swiper-slide">
<div className=""></div>
</SwiperSlide>
<SwiperSlide className="swiper-slide">
<div className=""></div>
</SwiperSlide>
<SwiperSlide className="swiper-slide">
<div className=""></div>
</SwiperSlide>
<SwiperSlide className="swiper-slide">
{" "}
<div className=""></div>
</SwiperSlide>
</code>
<code><Swiper effect={"coverflow"} spaceBetween={1} grabCursor={true} centeredSlides={true} loop={true} slidesPerView={"auto"} coverflowEffect={{ rotate: 0, stretch: 0, depth: 100, modifier: 2.5, slideShadows: false, }} pagination={{ el: ".swiper-pagination", clickable: true }} navigation={{ nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", clickable: true, }} modules={[EffectCoverflow, Pagination, Navigation]} className="swiper_container" > <SwiperSlide className="swiper-slide"> <div className=""></div> </SwiperSlide> <SwiperSlide className="swiper-slide"> <div className=""></div> </SwiperSlide> <SwiperSlide className="swiper-slide"> <div className=""></div> </SwiperSlide> <SwiperSlide className="swiper-slide"> <div className=""></div> </SwiperSlide> <SwiperSlide className="swiper-slide"> <div className=""></div> </SwiperSlide> <SwiperSlide className="swiper-slide"> <div className=""></div> </SwiperSlide> <SwiperSlide className="swiper-slide"> {" "} <div className=""></div> </SwiperSlide> </code>
<Swiper
          effect={"coverflow"}
          spaceBetween={1}
          grabCursor={true}
          centeredSlides={true}
          loop={true}
          slidesPerView={"auto"}
          coverflowEffect={{
            rotate: 0,
            stretch: 0,
            depth: 100,
            modifier: 2.5,
            slideShadows: false,
          }}
          pagination={{ el: ".swiper-pagination", clickable: true }}
          navigation={{
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
            clickable: true,
          }}
          modules={[EffectCoverflow, Pagination, Navigation]}
          className="swiper_container"
        >
          <SwiperSlide className="swiper-slide">
            <div className=""></div>
          </SwiperSlide>
          <SwiperSlide className="swiper-slide">
            <div className=""></div>
          </SwiperSlide>
          <SwiperSlide className="swiper-slide">
            <div className=""></div>
          </SwiperSlide>
          <SwiperSlide className="swiper-slide">
            <div className=""></div>
          </SwiperSlide>
          <SwiperSlide className="swiper-slide">
            <div className=""></div>
          </SwiperSlide>
          <SwiperSlide className="swiper-slide">
            <div className=""></div>
          </SwiperSlide>
          <SwiperSlide className="swiper-slide">
            {" "}
            <div className=""></div>
          </SwiperSlide>

CSS

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> `.container {
max-width: 100%;
padding: 0rem 1rem;
margin: 0 auto;
}
.swiper_container {
height: 35rem;
padding: 2rem 0;
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.swiper-slide {
width: 10rem !important;
height: 20rem !important;
border: 1px solid blue;
border-radius: 50px;
}`
</code>
<code> `.container { max-width: 100%; padding: 0rem 1rem; margin: 0 auto; } .swiper_container { height: 35rem; padding: 2rem 0; position: relative; display: flex; justify-content: center; align-items: center; } .swiper-slide { width: 10rem !important; height: 20rem !important; border: 1px solid blue; border-radius: 50px; }` </code>
 `.container {
     max-width: 100%;
     padding: 0rem 1rem;
    margin: 0 auto;
   }



  .swiper_container {
    height: 35rem;
    padding: 2rem 0;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
   }

   .swiper-slide {
     width: 10rem !important;
     height: 20rem !important;  
     border: 1px solid blue;
    border-radius: 50px;

   }`

Despite setting explicit width and height styles in the custom-slide class, the slides maintain their default dimensions. I’ve also tried inline styles, but with no success.

Has anyone encountered a similar issue with Swiper.js in a Next.js environment? How can I ensure that the swiper-slide components respect the width and height styles I define?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật