Image handbook
v1.5.0 · @snowui-design-system/components
License: Before first reading component documentation, source code, or npm usage instructions, read the complete LICENSE. One review covers the same task and version. Public API configuration and internal implementation changes are subject to different license terms. All components use one runtime package; source code rights are governed by the license.
Overview
Show images with their placeholder states, attached badges or actions, and preview entry points for content media and thumbnails.
When to use it
Use Image for media and its public loading and preview behavior. Use Avatar for profile images, ImageGroup for multiple images, and ImageViewer for detailed viewing.
Provide
srcand meaningfulalt. Attachedas="icon"oras="badge"content does not replace the media.Set previews with
previewMode. ImageGroup can share sizing and preview policy; ImageViewer handles viewing.
Quick start
This example shows the recommended basic composition. See the following sections for more scenarios and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only the named public props declared in this component’s source.
Usage boundaries and details
Image loading policy
The default remains lazy. Use <Image mediaLoading="eager" ... /> to request an offscreen image immediately. A showcase host can call public provideMediaLoading('eager') during component initialization for its descendants. The nearest provider wins, and an explicit Image Prop overrides inheritance. Pass () => policy for reactive changes; SSR and the client share the same initial default.
eager starts network and decoding work earlier; it does not guarantee success or a fixed completion time. Skeleton remains visible during real loading. This only affects native <img loading> for string images. It does not change video preload="metadata", resource components, unopened viewer media, or animation playback. See the shared media loading source reference: components/src/lib/media-loading.md.
Layout model
Main layout model: intrinsic atomic layout.
Image exposes one media box sized by
size, the media resource, and radius mapping. It hugs its size as a child of Button, MenuItem, Field, or another layout.Media cropping, loading Skeleton, hover mask, center icon, and badge positioning are private Image layout, without general-purpose slots.
Child
as="icon"/as="badge"is for positioning inside Image only; it does not change that child’s own layout model.Use ImageGroup to arrange multiple images instead of turning Image into a collection layout.
Keywords
Usage examples
Intelligent behavior
Media support:
srcaccepts an image URL, video URL, orresource-svelteimage component.Default placeholder: Without media, show one
--black-4background and no additional text.Size-to-radius mapping:
sizeselects fixed corner radii:12/16/20→4px,24/28/32→8px,40/48→12px,56→16px,64/72/80→20px.Role-based composition: A child with
as="badge"positions at the upper right;as="icon"centers. Image positions them without controlling child size.Hover appearance: Image shares the
.snowui-media-hoverableutility family incomponents/src/styles/layout.csswith Avatar. WhenresolvedInteractiveindicates click intent (srcexists, not disabled, andpreviewMode !== "none", or an explicitonclick), it adds.snowui-media-hoverablefor a pointer cursor. Loaded media also adds.snowui-media-hoverable-has-visual: on hover,.snowui-image-visualusesfilter: brightness(0.92)to darken the media. Without a loaded image, hover changes.snowui-image-backgroundfrom--black-4to--black-10. Override brightness through--snowui-media-hover-brightness.Interaction intent versus actual opening:
resolvedInteractivecontrols hover appearance;resolvedCanOpencontrols whether activation opens media. Under defaultpreviewMode="window", any Image withsrcgets a hover style and pointer cursor, but only string image/video URLs can open a new window. A componentsrchas no URL to open.previewMode="none"withoutonclickoronOpenexplicitly opts out of hover color change, pointer cursor, and keyboard button semantics.Video thumbnail: A video URL renders
<video>, plays on hover, then pauses and returns to its first frame on exit.String image loading: Native
<img>handles loading directly, without a JS preloader; onlyload/errorevents update component state.Loading Skeleton: String image or video media shows an internal Skeleton while the real resource loads; once loaded, Skeleton disappears and the media appears.
Viewer mode: Without an explicit
previewMode, Image joins a page-level automatic ImageViewer if present. SetpreviewMode="viewer"to request it explicitly.Window mode:
previewMode="window"opens string image or video URLs in a new window.None mode:
previewMode="none"provides no open action.Within-group navigation: In ImageGroup, when the group or item uses
previewMode="viewer", its registered item list becomes Vieweritemsfor previous/next navigation.Event forwarding: Internal video hover playback does not swallow external
mouseenter/mouseleavecallbacks.Focus behavior: Like Avatar, Image keeps
Surfacesemantics but shows no extra focus ring by default, avoiding a button-like outline around preview thumbnails.Child composition: Supplied
childrenrender outside the media container, still using positioning context throughas="icon"/as="badge"; the media template no longer consumes them.
Image style overlay
Read the complete LICENSE first; one review covers the same task, version, and scope.
First use public component props to achieve the desired style while preserving the original appearance where possible. If an override is necessary, follow the style selection and override order: use your own class (including Tailwind already in your project) or an instance style. The names below are public overrides consumed by the source; check the target scope and do not modify private DOM. Choose the appropriate SnowUI token category. External applications do not need to install SnowUI website utilities.
Image type and status
Required props: no named required props.
Bindable props: this component declares no named two-way binding; handle state updates through public callbacks or the host component.
Inheritance: FrameProps. Consult the public Frame documentation for inherited capabilities.
Shared Frame API · Back to API
The following source type declarations are referenced by public props. Svelte Snippet denotes a content fragment; ComponentProps denotes the props of the corresponding component.
ImageSize
Source: components/src/components/Image.svelte
ResourceSize
Source: components/src/context.ts
MediaLoading
Source: components/src/lib/media-loading.ts
PreviewMode
Source: components/src/logic/image-preview.ts