Skip to content
animorio
IT
All components

Accordion document search

Search, HoverGSAP, CSS onlyMediumCompressed weight: Demo 13 KBGSAP 28 KBFreeDownload the zip

The docs search of Cobble, a small team's knowledge base, on white, in the premium style of Dribbble shots: the word types itself, a thin light runs under the field while it looks, then the results arrive grouped by folder. One folder at a time opens like an accordion on a spring, the matched letters get a yellow highlighter stroke that sweeps in from the left with a glint, and the selection is a small indigo plate gliding from row to row while the keys in the footer press down.

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>
<!--
  "Accordion document search" 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>The document search with results grouped in an accordion</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 search of Cobble, the docs of a small team: the query types itself, a thin light runs under the field
         while it looks, then the results arrive grouped by folder. One group at a time opens like an accordion and the
         matched word is marked with a highlighter stroke that sweeps in. The selection glides from row to row on a
         spring and the keys in the footer press as they are used -->
    <div class="wrap" data-wrap>
      <section class="card" data-card role="search" aria-label="Search the team docs">
        <i class="card__grain" aria-hidden="true"></i>
        <i class="card__sheen" aria-hidden="true"></i>

        <div class="field" data-field>
          <svg class="field__lens" data-lens viewBox="0 0 20 20" aria-hidden="true"><circle cx="8.6" cy="8.6" r="5.4"/><path d="M12.6 12.6l4.2 4.2"/></svg>
          <span class="field__type">
            <label class="sr" for="doc-q">Search the docs</label>
            <input class="field__input" id="doc-q" type="text" autocomplete="off" spellcheck="false" placeholder="Search Cobble docs" data-input aria-controls="doc-list" aria-autocomplete="list">
            <span class="field__caret" data-caret aria-hidden="true"></span>
            <span class="field__measure" data-measure aria-hidden="true"></span>
          </span>
          <button class="field__clear" type="button" data-clear aria-label="Clear the search">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M6.5 6.5l7 7M13.5 6.5l-7 7"/></svg>
          </button>
          <i class="field__beam" data-beam aria-hidden="true"></i>
        </div>

        <div class="sum" aria-hidden="true">
          <span class="sum__count"><span class="roll" data-roll><span class="roll__n" data-roll-n>0</span></span> <span data-sum-word>results</span></span>
          <span class="sum__in" data-sum-in>in 0 folders</span>
        </div>

        <div class="list" id="doc-list" data-list role="listbox" aria-label="Results">
          <i class="pick" data-pick aria-hidden="true"></i>
          <div class="groups" data-groups></div>
          <p class="empty" data-empty>
            <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 3.5h7l4 4v13H7z"/><path d="M14 3.5v4h4"/><path d="M10 13.5h5M10 16.5h3"/></svg>
            <span>No documents match <q data-empty-q></q></span>
          </p>
        </div>

        <footer class="foot" aria-hidden="true">
          <span class="hint"><kbd class="key" data-key="up"><svg viewBox="0 0 12 12"><path d="M6 9.2V2.8M3.2 5.6L6 2.8l2.8 2.8"/></svg></kbd><kbd class="key" data-key="down"><svg viewBox="0 0 12 12"><path d="M6 2.8v6.4M3.2 6.4L6 9.2l2.8-2.8"/></svg></kbd><span class="hint__w">move</span></span>
          <span class="hint"><kbd class="key key--wide" data-key="enter"><svg viewBox="0 0 16 12"><path d="M12.6 2.6v3.6a1.6 1.6 0 0 1-1.6 1.6H3.6M6 5.4L3.6 7.8 6 10.2"/></svg></kbd><span class="hint__w">open</span></span>
          <span class="hint"><kbd class="key key--wide" data-key="esc"><span>esc</span></kbd><span class="hint__w">clear</span></span>
        </footer>
      </section>
    </div>
    <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.

