Skip to content
animorio
IT
All components

Terms accordion

Accordions, Transitions, HoverGSAP, CSS onlyMediumCompressed weight: Demo 7.2 KBGSAP 28 KBFreeDownload the zip

The terms page of Harbor, a made-up file sharing app, kept short: six sections in an accordion that open on a short spring, each with an «In plain words» summary on top and the smaller legal text below. Beside it a slim index with a marker that slides to the open section (a row of pills on the phone), «Updated» tags on the sections that changed and a «What changed» pill that sweeps a highlighter over the new lines.

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>
<!--
  "Terms accordion" 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>Terms 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 terms page of a made-up file sharing app: six sections as an accordion with a plain-words summary on top,
         a slim index beside it (pills on the phone) and a «What changed» switch that marks the lines updated last time -->
    <article class="terms" data-terms aria-labelledby="titolo">
      <header class="terms__head">
        <div class="brand" aria-hidden="true">
          <svg viewBox="0 0 24 24"><path d="M4 15.5c2.2 0 2.2-1.6 4.4-1.6s2.2 1.6 4.4 1.6 2.2-1.6 4.4-1.6 2.2 1.6 2.8 1.6"/><path d="M12 4v8.2M8.6 7.6 12 4l3.4 3.6"/><path d="M4 19.5c2.2 0 2.2-1.6 4.4-1.6s2.2 1.6 4.4 1.6 2.2-1.6 4.4-1.6 2.2 1.6 2.8 1.6" class="brand__soft"/></svg>
          <span>Harbor</span>
        </div>
        <h1 class="terms__title" id="titolo">Terms of Service</h1>
        <div class="terms__meta">
          <span class="terms__date">Last updated 3 Nov 2026</span>
          <button class="changes" type="button" aria-pressed="false" data-changes>
            <span class="changes__face" data-changes-face>
              <span class="changes__label">What changed</span>
              <span class="changes__count" data-count>3</span>
            </span>
          </button>
        </div>
      </header>

      <div class="terms__body">
        <!-- the index: a column beside the accordion on a wide screen, a row of pills on the phone -->
        <nav class="index" aria-label="Sections" data-index>
          <span class="index__marker" data-marker aria-hidden="true"></span>
          <button class="index__item" type="button" data-go="0">Your account</button>
          <button class="index__item" type="button" data-go="1">Payments</button>
          <button class="index__item" type="button" data-go="2">Content you share</button>
          <button class="index__item" type="button" data-go="3">Cancellation</button>
          <button class="index__item" type="button" data-go="4">Privacy</button>
          <button class="index__item" type="button" data-go="5">Liability</button>
        </nav>

        <div class="list" data-list>
          <section class="sec" data-sec>
            <h2 class="sec__h"><button class="sec__btn" type="button" id="h0" aria-expanded="false" aria-controls="p0" data-head>
              <span class="sec__name">Your account</span>
              <svg class="sec__chev" viewBox="0 0 16 16" aria-hidden="true" data-chev><path d="M4 6.2 8 10l4-3.8"/></svg>
            </button></h2>
            <div class="sec__panel" id="p0" role="region" aria-labelledby="h0" data-panel>
              <div class="sec__inner">
                <p class="plain" data-line><span class="plain__k">In plain words</span>You need to be 16 or older, and keeping your password safe is up to you.</p>
                <p class="legal" data-line>You must provide accurate information when creating an account and keep your credentials confidential. You are responsible for all activity that happens under your account.</p>
              </div>
            </div>
          </section>

          <section class="sec" data-sec data-updated>
            <h2 class="sec__h"><button class="sec__btn" type="button" id="h1" aria-expanded="false" aria-controls="p1" data-head>
              <span class="sec__name">Payments</span>
              <span class="tag" data-tag>Updated</span>
              <svg class="sec__chev" viewBox="0 0 16 16" aria-hidden="true" data-chev><path d="M4 6.2 8 10l4-3.8"/></svg>
            </button></h2>
            <div class="sec__panel" id="p1" role="region" aria-labelledby="h1" data-panel>
              <div class="sec__inner">
                <p class="plain" data-line><span class="plain__k">In plain words</span>Plans renew every month. We email you a week before any price change.</p>
                <p class="legal" data-line>Fees are billed in advance, monthly or yearly, and are not refundable except where the law requires it. <mark class="mark" data-mark>We will tell you at least seven days before a new price takes effect.</mark></p>
              </div>
            </div>
          </section>

          <section class="sec" data-sec data-updated>
            <h2 class="sec__h"><button class="sec__btn" type="button" id="h2" aria-expanded="false" aria-controls="p2" data-head>
              <span class="sec__name">Content you share</span>
              <span class="tag" data-tag>Updated</span>
              <svg class="sec__chev" viewBox="0 0 16 16" aria-hidden="true" data-chev><path d="M4 6.2 8 10l4-3.8"/></svg>
            </button></h2>
            <div class="sec__panel" id="p2" role="region" aria-labelledby="h2" data-panel>
              <div class="sec__inner">
                <p class="plain" data-line><span class="plain__k">In plain words</span>Your files stay yours. We only use them to run Harbor for you.</p>
                <p class="legal" data-line>You keep all rights to what you upload and give Harbor a limited licence to store, copy and show it only to provide the service. <mark class="mark" data-mark>We never use your files to train machine learning models.</mark></p>
              </div>
            </div>
          </section>

          <section class="sec" data-sec data-updated>
            <h2 class="sec__h"><button class="sec__btn" type="button" id="h3" aria-expanded="false" aria-controls="p3" data-head>
              <span class="sec__name">Cancellation</span>
              <span class="tag" data-tag>Updated</span>
              <svg class="sec__chev" viewBox="0 0 16 16" aria-hidden="true" data-chev><path d="M4 6.2 8 10l4-3.8"/></svg>
            </button></h2>
            <div class="sec__panel" id="p3" role="region" aria-labelledby="h3" data-panel>
              <div class="sec__inner">
                <p class="plain" data-line><span class="plain__k">In plain words</span>Cancel anytime in Settings. Your files stay downloadable for 30 days.</p>
                <p class="legal" data-line>You may cancel your subscription at any time. <mark class="mark" data-mark>After cancelling, your content stays available for export for 30 days, then it is permanently deleted.</mark></p>
              </div>
            </div>
          </section>

          <section class="sec" data-sec>
            <h2 class="sec__h"><button class="sec__btn" type="button" id="h4" aria-expanded="false" aria-controls="p4" data-head>
              <span class="sec__name">Privacy</span>
              <svg class="sec__chev" viewBox="0 0 16 16" aria-hidden="true" data-chev><path d="M4 6.2 8 10l4-3.8"/></svg>
            </button></h2>
            <div class="sec__panel" id="p4" role="region" aria-labelledby="h4" data-panel>
              <div class="sec__inner">
                <p class="plain" data-line><span class="plain__k">In plain words</span>We never sell your data. The Privacy Policy has every detail.</p>
                <p class="legal" data-line>How we collect and use personal information is described in our Privacy Policy, which is part of these Terms.</p>
              </div>
            </div>
          </section>

          <section class="sec" data-sec>
            <h2 class="sec__h"><button class="sec__btn" type="button" id="h5" aria-expanded="false" aria-controls="p5" data-head>
              <span class="sec__name">Liability</span>
              <svg class="sec__chev" viewBox="0 0 16 16" aria-hidden="true" data-chev><path d="M4 6.2 8 10l4-3.8"/></svg>
            </button></h2>
            <div class="sec__panel" id="p5" role="region" aria-labelledby="h5" data-panel>
              <div class="sec__inner">
                <p class="plain" data-line><span class="plain__k">In plain words</span>If something goes wrong, we owe you at most what you paid us in the last year.</p>
                <p class="legal" data-line>To the fullest extent the law allows, Harbor’s total liability will not exceed the amounts you paid in the twelve months before the claim.</p>
              </div>
            </div>
          </section>
        </div>
      </div>
    </article>
  </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.

