logoAnt Design

⌘ K
  • 디자인
  • 개발
  • 컴포넌트
  • 블로그
  • 자료
5.21.3
  • Components Overview
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • Space
    • Splitter
      5.21.0
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
      5.5.0
    • 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
    • QRCode
      5.1.0
    • Segmented
    • Statistic
    • Table
    • Tabs
    • Tag
    • Timeline
    • Tooltip
    • Tour
      5.0.0
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
      5.1.0
  • Other
    • Affix
    • App
      5.1.0
    • ConfigProvider
    • Util
      5.13.0

Image

Preview-able image.
가져오기import{ Image }from"antd";
소스components/image
문서
이 페이지 수정변경 로그

Resources

Ant Design Charts
Ant Design Pro
Ant Design Pro Components
Ant Design Mobile
Ant Design Mini
Ant 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 Ant Design
Medium
Twitter
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference
Work with Us

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

When To Use

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

Examples

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

PropertyDescriptionTypeDefaultVersion
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.ReactElement, info: Omit<ToolbarRenderInfoType, 'current' | 'total'>) => React.ReactNode-5.7.0, info.image: 5.18.0
imageRenderCustom preview content(originalNode: React.ReactElement, info: { transform: TransformType, image: ImgInfo }) => React.ReactNode-5.7.0, image: 5.18.0
destroyOnCloseDestroy child elements when closing previewbooleanfalse
onTransformCallback when the transform of image changed{ transform: TransformType, action: TransformAction }-5.7.0
onVisibleChangeCallback when visible changed(visible: boolean, prevVisible: boolean) => void--

PreviewGroup

PropertyDescriptionTypeDefaultVersion
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

PropertyDescriptionTypeDefaultVersion
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.ReactElement, info: ToolbarRenderInfoType) => React.ReactNode-5.7.0, info.image: 5.18.0
imageRenderCustom preview content(originalNode: React.ReactElement, info: { transform: TransformType, image: ImgInfo, current: number }) => React.ReactNode-5.7.0, image: 5.18.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 Property 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: {
onActive?: (index: number) => void; // support after 5.21.0
onFlipY: () => void;
onFlipX: () => void;
onRotateLeft: () => void;
onRotateRight: () => void;
onZoomOut: () => void;
onZoomIn: () => void;
onReset: () => void; // support after 5.17.3
onClose: () => void;
};
transform: TransformType,
current: number;
image: ImgInfo
}

ImgInfo

{
url: string;
alt: string;
width: string | number;
height: string | number;
}

Design Token

컴포넌트 토큰어떻게 사용하나요?

토큰 이름설명타입기본값
previewOperationColor预览操作图标颜色stringrgba(255, 255, 255, 0.65)
previewOperationColorDisabled预览操作图标禁用颜色stringrgba(255, 255, 255, 0.25)
previewOperationHoverColor预览操作图标悬浮颜色stringrgba(255, 255, 255, 0.85)
previewOperationSize预览操作图标大小number18
zIndexPopup预览浮层 z-indexnumber1080

글로벌 토큰어떻게 사용하나요?

Basic Usage
codepen icon
External Link Icon
expand codeexpand code
Fault tolerant
codepen icon
External Link Icon
expand codeexpand code
Progressive Loading
codepen icon
External Link Icon
expand codeexpand code
Multiple image preview
codepen icon
External Link Icon
expand codeexpand code
Preview from one image
codepen icon
External Link Icon
expand codeexpand code
Custom preview image
codepen icon
External Link Icon
expand codeexpand code
Controlled Preview
codepen icon
External Link Icon
expand codeexpand code
Custom toolbar render
codepen icon
External Link Icon
expand codeexpand code
Custom preview render
codepen icon
External Link Icon
expand codeexpand code
Custom preview mask
codepen icon
External Link Icon
expand codeexpand code
nested
codepen icon
External Link Icon
expand codeexpand code
Top progress customization when previewing multiple images
codepen icon
External Link Icon
expand codeexpand code
Custom component token
codepen icon
External Link Icon
expand codeexpand code
Gets image info in the render function
codepen icon
External Link Icon
expand codeexpand code
미리보기
미리보기
미리보기
미리보기
미리보기
미리보기
미리보기
scaleStep:

미리보기
미리보기
미리보기
미리보기
示例
미리보기
미리보기
미리보기
미리보기
미리보기
test
미리보기