28 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 “Accordion document search” 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 white sits the Cobble search card, warm white with a very fine grain, a 1px edge catching light at the top and soft layered shadows. At the top the ‘Search Cobble docs’ field with its lens; below the count line, the list and a light grey footer with drawn keys: the two arrows, Enter and Esc. The field lights up with its indigo ring and types ‘refund’ by itself with its own caret; as soon as it is done the lens tilts and a thin light runs back and forth under the field while it looks. Then the folders arrive, one after the other, the fullest first: Policies 3, Meeting notes 2, Contracts 1, each with its tile and badge, and the count rolls to ‘6 results in 3 folders’. The first folder opens like an accordion on a spring, its chevron turns a quarter and passes the mark, the three documents rise one after another along a thread, and over the matched letters, in the title and in the line below, a yellow highlighter stroke sweeps in from the left with a glint crossing it once. The selection is a small indigo plate with a lit edge: it moves down row by row on a real spring while the down arrow in the footer presses at each step, and on the right of the picked row the time makes way for an Enter key. Once on Meeting notes, Enter presses: Policies folds away and Meeting notes opens with its own highlighted words. On the next row another Enter opens the document: the row gives a touch and comes back, the sheet of its icon lifts and settles. Then Esc presses, the word erases itself, the folders leave and the count goes back to zero; ‘onboarding’ comes in, with Guides 3 first, and the loop starts again. It is a real search: type in it, use the arrows, Enter and Esc, or the pointer.

How it works

A real search, in groups

The documents are a list of objects with folder, title, line and date. A regex looks for the word at the start of a word, in the title and in the line, the matches are grouped in a Map by folder and the folders are sorted fullest first; three remain, with three documents at most.

The accordion on a spring

Each folder has a body zero high with hidden overflow: opening it GSAP takes it from zero to height auto with a damped spring written as an ease (it passes the mark once and lands exactly on 1), the rows rise staggered and the chevron turns 90 degrees on the same spring. Opening a folder closes the others.

The highlighter

The matched letters are wrapped in a span holding an absolute yellow mark, multiplied under the text: it grows with scaleX from the left, staggered between title and line, then a white gradient in background-position runs over it once like a glint of fresh ink.

The gliding plate

The selection is one element under the rows. Every frame the picked row is measured and four springs (x, y, width, height), integrated by hand in two steps, chase it: so it follows the row even while the accordion opens and closes underneath.

The pilot and the person

The loop on its own is a GSAP timeline of calls using the same functions as the keyboard (move, enter, clear), so the footer keys really press. A tap, a key or the wheel from the person stops the pilot and the search is theirs.

Values to change

NameFileDefaultWhat it changes
QUERY_Ascript.jsrefundThe first word the field types by itself.
QUERY_Bscript.jsonboardingThe second word the field types by itself.
TYPINGscript.js11How many letters per second the field types by itself.
LOOKscript.js0.5How many seconds the light runs under the field before the results arrive.
OPENscript.js0.62How many seconds a folder takes to open like an accordion.
SPRINGscript.js1How springy the folders and rows are: 0.5 calm, 2 very bouncy.
MARKERscript.js0.42How many seconds the highlighter takes to sweep over a word.
GLIDEscript.js320The stiffness of the spring the selection glides on: higher is quicker.
AUTOscript.jstrueSearches, browses and opens by itself until someone touches the card.

Try them in the Playground

When to use it

For the search of a documentation site, a help centre, an internal wiki, a notes app or a back office: wherever results come from different places and are best seen by folder, with the found word highlighted and a keyboard that works.

On phones

The same animation with adapted sizes: the card is almost as wide as the screen and at most as tall as the window, rows and folders get shorter with the height, the Esc hint in the footer hides below 420 pixels. With a finger tap a folder to open it and a row to open it.

With reduced motion

Nothing moves: folders and rows fade in, the accordion opens without a spring, the highlighter is already laid down and fades in, the selection jumps to the row without gliding and the count changes in place.

Pitfalls

  • The selection moved with a tween to the row, but while the accordion opened the row went down and the plate lagged behind: now the row is measured every frame and four springs chase it, so it follows even while opening.
  • The highlighter stroke as the text's background broke on the glint and covered the letters: it is a separate element behind the letters, in multiply, with the glint as a second background layer.
  • The plate also got a scale from GSAP on the Enter press, but its transform is written by the spring loop every frame: the two cancelled each other. The row now does the press, the plate belongs to the springs only.
  • With a global regex, test called twice in a row skips matches because of lastIndex: the regex is made fresh for each document.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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