Skip to content
animorio
IT
All components

Auto-height tabs

Tabs, Transitions, HoverGSAP, CSS onlyEasyCompressed weight: Demo 5.5 KBGSAP 28 KBFreeDownload the zip

The tabs of a workspace, Overview, Usage and Members, over a single panel, clean on white: choosing one, the panel takes the height of the new page on a short spring, goes a pixel and a half too far and settles, while the old page leaves blurred and the new one comes in from its side. The line under the tab slides and lands a pixel past, and every page arrives with its own small gesture: the usage bars filling up, the team’s faces falling into line.

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>
<!--
  "Auto-height tabs" 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 tabs with the panel that fits its content</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">
    <!-- three tabs over one panel: choosing a tab, the panel springs to the height of the new page
         (a pixel too far, then back) while the old page leaves blurred and the new one comes in from its side -->
    <div class="slot" data-slot>
    <section class="card" data-card aria-label="Workspace">
      <div class="tabs" role="tablist" aria-label="Workspace" data-tabs>
        <span class="tabs__hover" data-hover aria-hidden="true"></span>
        <button class="tab" type="button" role="tab" id="tab-overview" aria-controls="pane-overview" aria-selected="true" tabindex="0" data-tab="0"><span>Overview</span></button>
        <button class="tab" type="button" role="tab" id="tab-usage" aria-controls="pane-usage" aria-selected="false" tabindex="-1" data-tab="1"><span>Usage</span></button>
        <button class="tab" type="button" role="tab" id="tab-members" aria-controls="pane-members" aria-selected="false" tabindex="-1" data-tab="2"><span>Members</span></button>
        <span class="tabs__line" data-line aria-hidden="true"></span>
      </div>

      <div class="panel" data-panel>
        <div class="pane" role="tabpanel" id="pane-overview" aria-labelledby="tab-overview" data-pane="0">
          <div class="row">
            <p class="plan">Pro plan</p>
            <span class="badge" data-pop>Active</span>
          </div>
          <p class="muted">Renews on Nov 14 &middot; $24 per month</p>
        </div>

        <div class="pane" role="tabpanel" id="pane-usage" aria-labelledby="tab-usage" data-pane="1">
          <div class="meter">
            <div class="row"><p>Requests</p><p class="muted">182k of 250k</p></div>
            <div class="meter__track"><span class="meter__fill" data-fill="0.73"></span></div>
          </div>
          <div class="meter">
            <div class="row"><p>Storage</p><p class="muted">6.4 of 10 GB</p></div>
            <div class="meter__track"><span class="meter__fill" data-fill="0.64"></span></div>
          </div>
          <div class="meter">
            <div class="row"><p>Bandwidth</p><p class="muted">41 of 100 GB</p></div>
            <div class="meter__track"><span class="meter__fill" data-fill="0.41"></span></div>
          </div>
          <p class="muted small">Resets on Nov 1</p>
        </div>

        <div class="pane" role="tabpanel" id="pane-members" aria-labelledby="tab-members" data-pane="2">
          <div class="faces" aria-label="7 members">
            <span class="face" data-face>AK</span>
            <span class="face" data-face>MR</span>
            <span class="face" data-face>JL</span>
            <span class="face" data-face>SO</span>
            <span class="face face--more" data-face>+3</span>
          </div>
          <p class="muted">7 members &middot; 2 invites pending</p>
        </div>
      </div>
    </section>
    </div>

    <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.

35 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 “Auto-height tabs” 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, alone in the middle, there is a panel with three tabs at the top, Overview, Usage and Members, and a thin black line under the chosen one. Overview is short: the Pro plan with its Active label and the renewal date. Usage is tall: three meters, Requests, Storage and Bandwidth, each with its blue bar. Members is in between: the team’s faces with their initials, overlapping, and how many invites are pending. Choosing a tab, the panel grows or shrinks to the height of the new page on a short spring: it goes a pixel and a half too far and comes back. Meanwhile the old page slides away to the opposite side and blurs, and the new one comes in from the side of the chosen tab, into focus. The line under the tabs slides over and lands a pixel past before settling, and the chosen name takes weight. Every page arrives with its own gesture: the usage bars fill one after the other, the faces come in a row with a small bounce, the Active label swells a little. Hovering a tab shows a light grey background that follows from tab to tab; pressing, the name gives for a moment. Until someone touches them, a drawn pointer tries the tabs by itself.

How it works

The pages stacked

The three pages all sit at the top of the panel, absolutely positioned: that way they can be measured even when hidden (visibility hidden and inert, not display none) and the old and new can overlap during the change.

The height on a short spring

The panel has a height in pixels, taken from the offsetHeight of the chosen page. On change it goes to the new one plus OVERSHOOT in the direction of travel with power3.out, then back to exact with sine.inOut: that is the pixel too far, the same every time, with no spring wobbling at random.

One page leaves, the other enters

The old one moves SHIFT pixels to the opposite side, fades and blurs with a filter blur; the new one starts 100 milliseconds later from the side of the chosen tab and arrives in focus. The direction comes from the order of the tabs, so the pages seem to sit in a row.

The line and the weight

The line under the tab is a single span: GSAP changes its x and width to the new word plus one pixel, then brings it back. The chosen name goes from 500 to 620 on Mona Sans’s weight axis, through an animated CSS variable.

Each page’s small gesture

Each page does its own thing when it arrives: the usage bars grow from scaleX 0 to their value (written in data-fill), the faces come in from the left with back.out one after the other, the Active label swells from 0.9.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#3b5bdbThe colour of the usage bars and of the Active label.
SPEEDscript.js1The speed of everything: 2 twice as fast, 0.5 half.
OVERSHOOTscript.js1.5How many pixels the panel goes past its new height before settling.
SHIFTscript.js12How many pixels the new page travels in from its side.
BLURscript.js4How much the leaving page blurs, in pixels.
PAUSEscript.js1.8The seconds on each tab when the pointer tries them by itself.
AUTOscript.jstrueThe drawn pointer tries the tabs by itself until someone touches them.

Try them in the Playground

When to use it

For the tabs of a dashboard, of account settings or of a product page, when the pages have different lengths: the panel does not jump, it adapts, and the page below does not lurch.

On phones

On the phone the panel takes almost the whole width and the tabs stay on one row; there is no grey hover background, everything else is the same.

With reduced motion

The panel takes its new height at once, the pages and the line swap with a fade, with no movement or blur; the bars are already full.

Pitfalls

  • With display none the hidden pages cannot be measured (offsetHeight gives zero): they stay on the page with visibility hidden and inert, so Tab cannot reach them but they keep their height.
  • The filter blur has to be cleared at the end (clearProps): left at 0px it keeps the page on its own layer and the text looks a touch softer.
  • On resize, and when the font arrives, the height and the line have to be measured again: with a fallback font the words are wider and the line would stay short.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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