Skip to main content
Neural UIv2.1.0Documentation
View v1

ImageViewer

Open a full-screen preview from an image or a labelled trigger.

Category
Layout and content
Import
@neural-ui/core/image-viewer
Selector
[neuImageViewer]
import { NeuImageViewerDirective } from '@neural-ui/core/image-viewer';

Overview

Attach the directive to an image or an accessible image button. Bind an image URL, a NeuImageViewerItem or a list with meaningful alt text and optional captions. For a list, neuIvIndex selects the zero-based image to enlarge. Plain thumbnails work without Gallery; choose Gallery when you also need a carousel component.

Try it

Click or tap either visible thumbnail to enlarge that same illustration. With the keyboard, Tab to a thumbnail and press Enter or Space. Use the previous/next controls or arrow keys to move between the two images, then Escape to close and return focus to the thumbnail.

Try it
Select an image to enlarge it

State and events

The application supplies the image list and initial index. The directive owns zoom, navigation and visibility during the session. Its opened and closed events report visibility. Use open() and close() when a separate application action needs control.

Accessibility and keyboard

Each thumbnail is a native button with an accessible action name and an image with meaningful alt text. Enter and Space open the corresponding image. The full-screen dialog keeps focus inside while open and restores the originating thumbnail on close. Gallery exposes public inputs when custom viewer control labels are needed.

Key
Action
Enter / Space Open the focused viewer trigger.
โ† / โ†’ Move to the previous or next image when available.
Escape Close the full-screen viewer.

API

Import the directive from its public entry point and attach it to a host element.

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
neuImageViewerstring | NeuImageViewerItem | readonly NeuImageViewerItem[]''[neuImageViewer]URL, image item or read-only list of image items.
neuIvIndexnumber0[neuIvIndex]Initial zero-based index for a list of images.

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
closedvoid(closed)="onClosed($event)"Emits when the viewer closes.
openedvoid(opened)="onOpened($event)"Emits when the viewer opens.

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.

This component does not expose content projection or public customization templates.

Public methods

Name
Contract
closeclose(): void;
openopen(): void;

Public Types

Open a type to inspect its definition and interface fields.

Styles and tokens

Apply the Neural theme to the application and check the overlay in both color schemes before overriding any public tokens.

Specific tokens

Token
Purpose
State / variant
Default / source
Fallback
--neu-image-viewer-arrow-bg Inherited theme value used by this component Field surface rgb(255 255 255 / 0.12)Root declarationNo token alias
--neu-image-viewer-arrow-hover Inherited theme value used by this component Field surface rgb(255 255 255 / 0.25)Root declarationNo token alias
--neu-image-viewer-bg Inherited theme value used by this component Field surface rgb(0 0 0 / 0.9)Root declarationNo token alias
--neu-image-viewer-btn-hover Inherited theme value used by this component Field surface rgb(255 255 255 / 0.15)Root declarationNo token alias
--neu-image-viewer-caption Inherited theme value used by this component Field surface rgb(255 255 255 / 0.65)Root declarationNo token alias
--neu-image-viewer-muted Inherited theme value used by this component Field surface rgb(255 255 255 / 0.7)Root declarationNo token alias

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-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-radius-lg Corner radius Shared by other Core consumers; scope the override. 12px
--neu-z-modal Inherited theme value used by this component Shared by other Core consumers; scope the override. 200