Skip to content
animorio
IT
All components

File preview card

Cards, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 14 KBGSAP 28 KBFreeDownload the zip

People searched for “file preview” and found little that fit: here is the file list of a shared folder in a made-up workspace, Fieldnote, alone on white, with a PDF, a spreadsheet, a presentation, a photo and an audio file. Resting on a row springs open the preview card, anchored to the row by its tip: the PDF page with its lines settling and the page count rolling, the spreadsheet grid filling up, three slides flipping over, the real lake photo, the waveform drawing itself. Moving from row to row the card never closes: it slides, changing height and content on the way. Below, who edited it, Open and Share. On a phone it opens under the row.

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>
<!--
  "File preview card" 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>File preview card</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" data-stage>
    <!-- the files of a shared folder in a made-up workspace, Fieldnote: resting on a row opens the preview card anchored
         to it, and moving to another row slides the same card there while it changes shape and content -->
    <div class="group" data-group>
      <section class="files" data-files aria-labelledby="fp-title">
        <header class="files__head">
          <span class="folder" aria-hidden="true"><svg viewBox="0 0 20 20"><path d="M2.6 5.6c0-.9.7-1.6 1.6-1.6h3.3l1.7 1.8h6.6c.9 0 1.6.7 1.6 1.6v7.1c0 .9-.7 1.6-1.6 1.6H4.2c-.9 0-1.6-.7-1.6-1.6z"></path><path class="folder__lip" d="M2.6 8.2h14.8"></path></svg></span>
          <span class="crumb"><span class="crumb__ws" data-ws>Fieldnote</span><svg class="crumb__sep" viewBox="0 0 8 12" aria-hidden="true"><path d="M2.4 2.2L5.8 6l-3.4 3.8"></path></svg><h2 class="crumb__dir" id="fp-title" data-folder>Spring launch</h2></span>
          <span class="files__count">5 files</span>
        </header>

        <div class="files__body" data-body>
          <span class="hl" data-hl aria-hidden="true"></span>
          <ul class="rows" role="list">
            <li><button class="row" type="button" data-row="pdf" aria-haspopup="dialog" aria-expanded="false">
              <span class="ico ico--pdf" aria-hidden="true"><svg viewBox="0 0 24 28"><path class="ico__sheet" d="M4.5 1.5h10.2l5.8 5.8v17.2c0 1.1-.9 2-2 2h-14c-1.1 0-2-.9-2-2v-21c0-1.1.9-2 2-2z"></path><path class="ico__fold" d="M14.7 1.5v4.3c0 .8.7 1.5 1.5 1.5h4.3"></path><path class="ico__mark" d="M7.5 13.5h9M7.5 17h9M7.5 20.5h5.5"></path></svg><span class="ico__tag">PDF</span></span>
              <span class="row__name"><span class="row__title">Brand guidelines.pdf</span><span class="row__sub">4.2 MB &middot; Nov 18</span></span>
              <span class="row__size">4.2 MB</span>
              <span class="row__date">Nov 18</span>
            </button></li>
            <li><button class="row" type="button" data-row="sheet" aria-haspopup="dialog" aria-expanded="false">
              <span class="ico ico--sheet" aria-hidden="true"><svg viewBox="0 0 24 28"><path class="ico__sheet" d="M4.5 1.5h10.2l5.8 5.8v17.2c0 1.1-.9 2-2 2h-14c-1.1 0-2-.9-2-2v-21c0-1.1.9-2 2-2z"></path><path class="ico__fold" d="M14.7 1.5v4.3c0 .8.7 1.5 1.5 1.5h4.3"></path><path class="ico__mark" d="M6.8 12.5h10.4v9H6.8zM6.8 15.5h10.4M6.8 18.5h10.4M10.6 12.5v9"></path></svg><span class="ico__tag">XLS</span></span>
              <span class="row__name"><span class="row__title">Revenue forecast.xlsx</span><span class="row__sub">186 KB &middot; Nov 20</span></span>
              <span class="row__size">186 KB</span>
              <span class="row__date">Nov 20</span>
            </button></li>
            <li><button class="row" type="button" data-row="slides" aria-haspopup="dialog" aria-expanded="false">
              <span class="ico ico--slides" aria-hidden="true"><svg viewBox="0 0 24 28"><path class="ico__sheet" d="M4.5 1.5h10.2l5.8 5.8v17.2c0 1.1-.9 2-2 2h-14c-1.1 0-2-.9-2-2v-21c0-1.1.9-2 2-2z"></path><path class="ico__fold" d="M14.7 1.5v4.3c0 .8.7 1.5 1.5 1.5h4.3"></path><path class="ico__mark" d="M6.8 12.8h10.4v6.6H6.8zM12 19.4v2.6M9.6 22h4.8"></path></svg><span class="ico__tag">PPT</span></span>
              <span class="row__name"><span class="row__title">Launch deck.pptx</span><span class="row__sub">12.8 MB &middot; Nov 21</span></span>
              <span class="row__size">12.8 MB</span>
              <span class="row__date">Nov 21</span>
            </button></li>
            <li><button class="row" type="button" data-row="image" aria-haspopup="dialog" aria-expanded="false">
              <span class="ico ico--image" aria-hidden="true"><svg viewBox="0 0 24 28"><path class="ico__sheet" d="M4.5 1.5h10.2l5.8 5.8v17.2c0 1.1-.9 2-2 2h-14c-1.1 0-2-.9-2-2v-21c0-1.1.9-2 2-2z"></path><path class="ico__fold" d="M14.7 1.5v4.3c0 .8.7 1.5 1.5 1.5h4.3"></path><path class="ico__mark" d="M6.6 21.4l3.6-4.4 2.6 3 1.8-2.1 2.8 3.5M15.2 13.4a1.3 1.3 0 1 1-.01 0"></path></svg><span class="ico__tag">JPG</span></span>
              <span class="row__name"><span class="row__title">Lakeside cover.jpg</span><span class="row__sub">2.6 MB &middot; Nov 21</span></span>
              <span class="row__size">2.6 MB</span>
              <span class="row__date">Nov 21</span>
            </button></li>
            <li><button class="row" type="button" data-row="audio" aria-haspopup="dialog" aria-expanded="false">
              <span class="ico ico--audio" aria-hidden="true"><svg viewBox="0 0 24 28"><path class="ico__sheet" d="M4.5 1.5h10.2l5.8 5.8v17.2c0 1.1-.9 2-2 2h-14c-1.1 0-2-.9-2-2v-21c0-1.1.9-2 2-2z"></path><path class="ico__fold" d="M14.7 1.5v4.3c0 .8.7 1.5 1.5 1.5h4.3"></path><path class="ico__mark" d="M7 17v1.6M9.4 15v5.6M11.8 13v9.6M14.2 15.4v4.8M16.6 16.4v2.8"></path></svg><span class="ico__tag">M4A</span></span>
              <span class="row__name"><span class="row__title">Founder interview.m4a</span><span class="row__sub">5.1 MB &middot; Nov 22</span></span>
              <span class="row__size">5.1 MB</span>
              <span class="row__date">Nov 22</span>
            </button></li>
          </ul>
        </div>
      </section>

      <!-- the one preview card: it moves from row to row and changes its body -->
      <aside class="card" data-card role="dialog" aria-label="File preview" aria-hidden="true">
        <span class="card__caret" data-caret aria-hidden="true"></span>
        <div class="card__in">
          <header class="card__head">
            <span class="swap" data-head-name><span>Brand guidelines.pdf</span></span>
            <span class="swap swap--meta" data-head-meta><span>PDF document</span></span>
          </header>

          <div class="view" data-view>
            <!-- pdf: a small page whose lines settle, the page count rolls -->
            <div class="pane pane--pdf" data-pane="pdf">
              <div class="pages" aria-hidden="true">
                <span class="page page--back"></span>
                <span class="page page--mid"></span>
                <span class="page page--front" data-page>
                  <span class="pl pl--kicker"></span>
                  <span class="pl pl--title"></span>
                  <span class="pl pl--title2"></span>
                  <span class="pl pl--swatches"><i></i><i></i><i></i><i></i></span>
                  <span class="pl pl--txt"></span>
                  <span class="pl pl--txt pl--s"></span>
                  <span class="pl pl--txt"></span>
                  <span class="pl pl--txt pl--xs"></span>
                </span>
              </div>
              <div class="pdfinfo">
                <span class="bignum roll" data-pages aria-label="24 pages"></span>
                <span class="pdfinfo__lbl">pages</span>
                <span class="pdfinfo__note">A4 &middot; v3</span>
              </div>
            </div>

            <!-- sheet: a small grid that fills, the selection lands on the total -->
            <div class="pane pane--sheet" data-pane="sheet">
              <div class="grid" data-grid aria-hidden="true"></div>
              <span class="sel" data-sel aria-hidden="true"></span>
            </div>

            <!-- slides: three slides that flip over -->
            <div class="pane pane--slides" data-pane="slides">
              <div class="deck" aria-hidden="true">
                <span class="slide slide--a" data-slide><span class="sa__t"></span><span class="sa__t sa__t--2"></span><span class="sa__ring"></span></span>
                <span class="slide slide--b" data-slide><span class="sb__t"></span><span class="sb__bars"><i></i><i></i><i></i><i></i><i></i></span></span>
                <span class="slide slide--c" data-slide><span class="sc__big"></span><span class="sc__l"></span><span class="sc__l sc__l--2"></span><span class="sc__l sc__l--3"></span></span>
              </div>
            </div>

            <!-- image: one real photo -->
            <div class="pane pane--image" data-pane="image">
              <figure class="photo" data-photo>
                <img src="lake.webp" alt="A wooden dock running into a calm lake below forested hills" width="800" height="534" decoding="async">
                <figcaption class="photo__dims">2400 &times; 1600</figcaption>
              </figure>
            </div>

            <!-- audio: a waveform that draws itself in thin lines -->
            <div class="pane pane--audio" data-pane="audio">
              <span class="play" aria-hidden="true"><svg viewBox="0 0 20 20"><path d="M7.6 5.6l7 4.4-7 4.4z"></path></svg></span>
              <svg class="wave" data-wave viewBox="0 0 200 56" preserveAspectRatio="none" aria-hidden="true"></svg>
              <span class="atime roll" data-atime></span>
            </div>
          </div>

          <footer class="card__foot">
            <div class="who">
              <span class="avatar" data-avatar aria-hidden="true"><span data-ini>MI</span></span>
              <span class="who__text">
                <span class="swap" data-who><span>Edited by Mara Ilves</span></span>
                <span class="swap swap--when" data-when><span>2 hours ago</span></span>
              </span>
            </div>
            <div class="acts">
              <button class="act act--open" type="button" data-open-btn><span class="act__bg" aria-hidden="true"></span><span class="act__lbl">Open</span></button>
              <button class="act act--share" type="button" data-share><span class="act__bg" aria-hidden="true"></span><span class="act__lbl" data-share-lbl>Share</span><svg class="act__tick" viewBox="0 0 14 14" aria-hidden="true"><path d="M3.2 7.3l2.4 2.4 5.2-5.4" pathLength="1" data-tick></path></svg></button>
            </div>
          </footer>
        </div>
      </aside>
    </div>

    <svg class="ghost" data-ghost viewBox="0 0 22 22" aria-hidden="true"><path d="M4.5 2.8l12.6 9.4-5.6.9 3.3 6.1-2.3 1.2-3.2-6.1-4.1 3.9z"></path></svg>
    <p class="sr" aria-live="polite" data-live></p>
  </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.

