Angular Image slider with lightbox. An Angular responsive image slider with lightbox popup. Also support youtube url, image base64 string and mp4 video urls and base64 string.
npm install rm-image-slider
Advanced, customizable, Optimized ,Minimal, light-weight and fully customizable pure angular component for carousel.
Image Slider/ carousel


|
|
bash
npm: npm install rm-image-slider--save
yarn: yarn add rm-image-slider
`
Setup :
Import module in your component:
`typescript
import { RmImageSliderComponent, ImageObject } from 'rm-image-slider';
...
@Component({
selector: '',
standalone: true,
imports: [RmImageSliderComponent],
templateUrl: '',
styleUrl: '',
})
`
Add component in your template file.
`html
`
ImageObject format
`js
imageObject: Array = [{
image: 'assets/img/slider/1.jpg',
thumbImage: 'assets/img/slider/1_min.jpeg',
alt: 'alt of image',
title: 'title of image',
index: 1
}, {
image: '.../iOe/xHHf4nf8AE75h3j1x64ZmZ//Z==', // Support base64 image
thumbImage: '.../iOe/xHHf4nf8AE75h3j1x64ZmZ//Z==', // Support base64 image
title: 'Image title', //Optional: You can use this key if want to show image with title
alt: 'Image alt', //Optional: You can use this key if want to show image with alt
order: 1, //Optional: if you pass this key then slider images will be arrange according @input: slideOrderType
index: 2
}
];
`
Image, Youtube and MP4 url's object format
`js
imageObject: Array = [{
video: 'https://youtu.be/....' // Youtube url
index: 1
},
{
video: 'assets/video/**.mp4', // MP4 Video url
index: 2
},
{
video: 'assets/video/movie2.mp4',
posterImage: 'assets/img/slider/2_min.jpeg', //Optional: You can use this key if you want to show video poster image in slider
title: 'Image title',
index: 3
},
{
image: 'assets/img/slider/1.jpg',
thumbImage: 'assets/img/slider/1_min.jpeg',
alt: 'Image alt',
index: 4
}
...
];
`
API Reference (optional) :
| Name | Type | Data Type | Description | Default |
| ------------------ | ------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
| infinite | @Input | boolean | Infinite sliding images if value is true. | false |
| imagePopup | @Input | boolean | Enable image lightBox popup option on slider image click. | true |
| animationSpeed | @Input | number | By this user can set slider animation speed. Minimum value is 0.1 second and Maximum value is 5 second. | 1 |
| slideImage | @Input | number | Set how many images will move on left/right arrow click. | 1 |
| imageSize | @Input | object | Set slider images width, height and space. space is use for set space between slider images. Pass object like {width: '400px', height: '300px', space: 4} or you can pass value in percentage {width: '20%', height: '20%'} OR set only space {space: 4} | {width: 205, height: 200, space: 3} |
| manageImageRatio | @Input | boolean | Show images with aspect ratio if value is true and set imageSize width and height on parent div | false |
| autoSlide | @Input | number/boolean/object | Auto slide images according provided time interval. Option will work only if infinite option is true. For number data type minimum value is 1 second and Maximum value is 5 second. By object data type you can prevent auto slide stop behaviour on mouse hover event. {interval: 2, stopOnHover: false} | 0 |
| showArrow | @Input | boolean | Hide/Show slider arrow buttons | true |
| arrowKeyMove | @Input | boolean | Disable slider and popup image left/right move on arrow key press event, if value is false | true |
| videoAutoPlay | @Input | boolean | Auto play popup video | false |
| showVideoControls | @Input | boolean | Hide video control if value is false | true |
| direction | @Input | string | Set text direction. You can pass rtl / ltr / auto | ltr |
| slideOrderType | @Input | string | Arrange slider images in Ascending order by ASC and in Descending order by DESC. order key must be exist with image object. | ASC |
| lazyLoading | @Input | boolean | Lazy load images and Iframe if true. | false |
| defaultActiveImage | @Input | number | Set image as selected on load. | null |
| imageClick | @Output | n/a | Executes when click event on slider image. Return image index. | n/a |
| arrowClick | @Output | n/a | Executes when click on slider left/right arrow. Returns current event name and next/previous button disabled status. | n/a |
| lightboxClose | @Output | n/a | Executes when lightbox close. | n/a |
| lightboxArrowClick | @Output | n/a | Executes when click on lightbox next/previous arrow. | n/a |
Add custom navigation button
`typescript
import { Component, ViewChild } from '@angular/core';
import { RmImageSliderComponent } from 'rm-image-slider';
@Component({
selector: 'sample',
standalone: true,
imports: [RmImageSliderComponent],
template:
})
class Sample {
@ViewChild('nav') slider: RmImageSliderComponent;
imageObject = [{...}]
prevImageClick() {
this.slider.prev();
}
nextImageClick() {
this.slider.next();
}
}
`
---
š§ Compatibility
| Angular Version | Support | Standalone | Notes |
|-----------------|---------|------------|-------|
| 14.x | ā
Full | ā
Yes | Minimum required |
| 15.x | ā
Full | ā
Yes | Recommended |
| 16.x | ā
Full | ā
Yes | Recommended |
| 17.x | ā
Full | ā
Yes | Latest tested |
| 18.x+ | ā
Expected | ā
Yes | Should work |
---
$3
| Browser | Version | Support |
|---------|---------|---------|
| Chrome | 80+ | ā
Full |
| Firefox | 75+ | ā
Full |
| Safari | 13+ | ā
Full |
| Edge | 80+ | ā
Full |
---
š³ Tree-Shaking and Optimization
- The library is marked as sideEffects: false to support advanced tree-shaking.
- The service-based API is inherently tree-shakable; it won\'t be included in your bundle if it\'s not imported and used.
---
$3
`bash
git clone https://github.com/malikrajat/rm-image-slider.git
cd rm-rm-image-slider
pnpm install
pnpm start # Serves test app on localhost:4200
``