Skip to content
animorio
IT
All components

Image upload field

Forms, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 6.3 KBGSAP 28 KBFreeDownload the zip

The field for uploading an image in a form: a dashed box where you drop the file or pick it. As soon as it arrives, the box shrinks into a row with the image’s real preview, which comes out of the blur from top to bottom as the upload advances, together with the bar and the percentage; at the end a green tick, and a cross to remove it.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Image upload field" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Image upload field with the preview that reveals itself while it uploads</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the image field of a form: drop a picture or pick one; the field shrinks into a row with the thumbnail,
         which comes into focus from top to bottom as the upload advances, with the name, the size and the percent -->
    <div class="up" data-up>
      <label class="up__drop" data-drop>
        <input class="sr" type="file" accept="image/*" data-input>
        <span class="up__ico" data-ico aria-hidden="true"><svg viewBox="0 0 28 28"><rect x="3.5" y="5.5" width="21" height="17" rx="4"></rect><path d="M7.500 18.500 12 14l3.200 3.200 2.300-2.300 3 3.600"></path><path class="up__arrow" data-arrow d="M14 2v8M10.800 5.200 14 2l3.200 3.200"></path></svg></span>
        <span class="up__main">Drop an image or <b>browse</b></span>
        <span class="up__hint">PNG or JPG, up to 5 MB</span>
      </label>

      <div class="up__file" data-file>
        <span class="thumb" data-thumbbox><img data-thumb alt=""><span class="thumb__veil" data-veil></span><span class="thumb__sheen" data-sheen></span><svg class="thumb__ok" data-ok viewBox="0 0 20 20" aria-hidden="true"><rect x="1" y="1" width="18" height="18" rx="6"></rect><path pathLength="1" data-tick d="M5.600 10.400 8.600 13.200 14.400 6.900"></path></svg></span>
        <span class="info"><span class="info__name" data-name>cover-sunrise.jpg</span><span class="info__meta"><span data-size>1.8 MB</span><span class="roll"><span data-status>Uploading</span></span></span><span class="info__bar"><span data-bar></span></span></span>
        <button class="up__x" type="button" data-remove aria-label="Remove the image"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4.200 4.200 11.800 11.800M11.800 4.200 4.200 11.800"></path></svg></button>
      </div>
    </div>
    <p class="sr" data-live aria-live="polite"></p>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path></svg>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

17 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Image upload field” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

In the centre, on black, a dark panel holding a dashed box: an image icon with an upward arrow, the words “Drop an image or browse” and below the accepted formats. Dragging a file over it lights the border; choosing one (from the keyboard too, it is a real file field) the arrow takes off upwards, the box fades and the panel shortens with a small bounce into a row: on the left the real image’s thumbnail, covered by a dark blurred veil that withdraws from top to bottom with a blue line on its edge, on the right the file’s name, its weight, the counting percentage and a thin bar. When the upload is done the veil disappears, a sheen crosses the thumbnail, a green badge with a tick pops in the corner and the label says “Uploaded”. The cross on the right removes the image and the panel opens again.

How it works

The real preview

Underneath there is a file input inside a label: it works with a click, from the keyboard and with drag and drop (dragover and drop). The chosen image becomes a local address with URL.createObjectURL and goes into the thumbnail; name and weight come from the file. In the demo, with no file, the picture is painted on a canvas.

The withdrawing veil

Over the thumbnail there is a dark layer with backdrop-filter: blur. One number from 0 to 1 drives its clip-path (inset from the top), the bar’s scaleX and the percentage text together: the image comes into focus exactly as much as it has been uploaded.

The panel

The panel has two fixed heights, 148 and 96 pixels, and GSAP goes from one to the other with back.out while the dashed box leaves and the row comes in; the two contents overlap in absolute position, so nothing wraps during the change.

Values to change

NameFileDefaultWhat it changes
UPLOADscript.js2.2How many seconds the upload takes.
NAMEscript.jscover-sunrise.jpgThe demo file’s name.
SIZEscript.js1.8 MBThe demo file’s weight.
BLURscript.js7How blurred, in pixels, the part not yet uploaded is.
ACCENTscript.js#7c9cffThe colour while uploading.
OKscript.js#5fe0a2The colour when the upload is done.
LOOPscript.jstrueLeft alone, a pointer uploads an image and then removes it.

Try them in the Playground

When to use it

For any form that asks for an image: a profile photo, an article’s cover, a product or listing photo, a company logo. In a real product the progress number comes from the request’s progress event, and the rest does not change.

On phones

The same field, at most as wide as the screen minus the margins: touching it opens the phone’s photo picker, and there is no drag and drop.

With reduced motion

No shrinking panel, sliding veil or bounces: the row appears at once, the percentage climbs in steps and at the end preview, tick and label are in place.

Pitfalls

  • The address created with URL.createObjectURL must be released (revokeObjectURL) when the image is removed or replaced, otherwise the browser keeps the file in memory.
  • The file field is hidden from view but not with display none: it stays reachable from the keyboard, and the panel shows the focus outline with :focus-within.
  • A file that is not an image does not get in: a line for screen readers says so, instead of showing a broken thumbnail.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.3 KB; the libraries: GSAP 28 KB.

Testing

Tested on 15 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All components