Ngx Simple Gallery

August 28, 2025 ยท View on GitHub

npm version codecov

A simple gallery lib for Angular [20]. It displays all the images as thumbnails and makes it big, when clicked/tapped on it.

  • mobile friendly
  • lightweight
  • use images from any source
  • two main forms of use: component selector or directive
  • navigate forwards/backwards with keyboard arrows or touch/click on arrows in the showcase dialog
  • loading spinner while loading
  • smooth animation of the next item
  • you can define a thumbnail or leave it empty. It is recommended to provide it though, because of performance reasons.

Demo | Changelog

Versioning

GalleryAngularReadme
^2020+here
^1919+README.md
^1818README.md

Installation

npm install --save ngx-simple-gallery @angular/cdk

add the following line to your global styles (by default "styles.(scss|css)") if it is not included yet:

@import '@angular/cdk/overlay-prebuilt.css';

Usage

import { NgxSimpleGalleryComponent } from '@zolcsi/ngx-simple-gallery';

@Component({
  standalone: true,
  imports: [NgxSimpleGalleryComponent],
})
export class AppComponent {}
import { GalleryItem } from '@zolcsi/ngx-simple-gallery';

@Component({...})
export class AppComponent {
  
  galleryItems: GalleryItem[] = [
    { 
      src: '/img/image1.jpg' 
    }, 
    {
      src: 'https://picsum.photos/id/237/2000/3000',
      thumbnail: 'https://picsum.photos/id/237/160/160',
  }]
}
import { GalleryItem } from '@zolcsi/ngx-simple-gallery';

@Component({...})
export class AppComponent {
  
  galleryItems: GalleryItem[] = [...];
  
  galleryConfig: GalleryConfig = {
    emptyMessage: 'No images found in the galleryItems',
    galleryThumbnailSize: 140,
    modalStartIndex: 2,
    showModalThumbnailList: false
  }
}

4a. Using the component selector (this renders the images on the page)

<ngx-simple-gallery [galleryItems]="galleryItems" [galleryConfig]="galleryConfig"></ngx-simple-gallery>

or

4b. Using the directive on your own element (this does not render the items on the page, directly opens the modal view)

<p simpleGallery [galleryItems]="galleryItems" [galleryConfig]="galleryConfig">My Gallery</p>

Input parameters

NameRequiredTypeDefaultDescription
galleryItemsyesGalleryItem[][ ]Contains the list of images
galleryConfignoGalleryConfigCustom configuration for the gallery

GalleryItem (represents one single image)

NameRequiredTypeDefaultDescription
srcyesstring-Source of the image
thumbnailnostringsrcThumbnail of the image. If not provided, the source will be used
NameRequiredTypeDefaultDescriptionApplicable
emptyMessagenostring'Empty gallery, no images provided.'Message to show in case empty items providedcomponent, directive
galleryThumbnailSizenonumber160The width/height of the thumbnails in px in the gallery (not in the modal view)component
modalStartIndexnonumber0The index of the first image to show in the modal viewdirective
showModalThumbnailListnobooleantrueWhether to show the thumbnail list in the modal viewcomponent, directive