Skip to content
animorio
IT
Back to the library

Candle-out transition

Transitions, SVGGSAP, CSS onlyMediumCompressed weight: Demo 7.1 KBGSAP 28 KBFreeDownload the zip

A minimal page transition for Halloween night, with no pumpkins and no candle drawn: only light, dark and one line. On a click the warm light of the page closes into a circle that gets smaller and warmer, drawn towards the link, and the letters of the title thin out as the light leaves them; it flickers like a flame being blown and goes out. From that point a thread of smoke rises, curls and fades, then the next page lights up again from the same point and its title takes its weight as the light reaches it.

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>
<!--
  "Candle-out transition" 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 page transition that goes out like a candle</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="scena" data-stage>
    <!-- the first page: a title in the warm light of the page -->
    <section class="pagina is-on" data-page="a" aria-label="Tonight">
      <header class="testa">
        <span class="marchio">Vesper</span>
        <span class="voce">Stories for the long night</span>
      </header>
      <h1 class="titolo" data-title>After dark</h1>
      <p class="riga-sotto">Short stories, read by one lamp.</p>
      <a class="vai" href="#story" data-go data-autoclic>
        <span class="vai__t">Read tonight’s story</span>
        <svg class="vai__freccia" viewBox="0 0 26 12" aria-hidden="true"><path d="M1 6h22M18.5 1.5 23.5 6l-5 4.5"/></svg>
      </a>
    </section>

    <!-- the second page: the same light, lit again from the point where the first one went out -->
    <section class="pagina" data-page="b" aria-label="The story" aria-hidden="true">
      <header class="testa">
        <span class="marchio">Vesper</span>
        <span class="voce">Nine minutes, by the window</span>
      </header>
      <h2 class="titolo" data-title>Last light</h2>
      <p class="riga-sotto">The house was quiet, and the wick still warm.</p>
      <a class="vai vai--torna" href="#tonight" data-go data-autoclic>
        <svg class="vai__freccia" viewBox="0 0 26 12" aria-hidden="true"><path d="M25 6H3M7.5 1.5 2.5 6l5 4.5"/></svg>
        <span class="vai__t">Back to tonight</span>
      </a>
    </section>

    <!-- the dark that closes in around the light, and the warm glow that gathers as it shrinks -->
    <div class="buio" data-dark aria-hidden="true"></div>
    <div class="calore" data-warm aria-hidden="true"></div>

    <!-- the one line of smoke that rises when the light goes out -->
    <svg class="fumo" data-smoke aria-hidden="true" xmlns="http://www.w3.org/2000/svg">
      <defs>
        <linearGradient id="sfuma" gradientUnits="userSpaceOnUse" data-fade>
          <stop offset="0" style="stop-color:var(--fumo);stop-opacity:0.95"/>
          <stop offset="0.55" style="stop-color:var(--fumo);stop-opacity:0.5"/>
          <stop offset="1" style="stop-color:var(--fumo);stop-opacity:0"/>
        </linearGradient>
        <filter id="velo" x="-50%" y="-10%" width="200%" height="120%"><feGaussianBlur stdDeviation="2.2"/></filter>
      </defs>
      <path class="fumo__velo" data-wisp filter="url(#velo)"/>
      <path class="fumo__filo" data-thread/>
    </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.

24 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 “Candle-out transition” 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 dark page, the one of a small made-up story magazine, ‘Vesper’, sits in a warm light that breathes a little at its edges, like in a still room: the name and a line at the top, the big title ‘After dark’ in the middle, a grey sentence under it and a pill link with an orange arrow. Under the pointer the link widens, its border warms up and a faint glow lights under it; the arrow takes a three-pixel step. On a click the light leaves the corners and closes in, drawn towards the link, into a circle that gets smaller and warmer, orange in the middle; the letters of the title thin out one by one as the light leaves them. When the circle is as small as a flame it flickers, leans, catches, leans again and goes out: for a moment an ember stays and cools. From that point a single line of smoke rises, thin, curling, sliding sideways, coming loose from the bottom and fading. In the dark the next page arrives, ‘Last light’, and lights up again from the same point: a spark, a waver, then the light opens out to the corners and the letters of the new title take their weight as the light reaches them. The ‘Back to tonight’ link goes back the same way.

How it works

The light is a hole in the dark

Over the page lies a veil the colour of the night, with a radial gradient that is clear in the middle: the circle of light. A script writes its centre, radius and edge softness every frame, with five stops for an edge that fades gently. At rest the radius is bigger than the page and leaves only a vignette that breathes with three overlapping sines.

Smaller, warmer

A second layer in screen blending lays an orange gradient on the same centre: its strength grows as the radius drops, so the shrinking circle warms up by itself. The ember left after the light goes out is the same layer with one more number that GSAP brings down to zero.

The flicker written by hand

Before it goes out the radius passes through seven hand-picked values, smaller and smaller but not in order (22, 31, 15, 25, 10, 17, 7 pixels), with timings that grow longer: the flame leaning and catching again. The FLICKER knob draws them closer to the starting radius.

A single line of smoke

The smoke is an SVG path of thirty points joined with a Catmull-Rom curve: each point rises with its place along the thread and moves sideways with two sines that run over time, wider towards the top, so the line curls as it rises. Its head and tail are two numbers that GSAP raises, and a vertical gradient fades it upwards; under it the same line, blurred, makes a veil.

The weight follows the light

The letters of the title are measured once; every frame their distance from the centre of the light, compared with the radius, gives a value between zero and one that picks the weight of the variable font, from 300 to 620. So the title thins out as the light leaves it and takes its weight as the light reaches it.

Values to change

NameFileDefaultWhat it changes
SPEEDscript.js12 = twice as fast, 0.5 = half as fast.
FLICKERscript.js1How hard the light flickers before it goes out: 0 = it just goes out.
WARMTHscript.js1How warm the light gets as it closes in: 0 = no warm glow.
SMOKEscript.js1How tall the thread of smoke rises.
CURLscript.js1How much the smoke curls: 0 = a straight line.
DARKscript.js0.9Seconds of dark between the smoke and the new light.
THINscript.js300The weight of the title letters out of the light (lit, they are 620).

Try them in the Playground

When to use it

For moving from one page to another on a dark, intimate site: a story magazine, a night-time podcast, a theatre, an art-house cinema, a bar that opens in the evening, a special Halloween page. It works with any link: the light closes in towards the one that was clicked.

On phones

The same transition: the title is as big as the screen allows, in width and height, the smoke rises a little less and the light closes in towards the link that was tapped.

With reduced motion

Nothing closes in and nothing rises: the page fades into the dark and the next page fades in, with its title already at its weight.

Pitfalls

  • The resting radius is worked out again on every resize from the distance between the centre and the farthest corner: with a fixed number, the corners stay dark on a rotated phone.
  • The letter positions are measured with the title at full weight: measured while thin, the weight changes their width and the light reaches them late.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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