Skip to content
animorio
IT
Back to the library

Search bar transition

TransitionsGSAPMediumCompressed weight: Demo 12 KBGSAP 28 KBFreeDownload the zip

The transition between two screens of a mobile app, inside a phone on a dark page with two glows: the home of an app for booking stays, with real photos of the places, and its search screen. The search bar is the shared element: tapped, it gives under the finger, then rises to the top and narrows into the search field on a spring that passes the mark by a pixel, while the home sinks back a little under frosted glass, Cancel slides in from the side, the recent searches arrive one after the other and the keyboard comes up. Typing, every key pops up over the finger and the places are filtered letter by letter; once a place is chosen, the field flies back home carrying it, with a thin ring of the accent colour.

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>
<!--
  "Search bar transition" 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 transition from the search bar to the search screen</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>
    <span class="glow glow--warm" data-glow aria-hidden="true"></span>
    <span class="glow glow--cool" data-glow aria-hidden="true"></span>

    <!-- a phone with the home of Nookbay, an app for stays. Tapping the search bar, the bar itself is the shared
         element: it rises to the top and narrows into the search field, the home sinks back under frosted glass,
         Cancel slides in, the recent searches arrive one after the other and the keyboard comes up. Typing filters
         the places; choosing one, the field flies back home carrying it -->
    <div class="holder" data-holder>
      <span class="floor" aria-hidden="true"></span>
      <div class="device" data-device>
        <span class="device__key device__key--a" aria-hidden="true"></span>
        <span class="device__key device__key--b" aria-hidden="true"></span>
        <span class="device__key device__key--c" aria-hidden="true"></span>
        <div class="screen" data-screen>

          <!-- the home screen -->
          <section class="home" data-home>
            <p class="home__hello">Good evening, Mara</p>
            <h1 class="home__title">Where next?</h1>
            <span class="home__avatar" aria-hidden="true">MA</span>

            <div class="chips" data-chips>
              <span class="chip chip--on">All stays</span>
              <span class="chip">Cabins</span>
              <span class="chip">Coast</span>
              <span class="chip">City</span>
              <span class="chip">Desert</span>
            </div>

            <article class="stay" data-stay>
              <span class="stay__photo stay__photo--castelo" aria-hidden="true"></span>
              <span class="stay__rating">
                <svg viewBox="0 0 12 12" aria-hidden="true"><path d="M6 1.2l1.45 2.95 3.25.47-2.35 2.3.55 3.23L6 8.62 3.1 10.15l.55-3.23-2.35-2.3 3.25-.47z"/></svg>
                4.92
              </span>
              <span class="stay__save" aria-hidden="true">
                <svg viewBox="0 0 16 16"><path d="M8 13.4S2.2 10 2.2 6.1A2.9 2.9 0 0 1 8 4.6a2.9 2.9 0 0 1 5.8 1.5C13.8 10 8 13.4 8 13.4z"/></svg>
              </span>
              <span class="stay__info">
                <span class="stay__name">Casa Castelo</span>
                <span class="stay__where">Lisbon, 3 nights</span>
                <span class="stay__price">&euro;142<small>night</small></span>
              </span>
            </article>

            <article class="stay stay--small">
              <span class="stay__photo stay__photo--fjord" aria-hidden="true"></span>
            </article>

            <nav class="tabs" aria-label="App sections">
              <svg class="tabs__icon tabs__icon--on" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 10.5L12 4l8 6.5V19a1 1 0 0 1-1 1h-4.5v-5.5h-5V20H5a1 1 0 0 1-1-1z"/></svg>
              <svg class="tabs__icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="6"/><path d="M15.5 15.5L20 20"/></svg>
              <svg class="tabs__icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19.5S4.5 15 4.5 9.6A3.9 3.9 0 0 1 12 7.6a3.9 3.9 0 0 1 7.5 2C19.5 15 12 19.5 12 19.5z"/></svg>
              <svg class="tabs__icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="9" r="3.6"/><path d="M5 20c1.2-3.6 4-5 7-5s5.8 1.4 7 5"/></svg>
            </nav>
          </section>

          <!-- the search screen: frosted glass over the home -->
          <section class="sheet" data-sheet aria-label="Search">
            <button class="cancel" type="button" data-cancel>Cancel</button>

            <div class="group" data-recent>
              <p class="group__label">Recent searches <span>Clear</span></p>
              <ul class="rows">
                <li class="row" data-row><span class="row__thumb row__thumb--kyoto"></span><span class="row__text"><b>Kyoto, Japan</b><small>Apr 3 to 9, 2 guests</small></span><svg class="row__go" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="5.4"/><path d="M8 5.2V8l1.9 1.3"/></svg></li>
                <li class="row" data-row><span class="row__thumb row__thumb--copen"></span><span class="row__text"><b>Copenhagen, Denmark</b><small>Any week, 2 guests</small></span><svg class="row__go" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="5.4"/><path d="M8 5.2V8l1.9 1.3"/></svg></li>
                <li class="row" data-row><span class="row__thumb row__thumb--porto"></span><span class="row__text"><b>Porto, Portugal</b><small>May 22 to 25, 1 guest</small></span><svg class="row__go" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="5.4"/><path d="M8 5.2V8l1.9 1.3"/></svg></li>
              </ul>
              <p class="group__label group__label--gap">Popular this week</p>
              <div class="tags">
                <span class="tag">Weekend nearby</span>
                <span class="tag">Under &euro;120</span>
                <span class="tag">With a pool</span>
                <span class="tag">Quiet</span>
              </div>
            </div>

            <div class="group group--results" data-results>
              <p class="group__label">Places</p>
              <ul class="rows" data-result-rows></ul>
            </div>

            <div class="keyboard" data-keyboard aria-hidden="true">
              <span class="keyboard__pop" data-pop></span>
            </div>
          </section>

          <!-- the shared element: the search bar of the home that becomes the field of the search screen -->
          <div class="pill" data-pill role="button" tabindex="0" aria-label="Search stays">
            <span class="pill__ring" data-ring aria-hidden="true"></span>
            <svg class="pill__icon" data-pill-icon viewBox="0 0 20 20" aria-hidden="true"><circle cx="9" cy="9" r="5.6"/><path d="M13.2 13.2l3.4 3.4"/></svg>
            <span class="pill__home" data-pill-home>
              <b data-pill-title>Where to?</b>
              <small data-pill-sub>Anywhere, any week, add guests</small>
            </span>
            <span class="pill__field" data-pill-field>
              <span class="pill__query" data-query></span><span class="pill__caret" data-caret></span><span class="pill__hint" data-hint>Search destinations</span>
            </span>
            <span class="pill__filter" data-filter aria-hidden="true">
              <svg viewBox="0 0 20 20"><path d="M3.5 6.5h7M14.5 6.5h2M3.5 13.5h2M9.5 13.5h7"/><circle cx="12.5" cy="6.5" r="2"/><circle cx="7.5" cy="13.5" r="2"/></svg>
            </span>
          </div>

          <div class="status" aria-hidden="true">
            <span class="status__time">9:41</span>
            <span class="status__island"></span>
            <svg class="status__icons" viewBox="0 0 52 12"><rect x="0" y="8" width="3" height="4" rx="1"/><rect x="5" y="6" width="3" height="6" rx="1"/><rect x="10" y="3.5" width="3" height="8.5" rx="1"/><rect x="15" y="1" width="3" height="11" rx="1"/><rect class="status__cell" x="26.5" y="1.5" width="21" height="9.5" rx="2.6"/><rect x="28.5" y="3.5" width="14" height="5.5" rx="1.4"/><rect x="48.6" y="4.4" width="1.6" height="3.6" rx=".8"/></svg>
          </div>
          <span class="indicator" aria-hidden="true"></span>
          <span class="glare" aria-hidden="true"></span>
        </div>
      </div>
    </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.