60 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “File preview card” 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

On a white background, the panel of a shared folder in Fieldnote, a made-up workspace: at the top the folder icon, Fieldnote › Spring launch and “5 files”. Below, five rows, each with the kind’s icon drawn in SVG (a sheet with a folded corner, the kind’s mark and a PDF, XLS, PPT, JPG or M4A tag), the name, the size and the date. Resting on a row, a soft grey background slides under it, the icon nods on a spring and its tag turns blue, and next to it the preview card springs open with its tip pointing at the row: at the top the file’s name and kind, then the preview, below the avatar of whoever edited it with when, and the Open and Share buttons. For the PDF three stacked pages that fan out, the abstract lines of the first settling one after another and the page count rolling up to 24; for the spreadsheet a grid whose cells fill diagonally and the selected cell, with its handle, jumping to the total; for the presentation three slides (a blue one, a bar chart, a black one) flipping one after another; for the image a real photo of a dock on a lake uncovering from the centre with its size in a glass pill; for the audio a play button and a thin-line waveform drawing itself from the left while the playhead turns it blue. Moving from row to row the card never closes: it slides to the new row, changes height on a spring, the old content rises and fades while the new one arrives, and name, kind, author and initials roll. Share becomes “Link copied” as a tick draws itself. On a phone the card opens under the row and the rows after it move down to make room.

