ImageUpload

A single-image upload component with drag-and-drop support, inline preview, loading state, and file validation. Available in square and circle variants, making it suitable for both general image fields and profile avatar uploads.

Import

import { ImageUpload } from '@wavebooking/aqua-fusion';

Preview

Loading preview...

Usage

<ImageUpload
  value={imageUrl}
  onChange={(url) => setImageUrl(url)}
  onUpload={async (file) => {
    const url = await uploadToStorage(file);
    return url;
  }}
/>
 
<ImageUpload
  variant="circle"
  size={160}
  emptyIcon="UserCircleIcon"
  onChange={handleChange}
  onUpload={handleUpload}
/>

Props

PropTypeDefaultDescription
onChange*(url: string | null) => void-Callback fired when the image changes. Receives the URL or null when removed.
onUpload*(file: File) => Promise<string>-Async function that uploads the file and returns the resulting URL.
valuestring-Current image URL for controlled usage.
variant'square' | 'circle''square'Shape variant of the upload area.
sizenumber128Width and height of the upload area in pixels.
maxSizenumber5242880Maximum file size in bytes (default is 5 MB).
emptyIconHeroIconName-Icon shown when no image is set. Defaults to 'UserCircleIcon' for circle and 'PhotoIcon' for square.
labelsImageUploadLabels-Custom label strings for internationalization (uploadText, fileSizeError, fileTypeError, uploadError, removeAriaLabel, uploadAriaLabel).
disabledbooleanfalseWhether the upload is disabled.
classNamestring-Additional CSS classes to apply to the upload area.