49 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 “Search bar transition” 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 near black page with an orange glow and a blue one drifting slowly there is a dark titanium phone, its edges catching the light. On the screen is the home of Nookbay, an invented app for booking stays: the greeting, the title ‘Where next?’, the white search bar ‘Where to?’ with its filter button, the category pills, the card of Casa Castelo in Lisbon with a real photo of the red roofs below the castle hill and the sun through the clouds, above a second card with a still fjord between the cliffs, the rating and the price on frosted glass, and the tab bar at the bottom. A finger taps the search bar: it gives a touch, then rises to the top and narrows into the field of the search screen, passing its mark by a pixel before it settles; its two lines fade out to the left, the filter button shrinks away and Cancel slides in where it was. Behind, the home gets a little smaller and stays under frosted glass; the recent searches, with their photo thumbnails (the golden pavilion in Kyoto, the coloured houses of Nyhavn in Copenhagen, the façades of Porto), and the picks of the week arrive one after the other, and the keyboard comes up from below. The caret blinks next to ‘Search destinations’. ‘Lis’ is typed: every key greys and its letter pops up over the finger, and at every letter the places are filtered, with the typed letters in bold (Lisbon, Lisbon Coast, Lismore). Lisbon is tapped: the row darkens under the finger, the keyboard goes down, the search screen fades away and the field flies back home turning into the bar again, now holding ‘Lisbon’ and the dates, while a thin orange ring closes around it and then fades. After a moment the bar goes back to ‘Where to?’ and the loop starts again. Everything works by hand: tap the bar, type on the keys (or a real keyboard), delete, pick a place or press Cancel.

