Displays an image with preview and tranformation options.
import { ImageModule } from 'primeng/image';
Image is used as the native img element and supports all properties that the native element has. For multiple image, see Galleria.
<p-image
src="https://primefaces.org/cdn/primeng/images/galleria/galleria10.jpg"
alt="Image"
width="250" />
Preview mode displays a modal layer when the image is clicked that provides transformation options such as rotating and zooming.
<p-image
src="https://primefaces.org/cdn/primeng/images/galleria/galleria10.jpg"
alt="Image"
width="250"
[preview]="true" />
An eye icon is displayed by default when the image is hovered in preview mode. Use the indicator template for custom content.
<p-image
src="https://primefaces.org/cdn/primeng/images/galleria/galleria10.jpg"
[preview]="true"
alt="Image"
width="250">
<ng-template pTemplate="indicator">
<i class="pi pi-check"></i>
</ng-template>
</p-image>
In case that you want to show different image on preview, you can set previewImageSrc attribute. It could come handy when wanted to use smaller image version at first and bigger one on preview.
<p-image
src="https://primefaces.org/cdn/primeng/images/galleria/galleria11.jpg"
previewImageSrc="https://primefaces.org/cdn/primeng/images/galleria/galleria11.jpg"
alt="Image"
width="250"
[preview]="true" />
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-image | Container element. |
p-image-preview-container | Container element with preview enabled. |
p-image-preview-indicator | Mask layer over the image when hovered. |
p-image-preview-icon | Icon of the preview indicator. |
p-image-mask | Preview overlay container. |
p-image-toolbar | Transformation options container. |
p-image-action | An element inside the toolbar. |
p-image-preview | Image element inside the preview overlay. |
The preview button is a native button element with an aria-label that refers to the aria.zoomImage property of the locale API by default.
When preview is active, dialog role with aria-modal is applied to the overlay image container.
Button controls use aria.rotateRight, aria.rotateLeft, aria.zoomIn, aria.zoomOut and aria.close from the locale API as aria-label.
When preview is activated, close button receives the initial focus.
Key | Function |
---|---|
tab | Moves focus through button bar. |
enter | Activates the button. |
space | Activates the button. |
esc | Closes the image preview. |
API defines helper props, events and others for the PrimeNG Image module.
Displays an image with preview and tranformation options. For multiple image, see Galleria.
Defines the input properties of the component.
Defines emit that determine the behavior of the component based on a given condition or report the actions that the component takes.
Defines the templates used by the component.