Skip to content
animorio
IT
All components

The workspace switcher menu

Menus, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 7.6 KBGSAP 28 KBFreeDownload the zip

In the style of product interfaces: the dropdown to switch workspace in a team app. The button shows the tile with the initials, the name and the plan; pressed, the panel opens on a short spring, a soft highlight slides under the row you point at and the check draws itself on the one you pick. Then the button changes name: a small spinner while it loads, the tile turning, the old name rising away and the new one coming in, with the width stretching or shrinking.

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>
<!--
  "The workspace switcher menu" 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 workspace switcher menu</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 workspace switcher of a team app. The button shows the workspace you are in, its tile with the initials
         and its plan. Pressed, a panel opens on a short spring; a soft highlight slides under the row you point at,
         the check draws itself on the one you choose, and the button changes name with its width animated -->
    <div class="switcher" data-frame>
      <button class="trigger" type="button" aria-haspopup="listbox" aria-expanded="false" aria-controls="ws-list" data-trigger data-autoclic>
        <span class="trigger__press" data-press>
          <span class="tile" data-tile><span class="tile__letters" data-tile-letters>FS</span></span>
          <span class="trigger__text" data-text>
            <span class="trigger__line" data-line>
              <span class="trigger__name">Fernway Studio</span>
              <span class="trigger__plan">Pro plan</span>
            </span>
          </span>
          <span class="trigger__end">
          <svg class="trigger__spin" viewBox="0 0 16 16" aria-hidden="true" data-spin><circle cx="8" cy="8" r="5.6" class="spin__track"/><path d="M8 2.4a5.6 5.6 0 0 1 5.6 5.6" class="spin__arc"/></svg>
          <svg class="trigger__chev" viewBox="0 0 16 16" aria-hidden="true" data-chev>
            <path d="M5 6.2 8 3.4l3 2.8" data-chev-up/>
            <path d="M5 9.8 8 12.6l3-2.8" data-chev-down/>
          </svg>
          </span>
        </span>
      </button>

      <div class="panel" data-panel hidden>
        <div class="panel__head">
          <span class="panel__label">Workspaces</span>
          <span class="panel__mail">ines@fernway.studio</span>
        </div>
        <div class="panel__list-wrap">
          <span class="hl" aria-hidden="true" data-hl></span>
          <ul class="panel__list" id="ws-list" role="listbox" aria-label="Workspaces" tabindex="-1" data-list>
            <li class="opt" role="option" aria-selected="true" id="ws-fernway" data-opt data-name="Fernway Studio" data-plan="Pro plan" data-letters="FS" data-hue="0">
              <span class="tile tile--hue0"><span class="tile__letters">FS</span></span>
              <span class="opt__text"><span class="opt__name">Fernway Studio</span><span class="opt__meta"><span class="badge badge--pro">Pro</span>12 members</span></span>
              <svg class="check" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.6 8.4 6.6 11.2 12.4 4.9" data-check/></svg>
            </li>
            <li class="opt" role="option" aria-selected="false" id="ws-quillmark" data-opt data-name="Quillmark" data-plan="Pro plan" data-letters="Q" data-hue="1">
              <span class="tile tile--hue1"><span class="tile__letters">Q</span></span>
              <span class="opt__text"><span class="opt__name">Quillmark</span><span class="opt__meta"><span class="badge badge--pro">Pro</span>28 members</span></span>
              <svg class="check" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.6 8.4 6.6 11.2 12.4 4.9" data-check/></svg>
            </li>
            <li class="opt" role="option" aria-selected="false" id="ws-orbit" data-opt data-name="Orbit Labs" data-plan="Free plan" data-letters="OL" data-hue="2">
              <span class="tile tile--hue2"><span class="tile__letters">OL</span></span>
              <span class="opt__text"><span class="opt__name">Orbit Labs</span><span class="opt__meta"><span class="badge">Free</span>3 members</span></span>
              <svg class="check" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.6 8.4 6.6 11.2 12.4 4.9" data-check/></svg>
            </li>
            <li class="opt" role="option" aria-selected="false" id="ws-personal" data-opt data-name="Personal" data-plan="Free plan" data-letters="IM" data-hue="3">
              <span class="tile tile--hue3"><span class="tile__letters">IM</span></span>
              <span class="opt__text"><span class="opt__name">Personal</span><span class="opt__meta"><span class="badge">Free</span>Only you</span></span>
              <svg class="check" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.6 8.4 6.6 11.2 12.4 4.9" data-check/></svg>
            </li>
            <li class="opt opt--create" role="option" aria-selected="false" id="ws-create" data-opt data-create>
              <span class="plus" aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M8 3.5v9M3.5 8h9"/></svg></span>
              <span class="opt__text"><span class="opt__name">Create workspace</span></span>
              <span class="keys" aria-hidden="true"><kbd>Ctrl</kbd><kbd>N</kbd></span>
            </li>
          </ul>
        </div>
      </div>

      <!-- the preview's pointer, only while the tour runs -->
      <svg class="ghost" viewBox="0 0 20 24" aria-hidden="true" data-ghost>
        <path d="M3 2.5v16.2l4.2-3.9 2.7 6.1 2.9-1.3-2.7-6h5.9z"/>
      </svg>
      <p class="sr" aria-live="polite" data-live></p>
    </div>
  </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.

