Image
Images with loading, fallback, transformations and general viewing of the series.
When to use
Image displays a thumbnail with interactive viewing: scaling, rotating, flipping and moving. ImagePreviewGroup groups images into a series. For a regular illustration without preview, set preview:false or use a native img.
CSS Image Prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. Image.previewPrefixCls - The full viewer prefix, including the explicit empty string. undefined adds -preview to the thumbnail prefix. For PreviewGroup this is the basic Image prefix: viewer adds -preview; group thumbnails choose their namespace independently.
Miniature, loading and spare source
src refers to a miniature, preview.src may indicate an original of higher resolution. width/height reserve a place in advance. placeholder — boolean or snippet before loading; fallback substitutes a fallback file in case of error.
| Problem | Opportunity | Example |
|---|---|---|
| Open image | src, preview |
Main View |
| Show preview content | placeholder |
Loading |
| Substitute backup file | fallback |
Source error |
| Separate the original from the miniature | preview.src |
Other source |
| View episode | ImagePreviewGroup |
Group |
| Open a series of one picture | explicit items |
One miniature |
onLoad and onError report image load and failure. Pass your progress value in placeholder.progress. The application supplies the percentage. Image events still determine whether the request loads or fails.
Group opening and indexes
Preview:true uses local state. With preview.open, the owner must accept the new value in onOpenChange and pass it back. For the group, also update the current via onChange. current starts from zero, but countRender gets its number from one.
The group uses explicit items or registered child Images. An explicit array, including an empty one, takes precedence. Therefore, you can show one thumbnail, transfer the entire series to items, or open the view with an external button without thumbnails at all.
mask separately specifies the presence of darkening, blur, and background closure. focusTrap holds focus inside the viewer; example in Modal checks for returning to the original action after closing.
Transformations and own content
scaleStep, minScale/maxScale limit the scale, wheel controls wheel scaling, movable controls movement. onTransform communicates the transform and action via requestAnimationFrame. In the group actions.onActive(offset) takes a relative step.
actionsRender gets the original actionbar and viewer context. imageRender receives an image snippet and transform. Keep the original snippets if you supplement standard operations with a signature or button, as in action bars.
Transformations change the CSS, not the source file. The download link in the example preserves the original. Creating a rotated file requires separate Canvas processing and a CORS enabled source.
API design and boundaries
Alt describes the image; preview opens by pressing or Enter. For a decorative picture, do not duplicate adjacent text. Own controls viewer should remain buttons with accessible names.
class/style refers to the img, styles.root refers to the thumbnail wrapper. classNames.popup.root styles the root of a single or group view. The remaining semantic slots are not yet available in the official version. Six Image design tokens apply to the thumbnail and viewer, including PreviewGroup; preview.zIndex allows you to override the preview level. Native nodes are accessible via nativeElement/imageElement.
Examples
Action: no. Scale: 100%.
View Image
Pressing or Enter opens a view with zoom, rotation and flip.
<script lang="ts">
import { Image, type ImageTransformAction } from '@woodger/antd';
let action = $state<ImageTransformAction | "no">(("no"));
let scale = $state(1);
</script>
<Image
src="/examples/image/landscape.svg"
alt={("Mountain landscape")}
width={240}
preview={{
onTransform: info => {
action = info.action;
scale = info.transform.scale;
}
}}
/>
<p
role="status"
aria-label={("Image Conversion")}
>{("\n Action: ")}{action}{(". Scale: ")}{(Math.round(
scale * 100
))}%.
</p>
Preload
Snippet with blurry illustration is displayed before the main file is loaded.
<script lang="ts">
import { Button, Image } from '@woodger/antd';
let revision = $state(0);
let loaded = $state(false);
function reload() {
loaded = false;
revision++;
}
</script>
<style>
.placeholder {
position: relative;
height: 160px;
overflow: hidden;
}
.placeholder span {
position: absolute;
inset: 0;
display: grid;
place-items: center;
color: #fff;
background: rgb(0 0 0 / 35%);
}
.actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-top: 16px;
}
</style>
{#snippet placeholder()}
<div class="placeholder">
<Image
src="/examples/image/coast.svg"
alt={("")}
width={240}
height={160}
preview={false}
style="filter:blur(8px)"
/>
<span>{("Loading image...")}</span>
</div>
{/snippet}
<Image
src={`/examples/image/landscape.svg?demo=progressive&revision=${revision}`}
alt={("Landscape with pre-loading")}
width={240}
height={160}
placeholder={(placeholder)}
onLoad={() => { loaded = true; }}
/>
<div class="actions">
<Button onclick={reload}>{("Upload again")}</Button>
<span role="status" aria-label={("Loading Image")}>{(loaded ? "Ready" : "Loading…")}</span>
</div>
Backup image
fallback substitutes a fallback file in case of decoding error; button restores the source.
<script lang="ts">
import { Button, Image } from '@woodger/antd';
let source = $state('data:image/png;base64,AA==');
let failed = $state(false);
function restore() {
failed = false;
source = '/examples/image/landscape.svg';
}
</script>
<style>
.actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-top: 16px;
}
</style>
<Image
src={source}
fallback="/examples/image/geometry.svg"
alt={("Image with backup illustration")}
width={240}
onError={() => { failed = true; }}
/>
<div class="actions">
<Button onclick={restore}>{("Restore source")}</Button>
<span role="status" aria-label={("Source Status Image")}>
{(failed ? "Backup illustration shown" : "Original image available")}
</span>
</div>
General view
ImagePreviewGroup combines child Images. Saved review example with three images.
<script lang="ts">
import { Image, ImagePreviewGroup } from '@woodger/antd';
const images = ['#1677ff', '#722ed1', '#13c2c2'].map(
(color, index) =>
({
src: 'data:image/svg+xml,' + encodeURIComponent(
`<svg xmlns="http://www.w3.org/2000/svg" width="900" height="600"><rect width="900" height="600" fill="${color}"/><circle cx="450" cy="300" r="160" fill="white" opacity="0.6"/><text x="450" y="335" text-anchor="middle" font-size="100">${index
+ 1}</text></svg>`
),
alt: `Gallery Image ${index + 1}`
})
);
</script>
<div style="
display: flex;
gap: 12px;
flex-wrap: wrap;
"><ImagePreviewGroup>{#each images as image}<Image
{...image}
width={140}
/>{/each}</ImagePreviewGroup></div>
Series of one miniature
items specifies a complete series, although one image is shown on the page.
<script lang="ts">
import { Image, ImagePreviewGroup } from '@woodger/antd';
const items = [
{ src: '/examples/image/landscape.svg', alt: "Mountains in the series" },
{ src: '/examples/image/coast.svg', alt: "Coast series" },
{ src: '/examples/image/geometry.svg', alt: "Geometry in the series" }
];
</script>
<ImagePreviewGroup items={(items)}>
<Image src={items[0].src} alt={("Open a series of three images")} width={240} />
</ImagePreviewGroup>
Separate viewing source
preview.src is different from the thumbnail src; in the application this is how they connect the original of a higher resolution.
<script lang="ts">
import { Image } from '@woodger/antd';
</script>
<Image
src="/examples/image/coast.svg"
alt={("Coastal miniature, mountains in view")}
width={240}
preview={{ src: '/examples/image/landscape.svg' }}
/>
Guided View
The owner stores open and current, processes callbacks and configures the counter.
<script lang="ts">
import { Button, ImagePreviewGroup, Select } from '@woodger/antd';
let open = $state(false);
let current = $state(1);
const items = [
{ src: '/examples/image/landscape.svg', alt: "Mountains in Guided View" },
{ src: '/examples/image/coast.svg', alt: "Coast in Guided View" },
{ src: '/examples/image/geometry.svg', alt: "Geometry in Headed View" }
];
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
}
.field { width: 180px; }
output {
display: block;
margin-top: 16px;
}
</style>
{#snippet counter(index: number, total: number)}{("\n Image ")}{(index)}{(" from ")}{(total)}
{/snippet}
<ImagePreviewGroup
items={(items)}
preview={{
open,
current,
countRender: counter,
onOpenChange: (next, info) => {
open = next;
current = info.current;
},
onChange: next => { current = next; }
}}
>
<div class="controls">
<div class="field">
<Select
aria-label={("Initial image")}
bind:value={current}
options={(items.map((item, value) => ({ value, label: item.alt })))}
/>
</div>
<Button onclick={() => { open = true; }}>{("Open view")}</Button>
</div>
</ImagePreviewGroup>
<output aria-label={("Guided View")}>{("Image: ")}{(current + 1)}{(". Open: ")}{(open ? "yes" : "no")}.</output>
Own action bar
actionsRender retains standard operations and adds reset and download of the original.
<script lang="ts">
import { Image, type ImagePreviewRenderInfo } from '@woodger/antd';
import type { Snippet } from 'svelte';
</script>
<style>
.toolbar {
display: grid;
justify-items: center;
gap: 12px;
max-width: calc(100vw - 24px);
}
.custom-actions {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 12px;
}
.custom-actions a,
.custom-actions button {
padding: 8px 12px;
border: 1px solid #fff;
border-radius: 6px;
color: #fff;
background: #262626;
font: inherit;
text-decoration: none;
}
.custom-actions a:focus-visible,
.custom-actions button:focus-visible {
outline: 2px solid #fff;
outline-offset: 2px;
}
</style>
{#snippet actions(original: Snippet, info: ImagePreviewRenderInfo)}
<div class="toolbar">
{@render original()}
<div class="custom-actions">
<button
type="button"
onclick={info.actions.onReset}
>{("Reset transformations")}</button>
<a href={(info.image.url)} download="landscape.svg">
{("Download original")}
</a>
</div>
</div>
{/snippet}
<Image
src="/examples/image/landscape.svg"
alt={("Landscape with additional actions")}
width={240}
preview={{ actionsRender: actions }}
/>
View content
imageRender saves the original image and adds a caption with the current scale.
<script lang="ts">
import { Image, type ImageInfo, type ImageTransform } from '@woodger/antd';
import type { Snippet } from 'svelte';
</script>
<style>
figure { display: contents; }
figcaption {
position: absolute;
top: 24px;
left: 50%;
width: min(70vw, 440px);
transform: translateX(-50%);
padding: 8px;
border-radius: 8px;
color: #fff;
background: rgb(0 0 0 / 65%);
pointer-events: none;
}
</style>
{#snippet renderImage(
original: Snippet,
info: { transform: ImageTransform; image: ImageInfo; current?: number }
)}
<figure>
{@render original()}
<figcaption>
{(info.image.alt)}{(" Scale: ")}{(Math.round(
info.transform.scale * 100
))}%
</figcaption>
</figure>
{/snippet}
<Image
src="/examples/image/coast.svg"
alt={("Coast with label")}
width={240}
preview={{ imageRender: renderImage }}
/>
View background
Dimming, blurring, no background and separate background closure control.
<script lang="ts">
import { Checkbox, Image, Select } from '@woodger/antd';
let mode = $state<'dimmed' | 'blur' | 'none'>('blur');
let closable = $state(true);
</script>
<style>
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 20px;
}
.field { width: 180px; }
</style>
<div class="controls">
<div class="field">
<Select
aria-label={("View background Image")}
bind:value={mode}
options={([
{ value: 'blur', label: "Blur" },
{ value: 'dimmed', label: "Dimming" },
{ value: 'none', label: "No background" }
])}
/>
</div>
<Checkbox bind:checked={closable}>{("Close by background")}</Checkbox>
</div>
<Image
src="/examples/image/geometry.svg"
alt={("Geometry with background customization")}
width={240}
preview={{ mask: { enabled: mode !== 'none', blur: mode === 'blur', closable } }}
/>
Label on thumbnail
coverNode and placement specify the content and location of the caption on hover or focus.
<script lang="ts">
import { Image } from '@woodger/antd';
</script>
{#snippet cover()}<span>{("Open image ↗")}</span>{/snippet}
<Image
src="/examples/image/coast.svg"
alt={("Coast with caption on hover")}
width={240}
preview={{ cover: { coverNode: cover, placement: 'bottom' } }}
/>
Semantic styles
styles.root designs the thumbnail wrapper, class/style - img, classNames.popup.root - individual or group viewing. The remaining semantic slots have not yet been transferred.
<script lang="ts">
import { Image, ImagePreviewGroup } from '@woodger/antd';
const items = [
{ src: '/examples/image/landscape.svg', alt: "Mountains in a decorated group" },
{ src: '/examples/image/coast.svg', alt: "Coast in a decorated group" }
];
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
align-items: start;
gap: 24px;
}
figure {
display: grid;
gap: 8px;
margin: 0;
}
figcaption { color: var(--ant-color-text-secondary); }
:global(.image-semantic-single) {
outline: 3px solid var(--ant-color-success);
outline-offset: -3px;
}
:global(.image-semantic-group) {
outline: 3px solid var(--ant-color-primary);
outline-offset: -3px;
}
</style>
<div class="examples">
<figure>
<Image
src="/examples/image/landscape.svg"
alt={("Image with individual styles")}
width={160}
rootClassName="image-semantic-thumbnail"
class="image-semantic-image"
style="border-radius:4px"
styles={{ root: `
border: 2px dashed var(--ant-color-success);
border-radius: 12px;
` }}
classNames={{ popup: { root: 'image-semantic-single' } }}
/>
<figcaption>{("Thumbnail and viewing")}</figcaption>
</figure>
<figure>
<ImagePreviewGroup items={(items)} classNames={{
popup: {
root: 'image-semantic-group'
}
}}>
<Image src="/examples/image/landscape.svg" alt={("Group with viewing design")} width={160} />
</ImagePreviewGroup>
<figcaption>{("General viewing of the series")}</figcaption>
</figure>
</div>
View inside Modal
Opens on top of a modal window and returns focus after closing the view.
<script lang="ts">
import { Button, Image, Modal } from '@woodger/antd';
let open = $state(false);
</script>
<Button onclick={() => { open = true; }}>{("Open image window")}</Button>
<Modal bind:open title={("Image inside Modal")} footer={null}>
<p>{("Open view. Escape first closes the image and returns focus to the thumbnail.")}</p>
<Image
src="/examples/image/coast.svg"
alt={("Coast inside Modal")}
width={240}
/>
</Modal>
Component tokens
Local thumbnail theme and viewer, ImagePreviewGroup, CSS variables and priority preview.zIndex.
<script lang="ts">
import { Checkbox, ConfigProvider, Image, ImagePreviewGroup } from '@woodger/antd';
let named = $state(false);
let explicitLayer = $state(false);
const items = [
{ src: '/examples/image/landscape.svg', alt: "Mountains in the thematic group" },
{ src: '/examples/image/coast.svg', alt: "Coast in the thematic group" }
];
</script>
<style>
.settings {
display: grid;
justify-items: start;
gap: 12px;
margin-bottom: 20px;
}
.images {
display: flex;
flex-wrap: wrap;
align-items: start;
gap: 20px;
}
figure {
display: grid;
gap: 8px;
margin: 0;
}
figcaption { color: var(--ant-color-text-secondary); }
</style>
<div class="settings">
<Checkbox bind:checked={named}>{("Named CSS Image Variables")}</Checkbox>
<Checkbox bind:checked={explicitLayer}>{("Explicit preview.zIndex=2300")}</Checkbox>
</div>
<ConfigProvider theme={{
cssVar: named ? { key: 'image-tokens-demo', prefix: 'image-tokens-demo' } : undefined,
components: {
Image: {
previewOperationSize: 30,
previewOperationColor: '#722ed1',
previewOperationHoverColor: '#fa8c16',
previewOperationColorDisabled: '#595959',
zIndexPopup: 2100,
progressAnimationDuration: '9s'
}
}
}}>
<div class="images">
<figure>
<Image
src="/examples/image/landscape.svg"
alt={("Local topic Image")}
width={160}
preview={{ zIndex: explicitLayer ? 2300 : undefined }}
/>
<figcaption>{("Single image")}</figcaption>
</figure>
<figure>
<ImagePreviewGroup items={(items)} preview={{
zIndex: explicitLayer ? 2300 : undefined
}}>
<Image
src="/examples/image/landscape.svg"
alt={("Local group topic")}
width={160}
/>
</ImagePreviewGroup>
<figcaption>{("Group of two images")}</figcaption>
</figure>
</div>
</ConfigProvider>
Open the image to scale, rotate and move.
Landscape from review
Saved example with local data URL.
<script lang="ts">
import { Image } from '@woodger/antd';
const source = 'data:image/svg+xml,' + encodeURIComponent(
'<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="800"><rect width="1200" height="800" fill="#1677ff"/><circle cx="850" cy="220" r="90" fill="#fff"/><path d="M0 800 400 300 700 700 950 400 1200 800" fill="#0958d9"/></svg>'
);
</script>
<Image src={source} alt={("Landscape for viewing")} width={240} />
<p>{("Open the image to scale, rotate and move.")}</p>
Image.previewPrefixCls - The full viewer prefix, including the explicit empty string. Undefined adds -preview to the thumbnail prefix. For PreviewGroup this is the basic Image prefix: viewer adds -preview; group thumbnails choose their namespace independently.
CSS prefixes Image
Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.
<script lang="ts">
import { Checkbox, ConfigProvider, Image, ImagePreviewGroup } from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
const prefix = $derived(custom ? 'suite' : 'ant');
const localPrefix = $derived(local ? 'project-image' : '');
let independent = $state(true);
let scale = $state(1);
</script>
<style>
.example,
.prefix-stage {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("General prefix Image suite")}</Checkbox>
<Checkbox bind:checked={local}>{("Local prefix Image")}</Checkbox>
</div>
<ConfigProvider prefixCls={prefix} theme={{ cssVar: { prefix: 'image-theme' } }}>
<div class="prefix-stage">
<Checkbox
bind:checked={independent}
>{("Independent viewing prefix Image")}</Checkbox>
<Image prefixCls={localPrefix} previewPrefixCls={independent ? 'project-viewer' : undefined}
src="/examples/image/landscape.svg" alt={("Landscape with prefix")} width={200}
preview={{ onTransform: info => scale = info.transform.scale }} />
<ImagePreviewGroup previewPrefixCls={local ? 'project-gallery' : undefined}>
<Image src="/examples/image/landscape.svg" alt={("Gallery with prefix, first frame")} width={120} />
<Image src="/examples/image/coast.svg" alt={("Gallery with prefix, second frame")} width={120} />
</ImagePreviewGroup>
<output
aria-label={("Image scale with prefix")}
>{("Scale: ")}{(Math.round(scale * 100))}%</output>
</div>
</ConfigProvider>
<output
aria-label={("CSS prefix Image")}
>{("General: ")}{prefix}{("; local: ")}{(localPrefix
|| ("from the provider"))}</output>
<p>
{("Image.previewPrefixCls - The full viewer prefix, including the explicit empty string. Undefined adds -preview to the thumbnail prefix. For PreviewGroup this is the basic Image prefix: viewer adds -preview; group thumbnails choose their namespace independently.")}
</p>
</div>
API
Example themes verified against ant.design 6.7.0; Svelte API - with installed package based on 6.6.8. Full definitions of Props belong to @woodger/antd. All example images are stored locally.
| Theme | Example or limitation |
|---|---|
| Basic Usage | View with keyboard and mouse. |
| Progressive Loading | placeholder accepts a Snippet or progress supplied by the application. |
| Fault tolerant | Spare file and src recovery. |
| Multiple image preview | Registration of child Images. |
| Preview from one image | Explicit items, one thumbnail. |
| Custom preview image | Independent preview.src. |
| Controlled Preview | open/current, callbacks, countRender. |
| Custom toolbar render | Snippet actionsRender, reset and download original. Converted Canvas export has not been added. |
| Custom preview render | imageRender preserving original. |
| preview mask | mask.enabled, blur and closable. |
| Custom semantic dom styling | Partially: styles.root for Image and classNames.popup.root for Image/PreviewGroup. The remaining slots are not yet available. |
| nested | View over Modal. |
Image
| Property | Description | Type | Default |
|---|---|---|---|
previewPrefixCls | Full viewer prefix; undefined adds -preview to resolved Image.prefixCls. The explicit empty string is retained. Namespace styles are included by the library. | string | Image prefixCls + "-preview" |
prefixCls | Full CSS prefix of the component and its parts. A non-empty local prop takes precedence; empty string and undefined inherit ConfigProvider. The namespace of the topic is set separately. | string | ConfigProvider.prefixCls + "-image" |
src | Thumbnail URL; native srcset, sizes, loading and referrerpolicy are also available. | string | — |
alt | Description of the picture and name of the view button. | string | — |
width | Thumbnail width. | number | string | — |
height | Thumbnail height. | number | string | — |
preview | View settings; false leaves the normal image. | boolean | ImagePreviewConfig | true |
placeholder | true enables the built-in placeholder background. Show a Snippet or progress while loading. | boolean | Snippet | { progress? } | — |
fallback | Fallback URL for thumbnail and preview in case of error. | string | — |
onError | Error loading or decoding thumbnail. | (event: Event) => void | — |
onLoad | Loading a thumbnail, including fallback. | (event: Event) => void | — |
styles | CSS string for the root wrapper of the thumbnail. | { root?: string } | — |
classNames | Separate view root class. For general viewing, it is set to ImagePreviewGroup. | { popup?: { root?: string } } | — |
style | Style img; class also applies to img. | string | — |
nativeElement | bind:nativeElement - thumbnail container. | HTMLElement | after mount |
imageElement | bind:imageElement - native img. | HTMLImageElement | after mount |
preview for Image
| Property | Description | Type | Default |
|---|---|---|---|
src | Independent viewer URL. | string | src Image |
alt | Describes the image in the viewer. A nonempty value also gives the dialog an accessible name. | string | alt Image |
getContainer | Viewer container. The getter runs in the browser without arguments. | GetContainer | ConfigProvider.getPopupContainer |
open | Controlled visibility. Update it in onOpenChange. | boolean | local state |
onOpenChange | Request to change visibility. | (open: boolean) => void | — |
afterOpenChange | Reports visibility after the animation finishes. | (open: boolean) => void | — |
onTransform | State after conversion; callback is delivered via requestAnimationFrame. | ({ transform, action }) => void | — |
scaleStep | Single step multiplier: 1 + scaleStep. | number | 0.5 |
minScale | Minimum scale. | number | 1 |
maxScale | Maximum scale. | number | 50 |
wheel | Zooming with the mouse wheel. | boolean | true |
movable | Drag and drop the enlarged image. | boolean | true |
focusTrap | Modal dialog with focus holding. | boolean | true |
mask | Background and closing based on it. | boolean | { enabled?, blur?, closable? } | true |
cover | Thumbnail label, false hides it. | boolean | Snippet | { coverNode?, placement? } | standard area |
actionsRender | Action bar and context with transform, image and actions. | Snippet<[original, info]> | standard actions |
imageRender | View content; original preserves the built-in transformations. | Snippet<[original, info]> | image |
zIndex | Explicit dialog layer. | number | 1080 |
ImagePreviewGroup
| Property | Description | Type | Default |
|---|---|---|---|
previewPrefixCls | Basic Image prefix for general viewing: viewer adds -preview. The empty string/undefined inherits the common Image prefix. Does not rename thumbnails. | string | ConfigProvider.prefixCls + "-image" |
classNames | General view root class. | { popup?: { root?: string } } | — |
items | URL strings or objects with native img fields. Even an empty array has priority over child registration. | readonly ImagePreviewGroupItem[] | child Image |
preview | General viewing settings; false disables opening. | boolean | ImagePreviewGroupConfig | true |
fallback | Spare file for the general viewer. | string | — |
Additions preview group
| Property | Description | Type | Default |
|---|---|---|---|
current | Managed index from scratch. | number | 0 |
onChange | Image change request; save the new index. | (current, previous) => void | — |
onOpenChange | Visibility with image index. | (open, { current }) => void | — |
countRender | Unlike current, the number in countRender starts with one. | Snippet<[current, total]> | number / total |
Use Image.PreviewGroup or the named ImagePreviewGroup export to preview a series. preview.getContainer selects the viewer container, and preview.alt describes the open image.
Semantic DOM
Thumbnail - native button with img; at preview={false} container becomes div. The view uses dialog, image, background, close and transform buttons. The button opens with Enter or a spacebar; Escape closes the view and returns focus.
In upstream, root, image, cover and popup.root/mask/body/footer/actions/close are available. In Svelte styles.root designs the miniature wrapper, and classNames.popup.root
specifies the class of the view root. These fields accept objects; callbacks and other slots are not yet available.
style and class refer to img, rootClassName - to the wrapper.
actionsRender and imageRender receive the original content as a Snippet. Challenge original() saves inline actions or image with transformations.
Registration tokens
theme.components.Image applies six tokens to the thumbnail and viewer, including ImagePreviewGroup. The example shows action sizes and colors, a custom zIndexPopup, and named CSS variables. Explicit preview.zIndex
takes precedence over the topic token.
progressAnimationDuration specifies a CSS duration variable. Object
placeholder.progress has not yet been ported, so there is no separate example of a progress animation yet.
| Token | Purpose |
|---|---|
zIndexPopup | View layer. |
previewOperationSize | Size of action icons. |
previewOperationColor | Action color. |
previewOperationHoverColor | Hover action color. |
previewOperationColorDisabled | Color of unavailable actions. |
progressAnimationDuration | Loading animation duration; progress API has not yet been migrated. |
| Token | Meaning |
|---|---|
colorBgMask | rgba(0,0,0,0.45) |
colorTextLightSolid | #fff |
colorTextSecondary | rgba(0,0,0,0.65) |
colorPrimaryBorder | #adc6ff |
fontSize | 14 |
marginXL | 32 |
motionDurationSlow | 0.3s |
FAQ
How to open a series without all the miniatures?
Set items to ImagePreviewGroup. A child Image or external button with controlled open will open the overall series.
Why doesn't the view close with controlled open?
Update open in onOpenChange. For a managed index, handle onChange in the same way.
Is the rotated image downloaded?
No. The example downloads the source file; CSS transform doesn't change its content.
How to show loading and error?
placeholder is visible before loading, fallback replaces the failed source. Reserve your thumbnail sizes in advance.