Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

Gallery

Display an image collection with thumbnails and an accessible full-screen preview.

Category
Layout and content
Import
@neural-ui/core/gallery
Selector
neu-gallery
import { NeuGalleryComponent } from '@neural-ui/core/gallery';

Usage

Each item contains src and an accessible alt; title is optional. Choose activeIndex for a controlled image or initialIndex for internal state. Thumbnails may appear below or beside the stage. objectFit selects contain or cover. previewEnabled opens the image viewer from the main image; its controls support zoom, rotation, flip, reset and download. All toolbar labels can be translated.

Examples

Try the interaction and open Code for the complete implementation.

Examples

Applied image: 1 ยท Preview: closed ยท Zoom: 1 ยท Rotation: 0ยฐ ยท Flip: โ€” ยท Errors: 0

Try and configure

Change the options, try the result and see the template update. Code contains the full executable example.

Try and configure

Applied image: 1 ยท Preview: closed ยท Zoom: 1 ยท Rotation: 0ยฐ ยท Flip: โ€” ยท Errors: 0

Template generated from your current options. Open Code for the complete example.

template.html
<neu-gallery
  [items]="images"
  [previewEnabled]="true"
  [showThumbnails]="true"
  [showCounter]="true"
  [showItemNavigators]="true"
  [circular]="false"
  [maxZoom]="3"
  thumbnailPosition="bottom"
  objectFit="contain"
  (activeIndexChange)="changeImage($event)"
  [activeIndex]="0"
  [ariaLabel]="'Illustration gallery'"
/>

Data and content

Accept activeIndexChange by updating activeIndex. previewChange, zoomChange, rotationChange and flipChange report observed viewer state. imageError identifies the item and index that failed to load. The item Template replaces main-image rendering; the caption Template replaces its caption. Keep a meaningful alt on a custom image.

Accessibility and keyboard

Use arrow keys, Home and End to navigate the stage. Thumbnails expose the active state. The preview traps focus, Escape closes it and focus returns to its trigger. Supply translated control labels, descriptive image alternatives and keyboard-safe content in Templates.

Key
Action
Tab Reach gallery controls; focus stays inside an open modal preview.
ArrowLeft / ArrowRight Move to the previous or next gallery item.
Home Show the first item.
End Show the last item.
Enter Activate the focused thumbnail or gallery button.
Space Activate the focused thumbnail or gallery button.
Escape Close the preview and return focus to its trigger.

API

Inputs and Outputs match the installed package. Named types link to definitions. Every available Template has a Demo and Code example.

Inputs

Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.

Name
Type
Default
Template binding
Description
activeIndexnumber | nullnull[activeIndex]Applied zero-based image index; null uses internal state.
ariaLabelstring'Image gallery'[ariaLabel]Label for component region. Translate it for your application.
circularbooleanfalse[circular]Wrap first/last image navigation.
closeLabelstring'Close preview'[closeLabel]Label for close preview. Translate it for your application.
downloadLabelstring'Download image'[downloadLabel]Label for download image. Translate it for your application.
flipHorizontalLabelstring'Flip horizontally'[flipHorizontalLabel]Label for horizontal flip. Translate it for your application.
flipVerticalLabelstring'Flip vertically'[flipVerticalLabel]Label for vertical flip. Translate it for your application.
imageLoading"eager" | "lazy"'lazy'[imageLoading]Native eager or lazy image-loading policy.
initialIndexnumber0[initialIndex]Initial image index for uncontrolled navigation.
itemsreadonly NeuImageViewerItem[][][items]Images with src, alt and optional title.
maxZoomnumber3[maxZoom]Maximum scale in the image preview.
nextLabelstring'Next image'[nextLabel]Label for next navigation. Translate it for your application.
objectFit"cover" | "contain"'contain'[objectFit]Fit the main image with contain or cover.
previewEnabledbooleantrue[previewEnabled]Enable full-screen preview from the main image.
previewLabelstring'Image preview'[previewLabel]Label for image preview. Translate it for your application.
previousLabelstring'Previous image'[previousLabel]Label for previous navigation. Translate it for your application.
resetLabelstring'Reset image'[resetLabel]Label for reset image. Translate it for your application.
rotateLeftLabelstring'Rotate left'[rotateLeftLabel]Label for rotate left. Translate it for your application.
rotateRightLabelstring'Rotate right'[rotateRightLabel]Label for rotate right. Translate it for your application.
showCounterbooleanfalse[showCounter]Show the active-image counter.
showItemNavigatorsbooleantrue[showItemNavigators]Show previous/next image buttons.
showThumbnailsbooleantrue[showThumbnails]Show the image-thumbnail strip.
thumbnailLabelstring'Gallery thumbnails'[thumbnailLabel]Label for thumbnail navigation. Translate it for your application.
thumbnailPosition"bottom" | "start"'bottom'[thumbnailPosition]Place thumbnails below or beside the image.
toolbarLabelstring'Image controls'[toolbarLabel]Label for preview controls. Translate it for your application.
zoomInLabelstring'Zoom in'[zoomInLabel]Label for zoom in. Translate it for your application.
zoomOutLabelstring'Zoom out'[zoomOutLabel]Label for zoom out. Translate it for your application.

Outputs

Listen to an event with (event)="handler($event)". The table explains the data your handler receives and how to use it.

Name
Payload
Template binding
Description
activeIndexChangenumber(activeIndexChange)="onActiveIndexChange($event)"Proposes a zero-based active index.
flipChange{ x: number; y: number; }(flipChange)="onFlipChange($event)"Reports horizontal x and vertical y scale signs: 1 is unchanged and -1 is flipped.
imageError{ item: NeuGalleryItem; index: number; }(imageError)="onImageError($event)"Identifies the failed image and its index.
previewChangeboolean(previewChange)="onPreviewChange($event)"Reports whether the preview is open.
rotationChangenumber(rotationChange)="onRotationChange($event)"Reports the observed rotation in degrees.
zoomChangenumber(zoomChange)="onZoomChange($event)"Reports the observed image scale.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

Name
Mechanism
Contract
NeuGalleryCaptionDirectiveView example Public template directive (entrypoint)ng-template[neuGalleryCaption]
NeuGalleryItemDirectiveView example Public template directive (entrypoint)ng-template[neuGalleryItem]

Each example demonstrates a different template. Switch between Demo and Code to inspect its implementation, imports and state.

Public Types

Open a type to inspect its definition and interface fields.

Styles and tokens

Customize supported public tokens and check both themes. Example illustrations and application state are not Core inputs.

Specific tokens

This component uses shared theme tokens rather than dedicated component hooks.

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
--neu-border Normal control and cell borders Shared by other Core consumers; scope the override. rgba(15, 23, 42, 0.08)
--neu-focus-ring Normal keyboard-focus ring Shared by other Core consumers; scope the override. 0 0 0 var(--neu-focus-ring-width) rgba(0, 122, 255, 0.15)
--neu-primary Brand color for active controls and emphasis Shared by other Core consumers; scope the override. #007aff
--neu-radius Control corner radius Shared by other Core consumers; scope the override. 8px
--neu-surface Main field, header or control surface Shared by other Core consumers; scope the override. #ffffff
--neu-surface-2 Secondary surfaces and alternating rows Shared by other Core consumers; scope the override. #f1f5f9
--neu-text Main text and inherited icon color Shared by other Core consumers; scope the override. #0f172a
--neu-radius-lg Corner radius Shared by other Core consumers; scope the override. 12px