48 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 “The workspace switcher menu” 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 there is a button with rounded corners and a thin border: on the left a soft violet tile with the initials FS, then Fernway Studio with Pro plan in grey beneath, and on the right two small drawn arrows, one up and one down. A pointer comes in and presses the button, which sinks a pixel, and the panel opens below: it grows from the top centre on a short spring, goes a touch too far and settles, and the rows arrive one after the other. At the top Workspaces and the address of whoever is signed in; then four workspaces, each with its coloured tile, its name, a Pro or Free label and how many members it has: Fernway Studio with the indigo check, Quillmark, Orbit Labs and Personal; under a hairline, Create workspace with a dashed plus and the Ctrl N keys. The pointer goes down and a very light grey highlight slides under the row it points at, stretching a little on the way. On Quillmark it stops and presses: Fernway's check is erased and Quillmark's is drawn, the panel closes, and in the button the two arrows give way to a small spinning indigo ring, the name dims, the tile turns on itself and comes back orange with the Q, the old name rises away and Quillmark comes up from below while the button narrows to its new width, then settles by a pixel and the arrows come back.

How it works

A panel on a short spring

The panel opens with a single GSAP tween on opacity, a scale from 0.94 and 6 pixels of movement, with back.out (OPEN_BOUNCE): it goes a touch too far and settles, like the stiff springs of today's apps. The transform origin is the top centre, under the button, and the rows arrive STAGGER seconds apart.

A highlight that slides under the rows

The highlight of the row you point at is one element under the list, moved by GSAP with a y and a height measured from the row (offsetTop, offsetHeight). On the way it stretches a little vertically, more if it jumps more rows, and goes back to its height as it lands; when the pointer leaves the list it fades, and when it comes back it appears straight under the row, with no journey.

A check that draws itself

Each row has its SVG check with a stroke-dasharray of 14: the chosen one goes from 14 to 0 and is drawn, the old one goes from 0 to -14 and is erased in the direction it was drawn, then gets ready again.

The name changes with FLIP

The button measures the width of the old name, adds the new line to the flow and measures it, then fixes the old width and takes it to the new one in WIDTH_TIME seconds: the button stretches or shrinks by itself. Meanwhile the old name rises with yPercent -100, the new one comes in from 100 with a small back.out, and the tile turns on its vertical axis and changes colour and initials when it is edge on.

The loading state

For SWITCH_WAIT seconds the switch shows it is in progress: the arrows shrink and a small indigo ring spins in their place, the name dims halfway. At the end the button drops a pixel and comes back, and the arrows return with a bounce.

Keys and accessibility

The button has aria-haspopup and aria-expanded, the list is a listbox with aria-activedescendant and aria-selected. Arrow down opens, the arrows move the highlight, Home and End go to the ends, Enter chooses, Esc and Tab close and bring the focus back to the button, Ctrl N picks Create workspace; a click outside closes. The preview's click (detail 0) makes a tour with the fake pointer.

Values to change

NameFileDefaultWhat it changes
OPEN_TIMEscript.js0.34The seconds the panel takes to open.
OPEN_BOUNCEscript.js1.25How far the panel overshoots before it settles (1, not at all).
SLIDE_TIMEscript.js0.26The seconds of the highlight sliding from one row to the next.
WIDTH_TIMEscript.js0.42The seconds of the button stretching or shrinking to the new name.
STAGGERscript.js0.025The seconds between one row and the next as the panel opens.
SWITCH_WAITscript.js0.55How long the loading lasts before the new name lands.

Try them in the Playground

When to use it

In the sidebar or header of a team app, a SaaS tool or a dashboard with several workspaces, organisations, projects or stores. It suits three, four or five rows; longer lists need a search at the top.

On phones

The menu is at most as wide as the screen less 32 pixels and the panel sits under the button inside the frame; below 340 pixels the address at the top is left out. On touch the highlight goes under the row you tap and picks it.

With reduced motion

No springs and no movement: the panel fades in, the highlight jumps from row to row, the check is in place at once and the new name replaces the old one in a fade, already at the right width.

Pitfalls

  • The button told a keyboard click from the preview's click by how long it had been since the last key, starting from zero: in the first half second of the page every click looked like a keyboard one and the fake pointer's tour did not start. The last key now starts far back in the past.
  • To measure the new name's width the new line must be in the flow and the old one out of it (position absolute) before measuring; then the width is fixed to the old one and only then animated, otherwise the button jumps to the new size for a frame.
  • Moving the focus back to the button after a preview click (with no real pointer) lit the focus ring as if by keyboard: in the tour the menu closes without moving the focus.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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