Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I customize the size of navigation buttons in Swiper (Angular)

In my current project, the Swiper navigation buttons are too large, but I don't know how to manipulate the size.

I've tried this in the styles.css file:

::ng-deep .swiper-button-prev:after,
::ng-deep .swiper-button-next:after {
    font-size: 20px;
}

But it doesn't work for me.

I know I can open the file swiper-bundle.css and correct this line:

:root {
  --swiper-navigation-size: 44px;
}

But this file is located inside a npm package, meaning changes made in that file is local only. I need to push my code to GitHub, so that solution doesn't count.

like image 978
LiemLT Avatar asked Oct 23 '25 16:10

LiemLT


1 Answers

  <Swiper
                    style={{
                      "--swiper-navigation-color": "#000",
                      "--swiper-navigation-size": "25px",
                    }}
                    slidesPerView={matchesSmall ? 5 : 8}
                    spaceBetween={30}
                    centeredSlides={true}
                    freeMode={true}
                    navigation={false}
                    watchSlidesProgress={true}
                    modules={[FreeMode, Navigation]}
                  >
                   ...
                  </Swiper>

use style props

like image 83
Hamed Rahimi Avatar answered Oct 26 '25 11:10

Hamed Rahimi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!