Customizing Prev/Next Buttons in React SwiperJs
To customize the Prev/Next buttons, you can use the following props:
swiper-button-prev: This prop allows you to customize the previous button. You can pass a React component or an HTML element to this prop.
swiper-button-next: This prop allows you to customize the next button. You can pass a React component or an HTML element to this prop.
Here's an example of how to use these props, inside your css you can use the style below
This will change the color of the prev arrow button to green:
.swiper-button-prev {
color: green;
}
This will change the color of the next arrow button to blue:.swiper-button-next {
color: red;
}
.swiper-button-next {
color: red;
}
Result:
Now Replace the Image of the Swiper Arrows
.swiper-button-next { background-image: url(../../../public/images/svg/circle-right-regular.svg); background-repeat: no-repeat; background-size: 100% auto; background-position: center; } .swiper-button-next::after { display: none; } .swiper-button-prev { background-image: url(../../../public/images/svg/circle-left-regular.svg); background-repeat: no-repeat; background-size: 100% auto; background-position: center; } .swiper-button-prev::after { display: none; }
Result:
Conclusion:
That's it! You now know how to customize Prev/Next Buttons in React Swiper Js. You can further explore the Swiper Js documentation to learn more about the available props and customization options.My name is Sen Gideons, If you have any questions or comments about this tutorial, please feel free to leave them in the comments section below.
0 Comments