UploadAvatar

Designer doc
Upload avatar image.

Example

Basic Usage
View code
Previewed images
The image displayed will be the selected file, src, and placeholder in order. Try selecting a file from example below.
View code
Customizing Hint
Hint is the overlay text covering lower part of the avatar. You can specify null to hide it.
View code
You can also provide custom content by render anything inside.
View code
Handling upload
In your actual form, you most likely want to control file prop and later make some API request. Below is an example you can do so.
View code
Clearing selected file
To clear selected file, you can render UploadAvatarClear component inside.
View code
If you have src and you want it to be cleared as well, you have to treat it as a state - listen to onSrcChange and set the src.
View code
By default the UploadAvatarClear is hidden if file and src are empty. You can specify hidden prop false to always show the clear button.
View code

Accessibility

There’s no specific accessibility role for upload, thus the most appropriate role will be button. This component is labelled by wrapping Field and hint inside. It also indicates whether a file has been selected.

References

API

UploadAvatar
Prop nameTypeDefaultDescription
acceptstring | string[]image/*
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
avatarPropsPartial<AvatarProps> & { ref?: Ref<HTMLImageElement>; }
disabledboolean
fileFile
hintReactNodeUpload
initialFileFile
initialSrcstring
maxSizenumber2 * MB
minSizenumber
onChange(file: File) => void
onDrop<T extends File>(acceptedFiles: T[], rejectedFiles: T[], event: DropEvent) => void
onSrcChange(src: string) => void
placeholderstring
sizenumber72
srcstring
UploadAvatarClear
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
disabledboolean
Equivalent to button's disabled property.
keyboardClickKeysstring[]
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
    Example
    Example
    Basic Usage
    Basic Usage
    Previewed images
    Previewed images
    Customizing Hint
    Customizing Hint
    Handling upload
    Handling upload
    Clearing selected file
    Clearing selected file
    Accessibility
    Accessibility
    References
    References
    API
    API
    UploadAvatar
    UploadAvatar
    UploadAvatarClear
    UploadAvatarClear
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2025 Sea Labs