files-ui-main-logo
Files ui

ImagePreview API

API reference docs for the React ImagePreview component. Learn about the props and other APIs of this exported module.

Apart from the props described bellow, the ImagePreview component accepts all the HTML <img/> default props. You can check them out here.

Demo

Props

NameTypeDefaultDescription
src
string
|
File
Image source in string format (URL) or File Object (Will be read as URL).
width
string
The width of the image.
height
string
The height of the image.
alt
string
Alternative label when an error occurs on loading the image
onError
func
Callback fired when an error occured on loading the image.
smartImgFit
false
|
"orientation"
|
"center"
"orientation"
If false, image width will be set to 100%.
If present, image will be analized and displayed according to its heigh and width. Image with height greater than its width has a "portrait" orientation. Otherwise it has a "landscape" orientation. .
  • If value is "center", image will be centered and will not be displayed complete. This the empty space is avoided. This is achived by giving 100% to width prop if the orientation is "portrait". When orientation is "landscape", height prop will be set to 100%.
  • If value is "orientation", image will be displayed complete by giving 100% to width prop if the orientation is "landscape". When orientation is "portrait", height prop will be set to 100%. Some images will show an empty space.
style
React.CSSProperties
The in-line style object.
className
string
The classname to override the css styles in .css or .sass file instead of using in-line styles.