# Image Viewer
> A thumbnail that opens the image over the page, with zoom controls.
Source: https://native.shellui.dev/docs/components/data-display/image-viewer
## Installation
```bash
shellui-native add image-viewer
```
**Platforms:** MAUI · Avalonia. Also installs `icon`.
## Usage
### Basic
**MAUI**
```xml
```
**Avalonia**
```xml
```
[Live preview](https://native.shellui.dev/preview/index.html?c=image-viewer-basic)
Give the viewer a size: the thumbnail fills it. A tap opens the image over the page on a dark backdrop, with zoom out, reset, zoom in and close controls. A tap on the backdrop or Escape closes it.
### A smaller thumbnail file
Set `ThumbnailSource` to a smaller file for the page. `Source` then loads only when the viewer opens.
### Zoom
`Zoom` goes from 0.5 to 4, where 1 fits the page. Zooming scales the image around its centre; it doesn't pan. `ZoomIn()`, `ZoomOut()` and `ResetZoom()` do what the controls do.
## MAUI and Avalonia
- `Source` is an `ImageSource` on MAUI (an image in `Resources/Images`) and an `IImage` on Avalonia (a resource path such as `/Assets/photo.jpg`).
- How the thumbnail fills its box is `Aspect` on MAUI and `Stretch` on Avalonia.
- MAUI zooms with a pinch. Avalonia zooms with the mouse wheel and the + / - / 0 keys.
- On Avalonia the thumbnail and the controls are tab stops.
## API
XAML children go to `Items` on Avalonia.
| Property | Type | Default | Description |
|---|---|---|---|
| `Source` | `ImageSource` (MAUI) · `IImage?` (Avalonia) | `null` | The image shown in the viewer, and as the thumbnail when `ThumbnailSource` isn't set. |
| `ThumbnailSource` | `ImageSource` (MAUI) · `IImage?` (Avalonia) | `null` | A smaller file for the page; `Source` then loads only in the viewer. |
| `Description` | `string` | — | What the image shows, for screen readers. |
| `Aspect` | `Aspect` | `AspectFill` | How the thumbnail fills its box. MAUI only. |
| `Open` | `bool` | `false` | Whether the viewer is open. Two-way bindable. |
| `Stretch` | `Stretch` | `UniformToFill` | How the thumbnail fills its box. Avalonia only. |
| Event | Arguments | Description |
|---|---|---|
| `OpenChanged` | `bool` | Opened or closed. |
| Method | Description |
|---|---|
| `ZoomIn()` | Zooms in one step, up to 4. |
| `ZoomOut()` | Zooms out one step, down to 0.5. |
| `ResetZoom()` | Back to 1, where the image fits the page. |
| `SetOpen(bool value)` | Opens or closes it. |