Skip to content
animorio
IT
All components

Token filter search

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

The mail search of Larkmail, on white, in the style of real product interface pieces: typing from: or is: opens a small menu of suggestions, and the pick folds the typed text into a token that grows with a spring. Below, the messages that do not fit close up, the ones left close ranks with a small settle and the results count rolls.

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>
<!--
  "Token filter 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 search with filters that turn into tokens as you type</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 search of a mail app: typing from: or is: opens a small menu, the pick folds the typed text into a token,
         the list below filters itself while the count rolls -->
    <section class="box" data-card aria-label="Larkmail search">
      <header class="box__head">
        <svg class="box__mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M3.5 8.5 12 14l8.5-5.5"></path><rect x="3.5" y="5.5" width="17" height="13" rx="2.5"></rect></svg>
        <p class="box__brand">Larkmail <span>/ Inbox</span></p>
        <p class="box__count" aria-live="polite"><span class="roll" data-count><span class="roll__in">6</span></span> <span data-count-word>results</span></p>
      </header>

      <div class="search" data-search>
        <svg class="search__lens" viewBox="0 0 24 24" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6"></circle><path d="m15 15 4.5 4.5"></path></svg>
        <div class="search__line" data-line>
          <input class="search__input" data-input type="text" autocomplete="off" spellcheck="false" placeholder="Search, or try from: and is:" aria-label="Search mail">
        </div>
        <span class="search__measure" data-measure aria-hidden="true"></span>
        <div class="menu" data-menu role="listbox" aria-label="Suggestions"></div>
      </div>

      <ul class="list" data-list></ul>
      <p class="empty" data-empty>No messages match these filters.</p>
    </section>
    <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 “Token filter 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 a very light grey background sits the card of Larkmail, an invented inbox: the mark, «Inbox» and on the right the results count. Below, the grey search field, which lights up with a blue border as soon as you touch it, and six messages from Nora Vey, Theo Park and Ines Ruiz, with the unread ones in bold, drawn stars and the time. Typing «from:» opens a menu of people that narrows as you type and marks the found letters in blue; typing «is:» offers unread and starred. On the pick (click, finger or Enter) the typed text folds into a blue token, «from Nora Vey», which starts as wide as the typed letters and grows past its size before settling, while the caret moves on right after it. Words without a colon search the subject and highlight it. The messages that do not fit close up sliding left, the ones left close ranks and settle by a pixel, and the number of results rolls up or down. A token’s x closes it and the tokens after it slide into place; Backspace on an empty field removes the last one too. A drawn pointer does it all by itself, then starts again.

How it works

A real field

The field is a real input in a flexible row: the tokens are spans placed before the input, so the caret always starts again after the last token and keyboard, paste and screen readers work as in any field.

The prefix opens the menu

On every letter a rule looks for from: or is: at the start of the text; if it is there, the menu is rebuilt with the items containing what follows the colon, and the found letters go into a blue mark.

Typed text that becomes a token

Before the field is emptied a hidden span measures how wide the typed text was: the new token starts from that width and reaches its own with back.out, while the input, pushed right, comes back with the same spring.

Rows that leave

Each row remembers whether it is visible: the leaving ones go to zero height sliding 10 pixels, the returning ones start from zero and reach the measured height, and the ones that stay settle by two pixels once the others are done.

The rolling count

The number sits in a window one line tall: the new one comes in from above or below depending on whether the results grow or shrink, the old one leaves the other way, and the number does a small elastic bounce.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#3b5bfdThe colour of the focused field, the tokens and the found letters.
TYPE_SPEEDscript.js0.09The seconds between letters when the autopilot types.
SPRINGscript.js1.8How far the token goes past its size before settling (0 = no spring).
ROW_TIMEscript.js0.38The seconds a result row takes to close or open again.
PAUSEscript.js1.1The seconds the autopilot waits between gestures.

Try them in the Playground

When to use it

For the search of an inbox, a project tracker or a dashboard with many items, wherever filters should be typed without leaving the keyboard.

On phones

The card takes the full width minus the margins; below 380 pixels the time of the messages disappears and the star stays, and when the window is short the rows drop to 38 pixels. A tap picks from the menu like a click.

With reduced motion

No springs and no sliding: the menu, the tokens and the rows appear and disappear with short fades, the count changes without rolling and the drawn pointer is hidden.

Pitfalls

  • Returning rows must go to the measured height, not to auto: GSAP does not animate well towards auto if another row changes meanwhile, and the height is measured again on resize.
  • The menu closes on the field’s blur: to pick an item with a click, pointerdown needs preventDefault, otherwise the field loses focus and the menu disappears before the click.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 27 October 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