Skip to content
animorio
IT
All components

Log out button

Buttons, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 5.1 KBGSAP 28 KBFreeDownload the zip

The button that signs you out of an account, asking first without opening a dialog. Pressed, the pill splits in two: “Stay” on the left and “Log out” in red on the right. Choose to leave and the avatar crosses the pill and goes through the door; what remains is a quiet “Sign in” with the arrow turned round.

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>
<!--
  "Log out button" 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>Log out button</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">
    <!-- a Log out button that asks before it acts: the pill splits in two, Stay and Log out;
         on Log out the avatar leaves through the door and what remains is a quiet Sign in -->
    <div class="lo" data-lo role="group" aria-label="Account">
      <button class="lo__a" type="button" data-a>
        <span class="lo__avatar" data-avatar aria-hidden="true">NK</span>
        <span class="lo__roll"><span data-alabel>Log out</span></span>
      </button>
      <button class="lo__b" type="button" data-b tabindex="-1" aria-hidden="true">
        <span class="lo__roll"><span data-blabel>Log out</span></span>
        <svg class="lo__door" viewBox="0 0 24 24" aria-hidden="true">
          <path d="M13 4.500h4.500A1.500 1.500 0 0 1 19 6v12a1.500 1.500 0 0 1-1.500 1.500H13"></path>
          <g data-arrow><path d="M4 12h10M10.500 8.500 14 12l-3.500 3.500"></path></g>
        </svg>
      </button>
      <span class="lo__say" data-say aria-live="polite"></span>
    </div>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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.

12 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 “Log out button” 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, a light grey pill with the dark disc of initials and the words “Log out”. On press it does not leave at once: the pill tightens around “Stay” and from its right a second, red pill is born, “Log out” with the door icon, widening on a spring and standing eight pixels off. Tap “Stay”, Esc or outside and the red one folds back, everything as before. Tap “Log out” and the left half closes, the red turns dark and says “Signing out”, and the disc of initials crosses the pill, reaches the door and goes through it shrinking, the arrow following. Then “Signed out”, and a moment later the pill is light and small again: “Sign in”, with the arrow turned inwards. One tap and you are back: the disc pops in with a spin and the label is “Log out” once more.

How it works

Two buttons, not one

The two halves are two real buttons in a row: the second starts zero wide and hidden. Asking for confirmation means tightening the first and widening the second, each to the size of its label.

Confirmation without a dialog

No dialog: the question is the shape itself. Staying is the gesture nearest the finger (same spot as the first tap), leaving asks you to move to the red: a careless double tap does not sign you out.

The avatar leaves by the door

On leaving, the disc is measured, a copy is made above the pills and sent to the centre of the door icon, worked out again every frame because the widths are changing meanwhile.

For keyboard users

The hidden half has tabindex -1 and aria-hidden until it is needed; Esc cancels and returns focus, and an aria-live region says every step.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#e5484dThe colour of the half that signs you out.
GAPscript.js8The space between the two halves when the pill splits, in pixels.
STRETCHscript.js1How elastic the two halves are when their width changes: 0.3 = stiff, 2 = very elastic.
PAUSEscript.js1.1How many seconds “Signed out” stays before it becomes “Sign in”.
LOOPscript.jstrueLeft alone, the demo’s pointer logs out, signs back in, and once thinks better of it.

Try them in the Playground

When to use it

At the bottom of the account menu, in a dashboard’s sidebar, in an app’s settings. The same splitting pill suits any action to confirm without a dialog: cancelling a plan, leaving a group, clearing a list.

On phones

The same button, 56 pixels tall: the two halves are wide enough for a thumb and stay in a row even on a narrow screen.

With reduced motion

The halves change width and label at once, the avatar does not fly and it goes straight from “Log out” to “Sign in”. The demo does not move by itself.

Pitfalls

  • Person and initials are made up; the real sign-out is done by the server, and “Signed out” should show only once it has answered.
  • The closed half stays in the DOM: it must leave the Tab order and be hidden from screen readers too, or you could sign out without seeing it.
  • When a half reaches zero width its padding would keep it open: it is zeroed together with the width.
  • The width is measured after the font has arrived (document.fonts.ready), or the pill is born at the fallback font’s size.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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