How do I customize the default styling of a single slider in react-slick?

Looking to enhance the look of slick carousels by customizing prev/next arrows and controlling their position? I'm currently using nextjs13, chakra-ui, react-slick, and vanilla extract.

An effective way to customize arrow styles is by passing an arrow component like this:

const settings = {
  ...
  prevArrow: <Arrow />
};

You can also control the arrow's position by applying global CSS 'slick-prev' style. However, if you need different styles for each slider, it becomes tricky.

I attempted to use a vanilla-extract class like this:

export const classname = style({...})

<Slider className={classname} />

But unfortunately, it didn't work as expected since the class name should be 'slick-prev' to override the default style.

Additionally, simply omitting the arrow setting in the settings object did not yield the desired result either.

Another approach I tried was creating a separate CSS file with '.slick-prev' style and importing it into a specific component. However, this modification impacted sliders on other pages as well.

If anyone has a solution on how to specifically override the '.slick-prev' style for a single slider, your input would be greatly appreciated.

Answer №1

If you want to adjust the font size of the previous and next arrows in your global CSS file, you can do so by adding the following command:

.slick-next:before, .slick-prev:before {
    font-size: 15px !important;
}

Currently, the next/prev arrow components are using the Icon component, which means we need to set the font-size using before. However, if you are using image or text button components for the next/prev arrows, you can customize their size using style or className. Take a look at the code snippet below for an example:

const settings = {
  ...
  prevArrow: <Arrow style={{ display: "block", background: "red" }} />
};

For more information, please refer to the customArrows example on the react-slick documentation.

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

Place the button inside the form following another block element

Here is the HTML code I am working with: <div class="actions"> <input id="submit-car" name="commit" type="submit" value="Добавить объявление"> </div> and here is a fiddle example: http://jsfiddle.net/348U4/ In ...

Is there a way to trigger two distinct CSS transitions simultaneously with a single click?

Below is a script that rotates two images in opposite directions when clicked. One image spins clockwise while the other spins counter-clockwise. The challenge is that each image requires an individual click to rotate. My goal is to make both images rotate ...

Encountering the issue of receiving "Account as undefined" within the Next Auth Jwt Callback

Currently, I am utilizing Next Auth V4 (which was upgraded from v3 and not built from scratch). I am facing an issue trying to retrieve user data from my Okta provider in the account object within the sign-in callback. Unfortunately, the data becomes unse ...

The link in the navigation bar is not functioning correctly

Let me break down the issue I'm facing here. The problem arises with the navigation buttons that have sub-lists nested within them (ul>li>ul). When attempting to click on these buttons, the link does not work unless I specifically click on the t ...

Exploring the process of obtaining a URL using getStaticPaths in Next.js

I am facing difficulty getting the URL in getStaticPath export const getStaticPaths = async (props) => { if (url === 'blah') { return { paths: [ { params: { pid: "create" } }, ], fallback: true, }; ...

Having difficulty generating a footer for a page that includes a Material-UI Drawer component

Looking to create a standard full-width footer at the bottom of my page, I need help with the implementation. Utilizing the "Permanent drawer" from Material-UI Drawer for reference here. If you're interested in experimenting with it, CodeSandbox link ...

Get the ability to overlay text onto an image by using jQuery for downloading

Currently, I am facing an issue with an online photo editor in my project. The problem is that I am unable to download the image after adding and editing text on it. The texts added are editable but the image cannot be downloaded after the changes. I nee ...

What steps can I take to minify my code using react-create-app?

Currently, I am facing an issue with minifying my code on the server. Despite running npm run build, which is supposed to handle all the minifying processes (as shown here: https://i.stack.imgur.com/wjpd7.png), I still see the unminified code when accessin ...

What is the reason behind Material UI's restriction on using camelCase props with "withStyles"?

Struggling with prop casing while diving into the new Material UI (version 1.0.0-beta.33 at the time of writing), I've encountered inconsistencies with withStyles allowing camelCased props in some scenarios but not others. For instance: <ChipInpu ...

I am curious about when the CSS of my website will start impacting its search engine ranking

Initially, my perception of CSS was that it was only used for styling the appearance of a document when viewed in a browser. However, I soon came to realize that search engines also utilize CSS for indexing web pages. It is said that search engines do not ...

Persistent footer text moving around

Check out the sticky header I created here. However, when it sticks in place, the text moves down and goes out of the container. I want the header to remain within the container. Here is my HTML & jQuery: <div id="container"> <div id="menu ...

Unable to customize the button color within the Bootstrap framework

This button was created using Bootstrap. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <lin ...

When using Material UI GridTile, the actionIcon will not be shown if there is no title present

In my React application, I am utilizing Material-UI GridList to showcase some images. I am interested in adding an IconButton on top of the image in my GridTile component. Currently, I can achieve this by providing the button to the actionIcon prop. Howeve ...

The issue arises when attempting to use input alongside debounce, event.persist(), and storing the value at the parent component

Is there a way to implement an input field with debounced search where the value is passed from the parent component? Currently, when I pass the value from the parent component it doesn't work as expected. What would be the correct approach to make th ...

CSS for Adjusting Parent Height Based on Child Content

I've been working on adjusting the height of the parent class to fit the child class perfectly without overflowing Here is a snippet from my CSS file: Parent &__video position: relative; width: 471px; background: red; border-radius: 12px ...

Why are my Chrome Div regions failing to expand to their full width?

I have been searching but couldn't find an answer to my issue, so I apologize if this question has been asked before. I am working on a simple site layout and noticed that two of the div regions do not expand fully in Chrome, however, they do in Firef ...

Issue with OpenAI's Rate Limit 429 Restriction

I've been experimenting with this repository in order to implement semantic search for YouTube videos using OpenAI + Pinecone. However, I keep encountering a 429 error at the following step - "Run the command npx tsx src/bin/process-yt-playlist.ts to ...

Paypal Payment Plans on a Monthly Basis Utilizing the Bootstrap Pricing Slider

I came across this fantastic Bootstrap Pricing Slider that I found originally at Within my Bootstrap Pricing Slider, there is a "total amount" calculated after some math, resulting in a final score. The slider includes a "Process" button which currently ...

How can I create a clickable <div> element containing multiple links and trigger only one action?

Within my code, there is a <div> element that has been made clickable. Upon clicking this <div>, the height and text expand using the jQuery function $(div).animate();. While this functionality works as intended, I am encountering a slight issu ...

Issue with Next.js: Router.push not causing page to refresh

I'm currently developing a next.js page called /page/data/[dataId] (this page is accessed when a user clicks on a link from the page /page/data, where I fetch the list of items through an API). When a user clicks on a button, I make an API call to de ...