Skip to content
animorio
IT
All components

Private account toggle

Toggles, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 8.1 KBGSAP 28 KBFreeDownload the zip

The privacy settings of an invented social app, on white, in the style of product interface pieces: switching Private account on slides the knob on a spring and closes the little lock it carries, while the preview of the profile as others see it blurs tile after tile under a frosted veil with a lock; below, the three follow requests come in. Switching it off brings everything back sharp in reverse.

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>
<!--
  "Private account toggle" 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 Private account toggle with the preview that blurs</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 privacy settings of a social app: switching Private account on slides the knob on a spring and closes the
         little lock it carries, while the preview of the profile, as others see it, blurs tile after tile under a
         frosted veil; switching it off brings everything back sharp in reverse; the follow requests come in below -->
    <section class="card" data-card aria-labelledby="pa-label">
      <header class="top">
        <svg class="top__back" viewBox="0 0 20 20" aria-hidden="true"><path d="M12 4.5 6.5 10l5.5 5.5"></path></svg>
        <span class="top__title">Privacy</span>
        <span class="brand">
          <svg class="brand__mark" viewBox="0 0 20 20" aria-hidden="true">
            <rect x="1" y="1" width="18" height="18" rx="6"></rect>
            <circle cx="7.6" cy="10" r="3.1"></circle>
            <circle cx="12.4" cy="10" r="3.1"></circle>
          </svg>
          <span class="brand__name">Murmur</span>
        </span>
      </header>

      <div class="row" data-row>
        <span class="row__ic" aria-hidden="true">
          <svg viewBox="0 0 24 24">
            <rect x="5" y="10.5" width="14" height="10" rx="3"></rect>
            <path class="row__shackle" data-rowshackle d="M8.4 10.5V8a3.6 3.6 0 0 1 7.2 0v2.5"></path>
            <path d="M12 14.6v2"></path>
          </svg>
        </span>
        <div class="row__text">
          <span class="row__name" id="pa-label">Private account</span>
          <span class="row__hint"><span data-hint>Anyone can see your posts</span></span>
        </div>
        <button class="sw" type="button" role="switch" aria-checked="false" aria-labelledby="pa-label" data-switch>
          <span class="sw__glow" data-glow aria-hidden="true"></span>
          <span class="sw__knob" data-knob>
            <svg class="sw__lock" viewBox="0 0 16 16" aria-hidden="true">
              <path class="sw__shackle" data-shackle d="M5.4 7.4V5.6a2.6 2.6 0 0 1 5.2 0v1.8"></path>
              <rect class="sw__body" data-lockbody x="3.8" y="7.2" width="8.4" height="6" rx="1.8"></rect>
            </svg>
          </span>
        </button>
      </div>

      <div class="preview" data-preview aria-label="How others see your profile">
        <span class="preview__label">How others see you</span>
        <div class="prof">
          <span class="avatar" aria-hidden="true"><span class="avatar__in">MO</span></span>
          <span class="prof__text">
            <span class="prof__name">Mira Okafor</span>
            <span class="prof__meta">@mira.okafor · 248 posts</span>
          </span>
          <span class="follow" data-follow aria-hidden="true"><span data-followtext>Follow</span></span>
        </div>
        <div class="grid" data-grid>
          <div class="tile" data-tile>
            <svg viewBox="0 0 100 100" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
              <defs>
                <linearGradient id="g-sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#ffd9c2"/><stop offset="1" stop-color="#ffb08a"/></linearGradient>
                <linearGradient id="g-hill" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#e2765a"/><stop offset="1" stop-color="#b9503f"/></linearGradient>
              </defs>
              <rect width="100" height="100" fill="url(#g-sky)"/>
              <circle cx="62" cy="46" r="16" fill="#fff4e6"/>
              <path d="M0 74c16-12 30-14 46-6s30 6 54-8v40H0Z" fill="url(#g-hill)"/>
              <path d="M0 86c22-8 40-8 58-2s28 2 42-2v18H0Z" fill="#8f3a30" opacity=".85"/>
            </svg>
          </div>
          <div class="tile" data-tile>
            <svg viewBox="0 0 100 100" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
              <defs>
                <linearGradient id="g-sage" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#dfe8dc"/><stop offset="1" stop-color="#b8ccb4"/></linearGradient>
              </defs>
              <rect width="100" height="100" fill="url(#g-sage)"/>
              <path d="M24 100V58a26 26 0 0 1 52 0v42Z" fill="#7f9c7a"/>
              <path d="M36 100V64a14 14 0 0 1 28 0v36Z" fill="#eef3ea"/>
              <path d="M50 16v18M41 25h18" stroke="#5d7b59" stroke-width="2.4" stroke-linecap="round"/>
            </svg>
          </div>
          <div class="tile" data-tile>
            <svg viewBox="0 0 100 100" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
              <defs>
                <linearGradient id="g-ind" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#3b3f8f"/><stop offset="1" stop-color="#1e2156"/></linearGradient>
              </defs>
              <rect width="100" height="100" fill="url(#g-ind)"/>
              <circle cx="38" cy="54" r="22" fill="#6c71e0" opacity=".9"/>
              <circle cx="62" cy="46" r="22" fill="#a9adff" opacity=".55"/>
              <circle cx="74" cy="24" r="4" fill="#ffd9c2"/>
            </svg>
          </div>
          <div class="veil" data-veil aria-hidden="true">
            <span class="veil__badge">
              <svg viewBox="0 0 24 24">
                <path class="veil__shackle" data-veilshackle d="M8.2 11V8.4a3.8 3.8 0 0 1 7.6 0V11"></path>
                <rect x="5.6" y="10.8" width="12.8" height="9.4" rx="2.8"></rect>
                <path d="M12 14.4v2.2"></path>
              </svg>
            </span>
            <span class="veil__title">This account is private</span>
            <span class="veil__sub">Only followers can see your posts</span>
          </div>
        </div>
      </div>

      <div class="req" data-req aria-live="polite">
        <div class="req__in">
          <span class="req__faces" aria-hidden="true">
            <span class="face" data-face style="--f:#ffb08a">JL</span>
            <span class="face" data-face style="--f:#9fb79a">AS</span>
            <span class="face" data-face style="--f:#8c90f0">TK</span>
          </span>
          <span class="req__text"><span class="req__count" data-count>3</span> follow requests</span>
          <svg class="req__go" viewBox="0 0 20 20" aria-hidden="true"><path d="M8 4.5 13.5 10 8 15.5"></path></svg>
        </div>
      </div>
    </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.