60 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Terms accordion” 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

A white card with the Harbor mark, «Terms of Service», «Last updated 3 Nov 2026» and a «What changed» pill with the number 3. Below, on the left, the index of the six sections and, on the right, the six accordion headers. Tap a header and the section opens with its height on a short spring, the arrow turns half a turn on its centre and inside the summary in a soft box and the legal text come in on staggered lines; another open one closes. In the index a soft marker with a green bar slides to the open section on a spring. With «What changed» on, the «Updated» tags turn green and a highlighter sweeps from the left over the changed lines of the open sections. The up and down arrows move between headers, Home and End jump to the ends, Enter opens. When nobody touches the page a tour opens a few sections, switches the changes on and closes everything again.

How it works

Height on a spring

The panel has zero height and hidden overflow: the inner content is measured and the height goes there with a short elastic.out(1, 0.82); at the end it becomes auto, so a window resize never clips it.

The arrow on its centre

The arrow is a small whole svg turning 180 degrees with transformOrigin «50% 50%» and back.out: never svgOrigin on the svg itself, which would move the pivot.

The index marker

A single element behind the items takes the position and size of the open one (offsetLeft, offsetTop, width and height) and slides there with back.out; on the phone it is the pill background, and the row scrolls to keep it in view.

The highlighter

The changed lines are a mark with a solid gradient as background: GSAP takes background-size from 0% to 100%, so the colour sweeps from the left even across wrapped lines (box-decoration-break: clone).

Values to change

NameFileDefaultWhat it changes
OPENscript.js0.62Seconds a section takes to open on its spring.
SPRINGscript.js0.82How firm the opening spring is: lower bounces more.
CLOSEscript.js0.34Seconds a section takes to close.
LINES_STAGGERscript.js0.07Seconds between the lines coming into an open section.
CHEVRON_TURNscript.js180Degrees the arrow turns when its section opens.
MARKERscript.js0.6Seconds the index marker takes to slide to the open section.
MULTIscript.jsfalseWhen true, several sections stay open together.
PRESSscript.js0.985How much a header sinks when pressed.

Try them in the Playground

When to use it

On the terms, privacy or FAQ page of an app or a subscription service: people find the section they want straight away, read the plain version first and see what changed since last time.

On phones

Below 620 pixels the index becomes a row of pills scrolling above the accordion, moving by itself to keep the open pill in view; the card is at most as tall as the screen and the list scrolls inside it.

With reduced motion

No springs or rising lines: sections open at once with the text fading in, the arrow turns without motion, the index marker and the highlighter appear without sliding.

Pitfalls

  • A height animated to a number has to go back to auto when the opening ends, or on resize text that wraps differently gets clipped.
  • The turning arrow is the whole svg: transformOrigin «50% 50%», not svgOrigin.
  • The index marker lives inside the row that scrolls on the phone: offsetLeft and offsetTop are already relative to it, getBoundingClientRect is not.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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