Skip to content

Image

An enterprise-level image component with support for lazy loading, preview, and error fallback.

Basic Usage

Display a basic image.

Example

Object Fit

Use the fit prop to control how the image should be resized to fit its container, just like the native object-fit CSS property.

cover
contain
fill
none
scale-down
Example

Image Preview

Use the preview prop to enable a full-screen image preview. You can also provide an array of images to preview-src-list to allow cycling through multiple images.

Example

Lazy Loading

Use the lazy prop to defer loading the image until it enters the viewport. A skeleton screen is automatically displayed while the image is loading.

Scroll down to see lazy loaded image / Scroll down to see lazy loaded images
Example

Watermark

Use the watermark prop to add a watermark to the image. You can pass a string or a configuration object.

Example

Error Fallback

When an image fails to load, a default error fallback will be displayed automatically.

Example

API

BrImage

Props

NameTypeDefaultDescription
srcstring-The source URL of the image
altstring-The alternative text of the image
fitstring'cover'How the image should fit its container: fill, contain, cover, none, scale-down
lazybooleanfalseWhether to use lazy loading
previewbooleanfalseWhether to enable image preview
previewSrcListstring[][]List of image URLs for the preview gallery
initialIndexnumber0The initial index of the preview gallery
zIndexnumber100The z-index of the preview overlay
watermarkstring | object-Watermark text or configuration object
roundedstring'none'Border radius: none, sm, md, lg, xl, 2xl, full
shadowstring'none'Box shadow: none, sm, md, lg, xl
borderedbooleanfalseWhether to show a border

Events

NameTypeDescription
load(e: Event) => voidEmitted when the image loads successfully
error(e: Event) => voidEmitted when the image fails to load
show() => voidEmitted when the preview is opened
close() => voidEmitted when the preview is closed
switch(index: number) => voidEmitted when switching images in the preview gallery