Better Programming

Advice for programmers.

Follow publication

Member-only story

Build an Image Carousel With React Slick

Hussain Arif
Better Programming
Published in
6 min readSep 16, 2021

Projector
Source: Alex Litvin at Unsplash

Carousels are crucial when it comes to displaying many parts of content in the same space. For example, assume that you have a successful online store. If you want to display a catalog of offers and discounts, it would be sensible to render them in a carousel. This way, the list doesn’t take up too much space, thus improving UX design.

One notable example of carousel usage is the Saturn online store:

Demo of carousel on Saturn
Demo of carousel on Saturn

To create a simple carousel using React, you would have to do the following:

  • Write complicated amounts of CSS to display our items and position them where suitable.
  • Later on, write custom logic to handle iteration functionality and perform exception handling.
  • Furthermore, write more code to handle mobile view. For example, iterate through the list when the user drags the slider with their finger.

As a result, this means that you have to spend a lot of time and energy coding a carousel for your app. So how do we mitigate this problem?

This where React Slick comes in. It is an open source library that lets you build carousel components with ease. It has the following advantages:

  • Has built-in support for lazy loading. This brings performance to the table.
  • An API is present for customization purposes. With this, you can alter the look and feel of your component.
  • Furthermore, React Slick also includes a set of methods for controlling your carousel. This means that you can let the user navigate the element with the click of a button or a keyboard shortcut.

Now that we have talked about its advantages, let’s get started!

In this guide, we will build an image slider with touch support. This will be the outcome:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Hussain Arif
Hussain Arif

Written by Hussain Arif

Hello, all! I'm Hussain. Here, I share whatever I find interesting. Email: hussainarifkl[at]gmail[dot]com

No responses yet

Write a response