Slick Carousel In Angular

In this article, you will learn how to use a slick carousel in angular. A slick carousel is an image slider that is used to show multiple images in slideshow representation. You will learn to use a slick carousel in angular using the ngx-slick-carousel npm package. The slick carousel is very easily and quickly configurable.

You will learn the following points about slick carousel:

Installing and using a slick carousel is very easy and quick. Follow the below steps to start using a slick carousel.

Step 1: Creating an angular project

Create an angular project using the following command:

ng new imageslider

Step 2: Installing npm packages

Install required npm packages using the following commands:

npm install jquery –save

npm install slick-carousel –save

npm install ngx-slick-carousel –save

Step 3: Importing SlickCarouselModule in AppModule

Now you have to import SlickCarouselModule into AppModule. Put the following code in the app.module.ts file.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { SlickCarouselModule } from 'ngx-slick-carousel';

  declarations: [
  imports: [
  providers: [],
  bootstrap: [AppComponent]
export class AppModule { }

Step 4: Adding CSS and JS file paths in the angular.json file :

Now you have to add slick CSS. Put slick CSS file paths in the ‘styles’ array of the angular.json file.

"styles": [

Now add jquery and slick js files into the ‘scripts’ array of the angular.json file.

"scripts": [

Step 5: Using Slick component in application:

Once the above installing of packages and importing of the module, CSS, and JS files is done then you can use slick carousels components, directives, and pipes in your application.

Add the following code in the app.component.html file.

<ngx-slick-carousel class="carousel" 
    <div ngxSlickItem *ngFor="let image of images" class="slide">
          <img src="{{ image.img }}" alt="" width="100%">
<div style="text-align: center; margin-top: 45px;">
  <button (click)="addSlide()">Add Slide</button>
  <button (click)="removeSlide()">Remove Slide</button>
  <button (click)="slickModal.slickGoTo(2)">slickGoto 2</button>
  <button (click)="slickModal.unslick()">unslick</button>

Add the following code in the app.component.ts file.

import { Component } from '@angular/core';

  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
export class AppComponent {
  title = 'imageslider';

  images = [
    {img: ""},
    {img: ""},
    {img: ""},
    {img: ""},
    {img: ""}
  slideConfig = {"slidesToShow": 3, "slidesToScroll": 1, "dots": true, "infinite": true};
  addSlide() {
    this.images.push({img: ""})
  removeSlide() {
    this.images.length = this.images.length - 1;
  slickInit(e) {
    console.log('slick initialized');
  breakpoint(e) {
  afterChange(e) {
  beforeChange(e) {

Add the following CSS in the styles.css file to add navigation buttons.

.slick-slider {
  width: 88%;
  margin: auto;
  background: rgb(14, 13, 13);

body .slick-prev, 
body .slick-next {
  height: 45px;
  width: 40px;
  background: grey !important;
  z-index: 100;

Step 6: Run your application

Run your application using the following command and open your application on the browser.

ng serve

You will see slick carousel output.

1) Setting “dots”: false in slideConfig will remove dots on the slider.
2) Setting “infinite”: true in slideConfig will stop the slider once it is reached to the last image. It will stop moving images repeatedly.
3) You can also set autoplay for a slick carousel. You have to set autoplay and autoplaySpeed properties in slideConfig. Replace the following slideConfig object with the previous slideConfig object to see autoplay functionality.

slideConfig = {
  "slidesToShow": 3,
  "slidesToScroll": 1,
  "dots": true,
  "infinite": true,
  "autoplay" : true,
  "autoplaySpeed" : 1000


4) You can also set responsiveness to a slick carousel. You can set different properties for different screen sizes. Replace the following slideConfig object with the previous slideConfig object to see responsiveness functionality. You can also add your own multiple breakpoints to increase responsiveness.

slideConfig = {
    "slidesToShow": 3,
    "slidesToScroll": 1,
    "dots": true,
    "infinite": true,
    "autoplay" : true,
    "autoplaySpeed" : 1000,
    responsive: [
        breakpoint: 1024,
        settings: {
          slidesToShow: 3,
          slidesToScroll: 1,
        breakpoint: 600,
        settings: {
          slidesToShow: 1,
          slidesToScroll: 1,


As breakpoints are set, only one image can be seen on small devices and three images will be visible on large devices. You can slide to the next images using navigation buttons.

Slick Carousel on a large device:


Slick carousel on a small device:

If you want to images variable as dynamic, use trackBy in *ngFor syntax. It will minimize ngxSlickItem directive recreation.


You learned how to use a slick carousel in angular. You also learned some notes related to a slick carousel that will be useful. You also learned alternate ways for adding image sliders in angular.

Related Article:

Bootstrap Carousel in Angular

Notify of
Inline Feedbacks
View all comments