Problem with Swiper js arrow controls

I'm currently incorporating Swiper Js into my project and I'm facing an issue with styling the arrow buttons in the slider. Whenever I try to add classes to them, they stop functioning and disappear from the HTML.

Here is the code snippet:

 <Swiper
               className={slider}
               modules={[Navigation]}
               spaceBetween={50}
               slidesPerView={1}
               navigation={{
                  nextEl: ".image-swiper-button-next",
                  prevEl: ".image-swiper-button-prev",
                  disabledClass: "swiper-button-disabled",
               }}
               onSwiper={(swiper) => console.log(swiper)}
               onSlideChange={() => console.log("slide change")}
            >
               <SwiperSlide>slide 1</SwiperSlide>
               <SwiperSlide>slide 2</SwiperSlide>
               <SwiperSlide>slide 3</SwiperSlide>
            </Swiper>

Imports section:

import React from "react";
import { Navigation } from "swiper";
import { Swiper, SwiperSlide } from "swiper/react";
import "swiper/css";

CSS Style:

.image-swiper-button-next , .image-swiper-button-prev {
   text-rendering: auto;
   color: red;
}

What are your thoughts on this matter?

Answer №1

There are a few choices available to you:

  1. Utilize the default swiper classes for your CSS styling:
    .swiper-button-next,
    .swiper-button-prev {
      text-rendering: auto;
      color: blue;
    }
  1. Design your own custom navigation buttons and customize them from the ground up. Here's an example for reference: example.com/custom-swiper-buttons

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Durable Container for input and select fields

I need a solution for creating persistent placeholders in input and select boxes. For instance, <input type="text" placeholder="Enter First Name:" /> When the user focuses on the input box and enters their name, let's say "John", I want the pl ...

Step-by-step guide on generating multiple division elements according to the values specified by the user

Currently, I am focused on a project using asp.net. The primary objective is to create an image div whenever a button is clicked. This involves fetching the image from a database and displaying it on the screen, either in another div or table. I would ap ...

Does shouldComponentUpdate returning `true` have the same effect as not having shouldComponentUpdate at all?

Within my React Native component, I have included a blank shouldComponentUpdate shouldComponentUpdate(nextProps, nextState) { } I am aware, from reading this answer, that an empty shouldComponentUpdate function helps in eliminating unnecessary re ...

When I'm working on iPhone css hover effects, I find that I need to include a

Why do I have to add a touch event to my element in order for it to trigger hover styles? Is this typical behavior? It seems a bit unconventional. This is the code I need to include to make :hover work; without it, no hover style is applied. Apologies f ...

The Forward and Back Buttons respond based on the current position of the caret

Exploring the concept of a Keypad-Login. I am trying to create Back and Forward buttons. However, the back and forward buttons are currently inserting the letters at the end of the input value instead of at the caret position. The input field is disabled, ...

jQuery's animation feature is experiencing significant delays when triggered by scrolling

Is there a way to make an image appear and disappear as the user scrolls by using the .animate() method? I have attempted to implement it, but unfortunately, it seems quite slow and sometimes the image does not reappear when scrolling back to the top. Take ...

The robots.txt of Websiteplanet does not specify a sitemap URL

This is how my robots.txt file is set up: User-Agent: * Disallow: /info/privacy Disallow: /info/cookies Allow: / Allow : /search/Jaén Allow : /search/Tarragona Allow : /search/Rioja Sitemap: https://www.alquileres.xyz/sitemap.xml However, when I verify t ...

Incorporating react-intl-tel-input into your project: A step

Greetings, I am currently delving into the realm of ReactJS and am tasked with incorporating react-intl-tel-input to capture phone numbers from around the globe. However, during the integration process, I encountered some obstacles. When I input this code: ...

Avoid activating the hover effect on an element situated below another element without the use of JavaScript

After reviewing various posts, it seems like the only solution involves using javascript. Is there a way to hover over one element without affecting the style of another element below it, all without relying on javascript? I'm looking for a solution u ...

What is the best way to display a Chart using data pulled from redux?

I am struggling to display a chart based on the data retrieved from the Redux cart. Although I have successfully fetched the data attributes from the Redux store into an array, the chart does not appear as expected. Below is the code snippet from ChartPro ...

Issue with CSS styling not being reflected in JSF application

I am currently diving into the world of JSF and facing an issue with moving my inline styles to a CSS file. Despite my efforts, I can't seem to get it to work as expected. Below is the code snippet for reference. The location of my XHTML file is as f ...

How can you add a new div directly after the parent div's content and display it in-line?

I have a banner that stretches to fill the width completely. Inside this main div, there is another smaller div measuring 30px in size positioned at the end. The nested div contains a close icon background image, and upon clicking it, the entire banner get ...

Difficulties encountered when trying to align the content within a div

I am struggling to align the content within three horizontal divs on an info bar. The center div should be aligned center and the right-hand div should be aligned to the right, but my CSS attempts have not been successful. My attempts included adding text ...

Is it possible to modify a website's CSS permanently using just the browser?

Is there a way to make changes to CSS in a large project using Firefox's built-in developer tools and have them saved permanently? I've been trying to edit the style sheets, but couldn't locate the specific property I needed. Since I can&apo ...

Display component based on condition

import Home from "./home"; import About from "./about"; import Contact from "./contact"; const Funks = [ { component: Home, label: "Home", isActive: true }, { component: About, label: " ...

How can I preloaded self-hosted fonts in Next.js without receiving a console warning for not using the resource within a few seconds?

I am working on a project in Next.js and I want to preload my self-hosted fonts. In my code, I have the following setup: Inside my _app.js file: <Head> <link rel="preload" href="/fonts/leira/Leira-Lite.t ...

I'm having trouble with Material Design Slide Toggle as it lacks event.StopPropagation functionality. Any suggestions on what alternative I

When working with the Slide Toggle in Material Design, I noticed that it does not have a stopPropagation event. This is because the "MdSlideToggle.prototype._onChangeEvent" already includes a call to stopPropagation. So, what should be used instead? <m ...

What could be causing the second image to not drop in the proper position in an HTML and JavaScript environment?

I am encountering an issue with a simple drag and drop implementation using images in my code. The first image works fine, but for some reason the second image does not display correctly when dragged inside the div boxes; it appears outside of the box. Can ...

Error encountered: A blank page appears when attempting to deploy a React app created with Vite

I've been facing a challenge trying to solve this issue and I'm still unable to find the correct solution. When attempting to deploy my React app created with Vite to Github Pages, all I see is a blank page. However, it works perfectly fine loca ...

Obtaining two divisions that simultaneously display partials in a parallel manner

It's proving difficult to align two divs containing rendered partials side by side within a form. Strangely enough, when I replace the divs with plain text, they respond perfectly to my style changes. However, as soon as I include the render code, the ...