Image Viewer

A thumbnail that opens the image in a zoomable lightbox.

ImageViewer is new in v0.4. It renders a thumbnail button; clicking it opens the full image over the page, with zoom controls.

Installation

bash
shellui add image-viewer

Usage

Basic

Size the thumbnail with Class. The image covers it.

<ImageViewer Src="@Image" Alt="Landscape illustration" Class="h-40 w-64" />

@code {
    private const string Image = "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='800' height='500'><defs><linearGradient id='s' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%2393c5fd'/><stop offset='1' stop-color='%23fde68a'/></linearGradient></defs><rect width='800' height='500' fill='url(%23s)'/><circle cx='620' cy='140' r='60' fill='%23fbbf24'/><path d='M0 380 L200 220 L360 360 L520 240 L800 400 L800 500 L0 500 Z' fill='%2334d399'/><path d='M0 430 L260 300 L460 440 L800 330 L800 500 L0 500 Z' fill='%23059669'/></svg>";
}

Each viewer opens its own image. Pass a small ThumbnailSrc to keep a grid light and load the full Src only in the lightbox.

Keyboard

Key Action
Esc Close
+ or = Zoom in
- Zoom out
0 Reset zoom

Zoom runs from 50% to 400% in steps of 25%. Clicking the backdrop also closes the viewer.

API Reference

Parameter Type Default Description
Src string "" The full-size image
ThumbnailSrc string? null Image for the thumbnail; defaults to Src
Alt string "" Alternative text
Class string? null Classes for the thumbnail button, such as its size
ImageClass string? null Classes for the thumbnail image

Accessibility

  • The thumbnail is a button labelled "View" plus the Alt text
  • The lightbox is role="dialog" with aria-modal="true" and takes focus when it opens
  • The zoom and close buttons have labels

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.