Flutter docs
Default skin

Image

Preview-able image.

When to use

  • When you need to display pictures.
  • Display when loading a large image or fault tolerant handling when loading fail.

Examples

Basic Usage

Click the image to zoom in.

Fault tolerant

Load failed to display image placeholder.

Preview from one image

Preview a collection from one image.

Controlled Preview

You can make preview controlled.

Custom preview render

You can customize the preview content.

Custom semantic dom styling

You can customize the semantic dom style of Image by passing objects/functions through classNames and styles.

Progressive Loading

Set placeholder via placeholder prop. When placeholder is { progress: true }, it shows a watercolor ink loading animation; when set to { progress: { percent: number } }, it shows a progress bar; you can also pass a custom React node as placeholder.

Multiple image preview

Click the left and right switch buttons to preview multiple images.

Custom preview image

You can set different preview image.

Custom toolbar render

You can customize the toolbar and add a button for downloading the original image or downloading the flipped and rotated image.

preview mask

mask effect.

nested

Nested in the modal

API

Image and Image.PreviewGroup are exported from @ceebee/ui/client.

Preview control names use LabelsProvider keys, including imagePrevious, imageNext, and the image transform labels. Ant Design continues to own preview navigation, zoom, focus, keyboard, and dismissal behavior.

The full-screen preview uses a solid dark canvas so its light toolbar controls stay readable over any image.

Image

PropertyDescriptionTypeDefaultVersion
altImage descriptionstring-—
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-—
fallbackFallback URL when load failsstring-—
heightImage heightstring | number-—
placeholderLoading placeholder, supports ReactNode or config objectPlaceholderType-—
previewPreview configuration; set to false to disableboolean | PreviewTypetrue—
srcImage URLstring-—
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-—
widthImage widthstring | number-—
onErrorCallback when loading error occurs(event: Event) => void-—

PlaceholderType

PropertyDescriptionTypeDefaultVersion
progressProgress config, set to true to show gradient animation, set { percent: number } to show progress, render for custom renderingboolean | ImageProgressConfig-—

ImageProgressConfig

PropertyDescriptionTypeDefaultVersion
percentProgress valuenumber-—
renderCustom rendering, receives default progress UI and percentage(progress: React.ReactNode, percent: number) => React.ReactNode-—

PreviewType

PropertyDescriptionTypeDefaultVersion
actionsRenderCustom toolbar render(originalNode: React.ReactElement, info: ToolbarRenderInfoType) => React.ReactNode-—
closeIconCustom close iconReact.ReactNode-—
coverCustom preview maskReact.ReactNode | CoverConfig-CoverConfig support after v6.0
focusTrapWhether to trap focus within the preview when openbooleantrue6.4.0
destroyOnCloseDestroy child elements on preview close (removed, no longer supported)booleanfalse—
forceRenderForce render preview image (removed, no longer supported)boolean-—
getContainerSpecify container for preview mounting; still full screen; false mounts at current locationstring | HTMLElement | (() => HTMLElement) | false-—
imageRenderCustom preview content(originalNode: React.ReactElement, info: { transform: TransformType, image: ImgInfo }) => React.ReactNode-—
maskpreview mask effectboolean | { enabled?: boolean, blur?: boolean, closable?: boolean }truemask.closable: 6.4.0
maskClassNameThumbnail mask class name; please use 'classNames.cover' insteadstring-—
maxScaleMaximum zoom scalenumber50—
minScaleMinimum zoom scalenumber1—
movableWhether the preview image can be dragged when it is larger than the viewportbooleantrue—
openWhether to display previewboolean-—
rootClassNameRoot DOM class name for preview; applies to both image and preview wrapperstring-—
scaleStepEach step's zoom multiplier is 1 + scaleStepnumber0.5—
srcCustom preview srcstring-—
stylesCustom semantic structure stylesRecord<SemanticDOM, CSSProperties>-—
wheelWhether to enable mouse wheel zoombooleantrue6.6.0
toolbarRenderCustom toolbar; please use 'actionsRender' instead(originalNode: React.ReactElement, info: Omit<ToolbarRenderInfoType, 'current' | 'total'>) => React.ReactNode-—
visibleWhether to show; please use 'open' insteadboolean-—
onOpenChangeCallback when preview open state changes(visible: boolean) => void-—
onTransformCallback for preview transform changes{ transform: TransformType, action: TransformAction }-—
onVisibleChangeCallback when 'visible' changes; please use 'onOpenChange' instead(visible: boolean, prevVisible: boolean) => void-—

PreviewGroup

PropertyDescriptionTypeDefaultVersion
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-—
fallbackFallback URL for load errorstring-—
itemsArray of preview itemsstring[] | { src: string, crossOrigin: string, ... }[]-—
previewPreview configuration; disable by setting to falseboolean | PreviewGroupTypetrue—

PreviewGroupType

PropertyDescriptionTypeDefaultVersion
actionsRenderCustom toolbar render(originalNode: React.ReactElement, info: ToolbarRenderInfoType) => React.ReactNode-—
closeIconCustom close iconReact.ReactNode-—
countRenderCustom preview count render(current: number, total: number) => React.ReactNode-—
focusTrapWhether to trap focus within the preview when openbooleantrue6.4.0
currentIndex of the current preview imagenumber-—
forceRenderForce render preview image (removed, no longer supported)boolean-—
getContainerSpecify container for preview mounting; still full screen; false mounts at current locationstring | HTMLElement | (() => HTMLElement) | false-—
imageRenderCustom preview content(originalNode: React.ReactElement, info: { transform: TransformType, image: ImgInfo, current: number }) => React.ReactNode-—
maskpreview mask effectboolean | { enabled?: boolean, blur?: boolean, closable?: boolean }truemask.closable: 6.4.0
maskClassNameThumbnail mask class name; please use 'classNames.cover' insteadstring-—
minScaleMinimum zoom scalenumber1—
maxScaleMaximum zoom scalenumber50—
movableWhether the preview image can be dragged when it is larger than the viewportbooleantrue—
openWhether to display previewboolean-—
rootClassNameRoot DOM class name for preview; applies to both image and preview wrapper. Use 'classNames.root' insteadstring-—
stylesCustom semantic structure stylesRecord<SemanticDOM, CSSProperties>-—
wheelWhether to enable mouse wheel zoombooleantrue6.6.0
scaleStepEach step's zoom multiplier is 1 + scaleStepnumber0.5—
toolbarRenderCustom toolbar; please use 'actionsRender' instead(originalNode: React.ReactElement, info: ToolbarRenderInfoType) => React.ReactNode-—
visibleWhether to show; please use 'open' insteadboolean-—
onOpenChangeCallback when preview open state changes, includes current preview index(visible: boolean, info: { current: number }) => void-—
onChangeCallback when changing preview image(current: number, prevCurrent: number) => void-—
onTransformCallback for preview transform changes{ transform: TransformType, action: TransformAction }-—
onVisibleChangeCallback when 'visible' changes; please use 'onOpenChange' instead(visible: boolean, prevVisible: boolean, current: number) => void-—