How it works

One card for every row

There is a single card, absolutely positioned inside the group. For each row the row’s position, the height of the preview pane and so the card’s final height are worked out from offsetTop; GSAP moves the card’s left/top, the preview window’s height and the tip together, so the card slides and changes shape instead of closing and reopening.

Panes that swap

The five panes sit on top of each other in the preview window, each with its own height in clamp and vh: the old one rises four pixels and fades in 0.16 seconds, the new one comes up from below a moment later, and the texts (name, kind, author) roll with two spans in the same grid cell.

An entrance for each kind of file

Each kind has its own small timeline, killed when the row changes: the PDF lines settling with back.out and the page counter in digit columns, the cell bars in scaleX staggered by row plus column, the slides rotating to the back of the deck, the photo opening with clip-path inset, the waveform lines in scaleY and the playhead colouring them.

Beside or below

Above 720 pixels the card opens to the right of the list, with the tip on its left side kept level with the row; below that it opens inside the panel, under the row: the rows after it move down by the card’s height and the panel grows with an animated padding-bottom.

The drawn pointer

The autopilot is a timeline that carries an SVG pointer from row to row, aiming at where the row will be once its card is open (removing GSAP’s offset), then steps into the card and presses Share. As soon as the real mouse moves or the screen is touched it stops, and it starts again by itself after eight quiet seconds.

