logoNamu Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
1.0.0
  • Components Overview
  • General
    • Button
    • FloatButtonNew
    • Icon
    • Typography
  • Layout
    • Divider
    • Grid
    • Layout
    • Space
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPickerNew
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
    • Popover
    • QRCodeNew
    • Segmented
    • Statistic
    • Table
    • Tabs
    • Tag
    • Timeline
    • Tooltip
    • TourNew
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • AppNew
    • ConfigProvider
When To Use
Examples
Basic Usage
Fault tolerant
Progressive Loading
Multiple image preview
Preview from one image
Custom preview image
Controlled Preview
Custom toolbar render
Custom preview render
API
Image
PreviewType
PreviewGroup
PreviewGroupType
Interface
TransformType
TransformAction
ToolbarRenderInfoType
Design Token

Image

  • EmptyList

    Resources

    Namu Design Charts
    Namu Design Pro
    Namu Design Pro Components
    Namu Design Mobile
    Namu Design Mini
    Namu Design Landing-Landing Templates
    Scaffolds-Scaffold Market
    Umi-React Application Framework
    dumi-Component doc generator
    qiankun-Micro-Frontends Framework
    ahooks-React Hooks Library
    Ant Motion-Motion Solution
    China Mirror 🇨🇳

    Community

    Awesome Namu Design
    Medium
    Twitter
    yuqueNamu Design in YuQue
    Namu Design in Zhihu
    Experience Cloud Blog
    seeconfSEE Conf-Experience Tech Conference

    Help

    GitHub
    Change Log
    FAQ
    Bug Report
    Issues
    Discussions
    StackOverflow
    SegmentFault

    Ant XTechMore Products

    yuqueYuQue-Document Collaboration Platform
    AntVAntV-Data Visualization
    EggEgg-Enterprise Node.js Framework
    kitchenKitchen-Sketch Toolkit
    xtechAnt Financial Experience Tech
    Theme Editor
    Made with ❤ by
    Ant Group and Namu Design Community

    Previewable 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.

    expand codeexpand code
    Fault tolerant

    Load failed to display image placeholder.

    expand codeexpand code
    Progressive Loading

    Progressive when large image loading.

    expand codeexpand code
    Multiple image preview

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

    expand codeexpand code
    Preview from one image

    Preview a collection from one image.

    expand codeexpand code
    Custom preview image

    You can set different preview image.

    expand codeexpand code
    Controlled Preview

    You can make preview controlled.

    expand codeexpand code
    Custom toolbar render

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

    expand codeexpand code
    Custom preview render

    You can customize the preview content.

    expand codeexpand code

    API

    Common props ref:Common props

    Image

    PropertyDescriptionTypeDefaultVersion
    altImage descriptionstring-4.6.0
    fallbackLoad failure fault-tolerant srcstring-4.6.0
    heightImage heightstring | number-4.6.0
    placeholderLoad placeholder, use default placeholder when set trueReactNode-4.6.0
    previewpreview config, disabled when falseboolean | PreviewTypetrue4.6.0 PreviewType:4.7.0
    srcImage pathstring-4.6.0
    widthImage widthstring | number-4.6.0
    onErrorLoad failed callback(event: Event) => void-4.12.0

    Other attributes <img>

    PreviewType

    参数说明类型默认值版本
    visibleWhether the preview dialog is visible or notboolean--
    srcCustom preview srcstring-4.10.0
    getContainerThe mounted node for preview dialog but still display at fullScreenstring | HTMLElement | (() => HTMLElement) | false-4.8.0
    movablewhether can be movedbooleantrue5.8.0
    maskThumbnail maskReactNode-4.9.0
    maskClassNameThe className of the maskstring-4.11.0
    rootClassNameThe classname of the preview root DOMstring-5.4.0
    scaleStep1 + scaleStep is the step to increase or decrease the scalenumber0.5-
    minScaleMin scalenumber15.7.0
    maxScaleMax scalenumber505.7.0
    closeIconCustom close iconReact.ReactNode-5.7.0
    forceRenderForce render preview dialogboolean--
    toolbarRenderCustom toolbar render(originalNode: React.ReactNode, info: Omit<ToolbarRenderInfoType, 'current' | 'total'>) => React.ReactNode-5.7.0
    imageRenderCustom preview content(originalNode: React.ReactNode, info: { transform: TransformType }) => React.ReactNode-5.7.0
    onTransformCallback when the transform of image changed{ transform: TransformType, action: TransformAction }-5.7.0
    onVisibleChangeCallback when visible changed(visible: boolean, prevVisible: boolean) => void--

    PreviewGroup

    参数说明类型默认值版本
    previewPreview config, disabled when falseboolean | PreviewGroupTypetrue4.6.0 PreviewGroupType:4.7.0
    itemsPreview itemsstring[] | { src: string, crossOrigin: string, ... }[]-5.7.0
    fallbackLoad failure fault-tolerant srcstring-5.7.0

    PreviewGroupType

    参数说明类型默认值版本
    visibleWhether the preview dialog is visible or notboolean--
    getContainerThe mounted node for preview dialog but still display at fullScreenstring | HTMLElement | (() => HTMLElement) | false-4.8.0
    movablewhether can be movedbooleantrue5.8.0
    currentThe index of the current previewnumber-4.12.0
    maskThumbnail maskReactNode-4.9.0
    maskClassNameThe className of the maskstring-4.11.0
    rootClassNameThe classname of the preview root DOMstring-5.4.0
    scaleStep1 + scaleStep is the step to increase or decrease the scalenumber0.5-
    minScaleMin scalenumber15.7.0
    maxScaleMax scalenumber505.7.0
    closeIconCustom close iconReact.ReactNode-5.7.0
    forceRenderForce render preview dialogboolean--
    countRenderCustom preview count content(current: number, total: number) => React.ReactNode-4.20.0
    toolbarRenderCustom toolbar render(originalNode: React.ReactNode, info: ToolbarRenderInfoType) => React.ReactNode-5.7.0
    imageRenderCustom preview content(originalNode: React.ReactNode, info: { transform: TransformType, current: number }) => React.ReactNode-5.7.0
    onTransformCallback when the transform of image changed{ transform: TransformType, action: TransformAction }-5.7.0
    onChangeCallback when switch preview image(current: number, prevCurrent: number) => void-5.3.0
    onVisibleChangeCallback when visible changed(visible: boolean, prevVisible: boolean, current: number) => void-current 参数 5.3.0

    Interface

    TransformType

    {
    x: number;
    y: number;
    rotate: number;
    scale: number;
    flipX: boolean;
    flipY: boolean;
    }

    TransformAction

    type TransformAction =
    | 'flipY'
    | 'flipX'
    | 'rotateLeft'
    | 'rotateRight'
    | 'zoomIn'
    | 'zoomOut'
    | 'close'
    | 'prev'
    | 'next'
    | 'wheel'
    | 'doubleClick'
    | 'move'
    | 'dragRebound';

    ToolbarRenderInfoType

    {
    icons: {
    flipYIcon: React.ReactNode;
    flipXIcon: React.ReactNode;
    rotateLeftIcon: React.ReactNode;
    rotateRightIcon: React.ReactNode;
    zoomOutIcon: React.ReactNode;
    zoomInIcon: React.ReactNode;
    };
    actions: {
    onFlipY: () => void;
    onFlipX: () => void;
    onRotateLeft: () => void;
    onRotateRight: () => void;
    onZoomOut: () => void;
    onZoomIn: () => void;
    };
    transform: TransformType,
    current: number;
    total: number;
    }

    Design Token

    Component Token

    Global Token

    Preview
    Preview
    Preview
    Preview
    Preview
    Preview
    Preview
    scaleStep:

    Preview
    Preview
    Preview