Image
Displays files, URLs, encoded bytes or raw RGBA pixels.
Displays a raster image (PNG, JPEG, WebP, ICO), an SVG, an HTTP(S) URL or in-memory bytes. On Windows, `src` may also name an executable, library or shortcut (`.exe`, `.dll`, `.lnk`): the image is the file's shell icon as Explorer draws it (a shortcut shows its target's icon), 256 px when the file carries a jumbo icon, else 48 or 32 px. Other platforms decode those paths as ordinary images, so they fail and fire `onError` (or show `fallbackSrc`).
Import
import { Image } from "@tarve/core";Usage
import { Image } from "@tarve/core";
<Image src="assets/photo.png" width={320} height={200} fit="cover" style={{ radius: 12 }} />Props
| Prop | Type | Default |
|---|---|---|
src required Local path, `http(s)://` URL, data URL, encoded bytes, or raw RGBA8 pixels. A URL is fetched and decoded natively, off the UI thread, the first time the image is on screen (like `loading="lazy"`); until then it shows its placeholder. | ImageSource | — |
fallbackSrc Shown instead of a string `src` once it fails (an `onerror` swap to a placeholder), until `clearImageSourceCache()`. | ImageSource | — |
fit CSS `object-fit`. | "cover" | "contain" | "fill" | — |
height | number | — |
onError The source failed to load or decode (HTML `onerror`): a missing file, a bad image, an HTTP error. | (event: ImageErrorEvent) => void | — |
width | number | — |
Common props
Shared by every component. See descriptions →
childrenclassclassNamehighlightidkeymotionFromonHighlightonPasteonPointerLeaveonPointerMoveonSizeonTransitionEndrovingGroupstyleTypes
interface ImageErrorEvent {
/** The source that failed (a path or URL; empty for bytes and pixels). */
src: string;
message: string;
}type ImageSource = string | Uint8Array | ImageBytesSource | ImageRgbaSource;