Values to change

NameFileDefaultWhat it changes
WORKSPACEscript.jsFieldnoteThe workspace name, at the top of the list.
FOLDERscript.jsSpring launchThe folder name.
PDF_PAGESscript.js24How many pages the PDF has: the number rolls when the card shows it.
AUDIO_SECONDSscript.js42How long the audio lasts, in seconds.
HOVER_DELAYscript.js0.09How long you rest on a row before the card opens.
CLOSE_DELAYscript.js0.35How long the card waits before closing once the pointer leaves.
MORPH_TIMEscript.js0.6How long the card takes to slide from row to row and change shape.
SPRINGscript.js1.4How far the card overshoots when it opens and when it arrives.
DWELLscript.js2.4How long the drawn pointer rests on each row.
LOOP_PAUSEscript.js1.4The pause with the card closed before the loop starts again.

Try them in the Playground

When to use it

In the file list of a cloud drive or workspace, in a project’s attachments in a team app, in a client’s materials folder in a portal, in the documents of a dashboard or on a site’s downloads page: anywhere people need to see what is inside a file without opening it.

On phones

Below 720 pixels the card does not open to the side but inside the panel, under the row, and the rows after it move down; in narrow rows size and date go under the name, the card drops its header (the name is already in the row) and puts author and buttons on one line. Row and preview heights also follow the height with clamp and vh, so with the card open everything fits the 341 by 410 box. Tapping a row opens or closes the card, tapping outside closes it.

With reduced motion

No springs, slides or entrances: the card is already open on the photo, on hover it changes row with a fade and the content already in place (pages counted, grid filled, waveform drawn) and the self-running loop does not start.

Pitfalls

  • On a phone the drawn pointer aimed at the row while it was still pushed down by the previous card and landed on the wrong row: it now aims at the row’s position without GSAP’s offset, that is where it will be with its card open.
  • On a phone a tap fired focus first (which opened the card) and then click (which closed it again): focus only opens the card when it is :focus-visible, that is from the keyboard.
  • The card’s tip is a small square rotated 45 degrees: with GSAP moving it, the CSS rotation was lost; GSAP now rotates it together with x and y, and the edge shadow changes side between the side card and the one below.
  • With a “12 slides” label inside the preview, the deck covered it while flipping: removed, the number is already in the file kind at the top of the card.
  • In the phone box, with the card open under a row, the last row went past the edge: in short boxes the panel moves to the top and the header gets shorter.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 22 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