Displays an input that lets users upload an image and see its preview.
The Image Field component is made up of Root and Preview. View source
Displays a stylized image input field.
The following errors may be returned by the onError
function:
This component is based on the div
element and supports common margin props m
, mx
, my
, ml
, mr
, mt
, mb
.
A placeholder is rendered when no preview is displayed. Use the placeholder
prop to change the default text.
Make the Root part controlled to access the uploaded file.
Use the onSrcChange
prop to access the temporary URL of the preview image.
Use a URL for the defaultFile
prop to create an uncontrolled field with an initial value.
You can render a custom preview layout if you pass a function as a child of the Preview part.
Use the backgroundColor
prop on the Preview part to set a background color on the preview image.