33 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 “Private account toggle” 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 the Privacy settings card of an invented social app, Murmur: the grey Private account row with the open lock icon and the switch, below it the «How others see you» preview with Mira Okafor’s profile (the initials avatar inside a gradient ring, posts and followers, the Follow button) and three post tiles made of shapes: a sunset over hills, an arch on a sage ground, two circles on an indigo ground. Switch on and the knob stretches and slides on a spring, the track turns purple with a short glow, and the little lock drawn on the knob drops its shackle and snaps shut, together with the one in the row; the line underneath rolls to «Only followers see your posts» and the preview’s button becomes Request. Then the three tiles, left to right, blur and sink slightly, one after another; over them comes a frosted veil with the round lock badge that shuts and rocks, «This account is private» and «Only followers can see your posts». Below, the purple requests row opens: three initials faces pop in one after another and the 3 count lands with a bounce, «3 follow requests». Switching off closes the requests, the veil’s lock opens again, the veil leaves and the tiles come back sharp right to left with a small settle; the knob slides back and the lock opens. A drawn pointer switches on, looks at the requests and switches off; it also works with the mouse, touch and the keyboard.

How it works

The knob on a spring

The knob has no transform in the CSS: GSAP stretches its width for 0.15 seconds as it leaves, then carries it to the end with an elastic.out whose spring is a knob of the Playground. The travel is measured from the switch’s width and recalculated on resize.

The lock that snaps shut

The lock is an SVG with a shackle and a body: open, the shackle is lifted two pixels and turned 22 degrees on its right leg (transformOrigin 100% 100%); closing brings it back to zero with a strong back.out, the knob squeezes by a tenth for the snap, and body and shackle take the accent colour.

The cascading blur

Every post tile has its own tween of filter blur and saturate with a slight scale, staggered by STAGGER seconds; switching off reverses the order and each tile comes back sharp with a small scale overshoot and an elastic settle.

The veil and the requests

The frosted veil arrives once the last tile is blurred: the round lock badge grows with a back.out, its shackle closes and the badge rocks by six degrees. The requests row opens with height auto, then the faces pop in with a stagger and the count lands last.

Values to change

NameFileDefaultWhat it changes
APPscript.jsMurmurThe social app’s name at the top right.
REQUESTSscript.js3How many follow requests come in below when the profile is private.
BLURscript.js9How much the post tiles in the preview blur, in pixels.
STAGGERscript.js0.11The delay between one tile blurring and the next, in seconds.
SPRINGscript.js0.55The knob’s spring: lower bounces more.
ACCENTscript.js#5b4cf5The colour of the switch when on, the lock and the requests.

Try them in the Playground

When to use it

For the settings of a social app, a community, a creative’s or photographer’s profile, a dating app or a members’ club: anywhere a switch changes who can see something and it helps to show the effect right away.

On phones

The card takes the width with a margin and the post tiles shrink with the grid; the gaps are sized on the height too with clamp and vmin, and below 460 pixels of height the top line and the preview label hide, so with the requests open everything fits in the box. A tap on the switch or on the row does the same as a click.

With reduced motion

No springs, rolls or cascade: the knob goes to its place, the lock closes, the tiles blur all together as a fade, the veil and the requests fade in. The fake pointer does not start.

Pitfalls

  • GSAP writes its own inline transform: the knob, the tiles and the veil have no transform in the CSS, they are placed with left, top and the grid.
  • The lock’s shackle has to turn on its right leg: with transformOrigin 100% 100% on the SVG element GSAP works out the point from the path’s box, not from the viewBox.
  • Switching on and off quickly makes the veil and requests timelines overlap: each one kills the previous one and starts from the current values, so no tile is left half blurred.
  • Waits go in gsap.delayedCall and not in setTimeout, so the site’s viewer can stop and restart everything.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 8.1 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 components