How it works

A phone drawn at a fixed size

The phone is 308 by 628 design pixels and shrinks as a whole with a scale worked out on resize (the --s variable): so every position inside the screen is a fixed number and the bar's two shapes are written as two objects, at home and in search.

One element for two screens

The bar is not copied: it is the same element, on a layer above the home and above the search screen. GSAP takes its position, width, height and radius from one shape to the other with back.out, passing the mark by a pixel; inside, the home's two lines and the field with its caret cross fade, staggered.

The home sinking under the glass

While the bar flies, the home scales to 95% and the search screen, a layer with a blurred and saturated backdrop-filter, fades in: the home stays visible behind it, as with iOS sheets. Cancel, the recent rows and the picks come in with a 40 ms stagger, the keyboard rises on a short spring.

The keyboard and the results

The keys are built by the script, with their places in pixels; pressed, a key greys and a bubble with its letter pops up above it. At every letter the places are filtered by how their name starts, the typed part goes bold and the rows refresh with a small slide.

The way back and the walk on its own

Once a place is chosen, the same bar goes back to its home shape with the new words, swapped while they are hidden, and a ring of the accent colour closes around it. The walk on its own is a timeline that opens, types and chooses; the first touch stops it and it starts again after a few quiet seconds.

Real photos, as backgrounds

The card photos and the search thumbnails are five webp files in the demo folder, used as background-image with cover and a fallback colour underneath. On the big photo a dark shade at the top and bottom keeps the rating and the price on glass readable; Lisbon, picked in the results, reuses the card's own photo, framed on the castle.

Values to change

NameFileDefaultWhat it changes
SPEEDscript.js12 = the whole walk twice as fast, 0.5 = half.
OVERSHOOTscript.js1.2How far the bar passes its mark before it settles (0 = none).
RECEDEscript.js0.95How small the home gets behind the glass.
TYPE_RATEscript.js4.5Letters per second when it types by itself.
QUERYscript.js'Lis'What it types by itself.
HOLDscript.js1.8Seconds the home holds the chosen place before starting again.
LOOPscript.jstrueRepeats the search.

Try them in the Playground

When to use it

For the app or mobile site of a vacation rental platform, a hotel, a shop or a travel service: the moment the home's search bar opens into the search screen without a cut.

On phones

The same animation with adapted sizes: the phone shrinks as a whole to fit the window's height and width, and with a finger you tap the bar, type on the keys and pick the place.

With reduced motion

Nothing moves: the bar fades out and back in already in its new shape, the search screen, the keyboard and the rows fade in and out, and the ring fades on and off.

Pitfalls

  • The bar has to sit on a layer above the search screen, not inside the home: left in the home, it shrinks with the home and flies crooked.
  • The bar's new words (the chosen place) are swapped only while its two lines are hidden, otherwise the text jumps mid flight.
  • The walk on its own and the touches by hand use the same functions: the first touch stops the walk entirely, otherwise one of its later steps closes the search while you are typing.
  • The thumbnails are 36 pixels: a photo with lots of small things turns into a blur. They need photos with one shape and clear colours (the golden pavilion, the coloured façades), saved small so they weigh little.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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