Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

feat: move Outline to Fill to the guided-steps page

matincd8d6e42b9c2
diff --git a/animations/05-text-typography/outline-to-fill/README.md b/animations/05-text-typography/outline-to-fill/README.md
index 7695fd8d..88fe1fd0 100644
--- a/animations/05-text-typography/outline-to-fill/README.md
+++ b/animations/05-text-typography/outline-to-fill/README.md
@@ -1,7 +1,7 @@
# Outline to Fill
## What it is
-Outline-to-fill starts text as hollow letterforms — a visible stroke with a transparent interior — then fills the characters with color. The transition reads as text being "inked in," giving it a sculptural, hand-crafted quality. Two implementation approaches exist: a clip-path reveal (directional, like paint being applied from one side) and an opacity crossfade (simultaneous, like ink bleeding in uniformly).
+Outline to fill starts text as hollow letters, with only the outline of each letter showing, then fills them with color, so the text looks as if it is being inked in. There are two ways to do it, and the demo shows both: a wipe that fills the letters from one side, like paint, and a fade that fills them everywhere at once, like ink soaking in.
## When to use it
- Hero words on posters and editorial-style sites where the letterforms themselves are the visual
@@ -76,10 +76,13 @@ For the opacity crossfade variant (no clip-path):
## Key parameters
| Parameter | Default | Effect |
|-----------|---------|--------|
-| Fill duration | 900ms | 400ms = snappy; 1500ms = slow and dramatic |
-| Stroke width | 2px | Thinner reads as precise/elegant; thicker reads as bold/graphic |
-| Direction | Bottom-up | Bottom-up reads as being filled like a container; left-right reads like writing |
-| Easing | ease-in-out | Symmetrical ease gives a smooth start and end |
+| Fill direction | Bottom up | Where the wipe starts: the bottom, the top, the left, the right or the middle; bottom up reads like filling a container, left to right like writing. The fade has no direction |
+| Speed | Normal | How long the fill takes: slow is 1500ms, normal 900ms and fast 550ms |
+| Outline thickness | Medium | How wide the outline is: thin is 1px, medium 2px and thick 4px; thin looks precise, thick looks bold |
+| Feel | Gentle | Gentle eases in and out; Smooth slows to a stop; Even keeps one steady pace |
+| Outline color | Pink | The color of the letters' outline |
+| Fill color | Pink | The color that fills the letters |
+| Your text | OUTLINE | The word that fills, up to 10 letters, shown in capitals |
## Production notes
- **`-webkit-text-stroke` is non-standard**: it is supported in all modern browsers (Chrome, Firefox, Safari, Edge) but is not in the CSS specification. The standard alternative is `text-shadow` with a spread — less crisp but more compatible. For production, test the stroke rendering in your target browsers and font size.
@@ -88,6 +91,6 @@ For the opacity crossfade variant (no clip-path):
- **GSAP**: animate `clipPath` on the fill layer element directly. `gsap.to(fillLayer, { clipPath: 'inset(0%)', duration: 0.9, ease: 'power2.inOut' })`.
## See also
-- [Text Gradient Animation](../text-gradient-animation/) — fills text with a moving gradient instead of a solid color
-- [Text Clip-Path Reveal](../text-clip-path-reveal/) — the same clip-path reveal technique applied to full lines of text
-- [Clip-Path Reveal](../../02-entrance-and-exit/clip-path-reveal/) — the general-purpose element clip-path reveal
+- [Text Gradient Animation](../text-gradient-animation/) — colors flow through the letters instead
+- [Text Clip-Path Reveal](../text-clip-path-reveal/) — whole lines are uncovered the same way
+- [Clip-Path Reveal](../../02-entrance-and-exit/clip-path-reveal/) — a shape uncovers any element
diff --git a/animations/05-text-typography/outline-to-fill/index.html b/animations/05-text-typography/outline-to-fill/index.html
index 7bb6da40..00719996 100644
--- a/animations/05-text-typography/outline-to-fill/index.html
+++ b/animations/05-text-typography/outline-to-fill/index.html
@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Outline to Fill — Animation Handbook</title>
- <meta name="description" content="Text starts as a hollow stroke then fills with color — two techniques: clip-path reveal and opacity crossfade.">
+ <meta name="description" content="Hollow letters fill with color, as a wipe or a fade. Best for big headlines.">
<link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/outline-to-fill/">
<link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png">
<link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
@@ -12,36 +12,19 @@
<meta property="og:type" content="article">
<meta property="og:site_name" content="Animation Handbook">
<meta property="og:title" content="Outline to Fill — Animation Handbook">
- <meta property="og:description" content="Text starts as a hollow stroke then fills with color — two techniques: clip-path reveal and opacity crossfade.">
+ <meta property="og:description" content="Hollow letters fill with color, as a wipe or a fade. Best for big headlines.">
<meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/outline-to-fill/">
<meta property="og:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Outline to Fill — Animation Handbook">
- <meta name="twitter:description" content="Text starts as a hollow stroke then fills with color — two techniques: clip-path reveal and opacity crossfade.">
+ <meta name="twitter:description" content="Hollow letters fill with color, as a wipe or a fade. Best for big headlines.">
<meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">
- <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Outline to Fill", "name": "Outline to Fill", "description": "Text starts as a hollow stroke then fills with color — two techniques: clip-path reveal and opacity crossfade.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/outline-to-fill/", "inLanguage": "en", "articleSection": "Text & Typography", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Text & Typography, Outline to Fill"}</script>
+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Outline to Fill", "name": "Outline to Fill", "description": "Hollow letters fill with color, as a wipe or a fade. Best for big headlines.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/05-text-typography/outline-to-fill/", "inLanguage": "en", "articleSection": "Text & Typography", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Text & Typography, Outline to Fill"}</script>
<style>
- @font-face{font-family:'Bricolage';src:url('../../../assets/fonts/brico-700.woff2') format('woff2');font-weight:700;font-display:swap}
- @font-face{font-family:'Bricolage';src:url('../../../assets/fonts/brico-800.woff2') format('woff2');font-weight:800;font-display:swap}
- @font-face{font-family:'PlexMono';src:url('../../../assets/fonts/plex-400.woff2') format('woff2');font-weight:400;font-display:swap}
- @font-face{font-family:'PlexMono';src:url('../../../assets/fonts/plex-500.woff2') format('woff2');font-weight:500;font-display:swap}
- :root{--bg:#0b0b0d;--ui-bg:#111114;--ui-border:rgba(255,255,255,.09);--ui-accent:#ff6f8b;--ui-text:#f4f4f2;--ui-muted:#77777e;--disp:'Bricolage','Arial Narrow',sans-serif;--mono:'PlexMono',ui-monospace,Menlo,Consolas,monospace;--stage-h:620px;--fill-dur:900ms;--fill-ease:ease-in-out;--stroke-color:#ff6f8b;--fill-color:#ff6f8b;--stroke-w:2px;--fill-dir:up}
+ :root{--ui-accent:#ff6f8b;--fill-dur:900ms;--fill-ease:ease-in-out;--stroke-color:#ff6f8b;--fill-color:#ff6f8b;--stroke-w:2px}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
- body{background:var(--bg);color:var(--ui-text);font-family:var(--mono);-webkit-font-smoothing:antialiased;padding:clamp(12px,3vw,24px)}
- header{margin-bottom:20px}
- header h1{font-family:var(--disp);font-weight:700;font-size:clamp(11px,1.8vw,15px);letter-spacing:-.01em}
- header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
- .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
- .stage{flex:1;min-width:0;overflow:hidden;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;background:#04060c;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:40px;padding:32px}
- /* Shared text style */
- .otf-text{
- font-family:Georgia,'Times New Roman',serif;
- font-size:clamp(52px,9vw,100px);
- line-height:1;
- letter-spacing:0.06em;
- font-style:italic;
- -webkit-user-select:none;user-select:none
- }
+ .stage{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;padding:24px;background:#04060c}
+ .otf-text{font-size:clamp(44px,8vw,84px);line-height:1;letter-spacing:0.06em;font-weight:800;-webkit-user-select:none;user-select:none}
/* Variant A: bottom-up fill via stacked layers */
.otf-wrap{position:relative;display:inline-block}
.outline-layer{
@@ -78,128 +61,208 @@
.stroke-fade-wrap.filled .stroke-only{opacity:0}
.stroke-fade-wrap.filled .fill-only{opacity:1}
/* Label */
- .var-label{font-size:10px;letter-spacing:2px;text-transform:uppercase;color:var(--ui-muted)}
- /* Panel */
- aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
- .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
- .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
- .div{height:1px;background:var(--ui-border)}
- .sr{display:flex;align-items:center;gap:6px;font-size:10px}
- .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
- .sv{width:44px;text-align:right;color:var(--ui-text)}
- select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
- input[type=text]{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:11px;padding:8px 10px;border-radius:4px;width:100%;min-height:44px;outline:none}
- input[type=text]:focus{border-color:var(--ui-accent)}
- .color-row{display:flex;gap:8px;align-items:center;font-size:10px;color:var(--ui-muted);flex-wrap:wrap}
- input[type=color]{border:none;background:none;width:44px;height:44px;cursor:pointer;border-radius:4px;padding:0;flex-shrink:0}
- button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%;min-height:44px}
- @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}}
- .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
- .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
- @media(max-width:600px){.layout{flex-direction:column;align-items:stretch}aside{width:100%}:root{--stage-h:auto}.stage{height:auto;min-height:440px}}
+ .var-label{font-size:10px;letter-spacing:2px;text-transform:uppercase;color:#8a8a92;text-align:center;margin-bottom:12px}
@media(prefers-reduced-motion:reduce){.fill-layer,.stroke-only,.fill-only{transition:none!important}.fill-layer{clip-path:inset(0%)!important}.stroke-fade-wrap.filled .fill-only{opacity:1!important}.stroke-fade-wrap.filled .stroke-only{opacity:0!important}}
</style>
-<style id="ah-inject">
-:root{--ah-bg:rgba(17,17,20,.82);--ah-line:rgba(255,255,255,.1);--ah-ink:#f4f4f2;--ah-muted:#9a9aa2;--ah-accent:#6ea8ff}
-body{padding-top:46px}
-.ah-bar{position:fixed;top:0;left:0;right:0;height:46px;z-index:2147483000;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:0 clamp(10px,3vw,18px);background:var(--ah-bg);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid var(--ah-line);font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px;box-sizing:border-box}
-.ah-bar a,.ah-bar button{color:var(--ah-muted);text-decoration:none;background:none;border:0;font:inherit;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:0 7px;border-radius:6px;transition:color .18s,background .18s;white-space:nowrap}
-.ah-bar a:hover,.ah-bar button:hover{color:var(--ah-ink)}
-.ah-home{color:var(--ah-ink);font-weight:600}
-.ah-actions{display:flex;align-items:center;gap:2px}
-.ah-sep{width:1px;height:16px;background:var(--ah-line);margin:0 4px}
-.ah-copied{color:var(--ah-accent)!important}
-@media(max-width:600px){.ah-bar .ah-hideSm{display:none}}
-@media print{.ah-bar{display:none}body{padding-top:0}}
-</style>
+ <link rel="stylesheet" href="../../../assets/css/demo-page.css?v=3">
+ <script src="../../../assets/js/demo-page.js?v=3" defer></script>
</head>
-<body>
-<div class="ah-bar" role="navigation" aria-label="Animation Handbook"><a class="ah-home" href="../../../">← Animation Handbook</a><span class="ah-actions"><a class="ah-hideSm" href="../text-gradient-animation/" rel="prev" title="Previous">‹ Prev</a><a class="ah-hideSm" href="../enter-exit-typography/" rel="next" title="Next">Next ›</a><span class="ah-sep ah-hideSm"></span><button type="button" id="ah-copy" class="ah-hideSm">Copy source</button><a class="ah-hideSm" href="https://github.com/matinmonshizadeh/animation-handbook/blob/main/animations/05-text-typography/outline-to-fill/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>
-<header>
- <h1>Outline to Fill</h1>
- <p>Text starts as a hollow stroke then fills with color — two techniques: clip-path reveal and opacity crossfade.</p>
-</header>
-<div class="layout">
- <div class="stage">
- <div>
- <div class="var-label" style="text-align:center;margin-bottom:12px">Clip-path Fill</div>
- <div class="otf-wrap" id="otf-wrap">
- <div class="otf-text outline-layer" id="outline-layer">OUTLINE</div>
- <div class="otf-text fill-layer" id="fill-layer">OUTLINE</div>
+<body class="hb" data-hb-kind="once" data-hb-autoplay>
+<nav class="hb-bar" aria-label="Animation Handbook">
+ <a class="hb-home" href="../../../"><svg class="hb-mark" viewBox="0 0 32 32" aria-hidden="true"><g class="g"><circle cx="11.16" cy="20.84" r="6.1"/><circle cx="15.12" cy="16.88" r="6.1"/><circle cx="18.51" cy="13.49" r="6.1"/></g><circle class="b" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>
+ <span class="hb-pager"><a href="../text-gradient-animation/" rel="prev" aria-label="Previous: Text Gradient Animation"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg><span><span class="hb-dir">Previous: </span>Text Gradient Animation</span></a><a href="../enter-exit-typography/" rel="next" aria-label="Next: Enter/Exit Typography"><span><span class="hb-dir">Next: </span>Enter/Exit Typography</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></a></span>
+</nav>
+<main class="hb-page">
+ <header class="hb-head">
+ <p class="hb-cat">05.09 · Text &amp; Typography</p>
+ <h1>Outline to Fill</h1>
+ <p class="hb-lede">Hollow letters fill with color, as a wipe or a fade. Best for big headlines.</p>
+ </header>
+
+ <section class="hb-step hb-watch" aria-labelledby="hb-watch-title">
+ <div class="hb-step-head">
+ <span class="hb-num" aria-hidden="true">1</span>
+ <div><h2 id="hb-watch-title">Watch it</h2><p>It plays by itself. Turn on slow motion to see each part of the movement.</p></div>
+ </div>
+ <div class="stage hb-dots">
+ <div class="otf-item">
+ <p class="var-label">Wipe</p>
+ <div class="otf-wrap" id="otf-wrap">
+ <div class="otf-text outline-layer" id="outline-layer">OUTLINE</div>
+ <div class="otf-text fill-layer" id="fill-layer">OUTLINE</div>
+ </div>
+ </div>
+ <div class="otf-item">
+ <p class="var-label">Fade</p>
+ <div class="stroke-fade-wrap" id="stroke-wrap">
+ <div class="otf-text stroke-only" id="stroke-only">OUTLINE</div>
+ <div class="otf-text fill-only" id="fill-only">OUTLINE</div>
+ </div>
+ </div>
+ </div>
+ <div class="hb-player">
+ <button class="hb-play" type="button" id="btn-play" data-hb-replay><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>Replay</button>
+ <label class="hb-toggle"><input class="hb-switch" type="checkbox" role="switch" id="loop-tog" data-hb-loop autocomplete="off"><span>Loop</span></label>
+ <label class="hb-toggle"><input class="hb-switch" type="checkbox" role="switch" id="slow-tog" data-hb-slowmo autocomplete="off"><span>Slow motion</span></label>
+ </div>
+ </section>
+
+ <section class="hb-step hb-try" aria-labelledby="hb-try-title">
+ <div class="hb-step-head">
+ <span class="hb-num" aria-hidden="true">2</span>
+ <div><h2 id="hb-try-title">Try it</h2><p>Change a setting and the animation plays again.</p></div>
+ </div>
+ <div class="hb-settings">
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="dir-lbl">Fill direction</p>
+ <div class="seg" id="dir-seg" role="group" aria-labelledby="dir-lbl">
+ <button type="button" data-dir="up" class="on" aria-pressed="true">Bottom up</button>
+ <button type="button" data-dir="down" aria-pressed="false">Top down</button>
+ <button type="button" data-dir="right" aria-pressed="false">Left to right</button>
+ <button type="button" data-dir="left" aria-pressed="false">Right to left</button>
+ <button type="button" data-dir="center" aria-pressed="false">From the middle</button>
+ </div>
+ <p class="hb-hint">Where the wipe starts; the fade fills all at once.</p>
+ </div>
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="speed-lbl">Speed</p>
+ <div class="seg" id="speed-seg" role="group" aria-labelledby="speed-lbl">
+ <button type="button" data-ms="1500" aria-pressed="false">Slow</button>
+ <button type="button" data-ms="900" class="on" aria-pressed="true">Normal</button>
+ <button type="button" data-ms="550" aria-pressed="false">Fast</button>
+ </div>
+ <p class="hb-hint">How long the letters take to fill.</p>
+ </div>
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="thick-lbl">Outline thickness</p>
+ <div class="seg" id="thick-seg" role="group" aria-labelledby="thick-lbl">
+ <button type="button" data-px="1" aria-pressed="false">Thin</button>
+ <button type="button" data-px="2" class="on" aria-pressed="true">Medium</button>
+ <button type="button" data-px="4" aria-pressed="false">Thick</button>
+ </div>
+ <p class="hb-hint">Thin looks precise; thick looks bold and graphic.</p>
</div>
</div>
- <div>
- <div class="var-label" style="text-align:center;margin-bottom:12px">Stroke → Fill Fade</div>
- <div class="stroke-fade-wrap" id="stroke-wrap">
- <div class="otf-text stroke-only" id="stroke-only">OUTLINE</div>
- <div class="otf-text fill-only" id="fill-only">OUTLINE</div>
+ <details class="hb-options">
+ <summary><span class="hb-more-label">More options</span><span class="hb-less">Fewer options</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></summary>
+ <div class="hb-settings">
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="feel-lbl">Feel</p>
+ <div class="seg" id="feel-seg" role="group" aria-labelledby="feel-lbl">
+ <button type="button" data-ease="ease-out" aria-pressed="false">Smooth</button>
+ <button type="button" data-ease="ease-in-out" class="on" aria-pressed="true">Gentle</button>
+ <button type="button" data-ease="linear" aria-pressed="false">Even</button>
+ </div>
+ <p class="hb-hint">Gentle eases in and out; Even keeps one pace.</p>
+ </div>
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="outline-color-lbl">Outline color</p>
+ <div class="swatches" id="outline-color-sw" role="group" aria-labelledby="outline-color-lbl">
+ <button type="button" class="on" aria-pressed="true" aria-label="Pink" data-c="#ff6f8b" style="background:#ff6f8b"></button>
+ <button type="button" aria-pressed="false" aria-label="White" data-c="#f4f4f2" style="background:#f4f4f2"></button>
+ <button type="button" aria-pressed="false" aria-label="Blue" data-c="#58a6ff" style="background:#58a6ff"></button>
+ <button type="button" aria-pressed="false" aria-label="Purple" data-c="#d2a8ff" style="background:#d2a8ff"></button>
+ <button type="button" aria-pressed="false" aria-label="Green" data-c="#56d364" style="background:#56d364"></button>
+ <button type="button" aria-pressed="false" aria-label="Orange" data-c="#ffa657" style="background:#ffa657"></button>
+ </div>
+ <p class="hb-hint">The color of the letters' edges.</p>
+ </div>
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="fill-color-lbl">Fill color</p>
+ <div class="swatches" id="fill-color-sw" role="group" aria-labelledby="fill-color-lbl">
+ <button type="button" class="on" aria-pressed="true" aria-label="Pink" data-c="#ff6f8b" style="background:#ff6f8b"></button>
+ <button type="button" aria-pressed="false" aria-label="White" data-c="#f4f4f2" style="background:#f4f4f2"></button>
+ <button type="button" aria-pressed="false" aria-label="Blue" data-c="#58a6ff" style="background:#58a6ff"></button>
+ <button type="button" aria-pressed="false" aria-label="Purple" data-c="#d2a8ff" style="background:#d2a8ff"></button>
+ <button type="button" aria-pressed="false" aria-label="Green" data-c="#56d364" style="background:#56d364"></button>
+ <button type="button" aria-pressed="false" aria-label="Orange" data-c="#ffa657" style="background:#ffa657"></button>
+ </div>
+ <p class="hb-hint">The color that pours into the letters.</p>
+ </div>
+ <div class="hb-setting">
+ <label class="hb-setting-name" for="txt-in">Your text</label>
+ <input class="hb-text" type="text" id="txt-in" value="OUTLINE" maxlength="10" autocomplete="off">
+ <p class="hb-hint">Short words work best, up to 10 letters.</p>
+ </div>
+ </div>
+ </details>
+ </section>
+
+ <section class="hb-step hb-prompt-step" aria-labelledby="hb-prompt-title">
+ <div class="hb-step-head">
+ <span class="hb-num" aria-hidden="true">3</span>
+ <div><h2 id="hb-prompt-title">Copy the prompt</h2><p>Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.</p></div>
+ </div>
+ <div class="hb-card">
+ <p class="hb-prompt">Add an outline-to-fill effect to [your headline or logo word]. The text should start hollow, with only the outline of each letter showing, then fill with color. The fill can wipe in from one side, like paint, or fade in everywhere at once, like ink soaking through. Draw the outline and the filled text as two layers in exactly the same place so the letters never shift. Use large, heavy letters so there is enough inside each one to fill. The text must stay readable by screen readers. If the visitor has reduced motion turned on, show the filled text straight away. Match the settings listed below.</p>
+ <div class="hb-chips-box" hidden>
+ <p class="hb-chips-title">Your settings</p>
+ <ul class="hb-chips"></ul>
+ </div>
+ <div class="hb-copy-row">
+ <button class="hb-copy" type="button"><svg class="hb-ic hb-i-copy" viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg><svg class="hb-ic hb-i-done" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg><span class="hb-copy-label" aria-live="polite">Copy prompt</span></button>
+ <p class="hb-hint">Replace the words in brackets with your own element. Your settings are added at the end.</p>
</div>
</div>
- </div>
- <aside>
- <p class="note">Two stacked text elements: the outline layer always visible, the filled layer revealed by clip-path from the chosen direction. -webkit-text-stroke is non-standard but universally supported.</p>
- <div class="lbl">Direction</div>
- <select id="dir-sel">
- <option value="up" selected>Up (bottom to top)</option>
- <option value="down">Down (top to bottom)</option>
- <option value="left">Left (right to left)</option>
- <option value="right">Right (left to right)</option>
- <option value="center">Center outward</option>
- </select>
- <div class="lbl">Fill Duration</div>
- <div class="sr"><input type="range" id="dur-sl" min="300" max="2000" value="900" step="50"><span class="sv" id="dur-v">900ms</span></div>
- <div class="lbl">Stroke Width</div>
- <div class="sr"><input type="range" id="sw-sl" min="1" max="6" value="2" step="1"><span class="sv" id="sw-v">2px</span></div>
- <div class="lbl">Colors</div>
- <div class="color-row">
- <span>Stroke</span><input type="color" id="stroke-pick" value="#ff6f8b" aria-label="Stroke color">
- <span>Fill</span><input type="color" id="fill-pick" value="#ff6f8b" aria-label="Fill color">
+ </section>
+
+ <section class="hb-about" aria-labelledby="hb-what-title">
+ <div class="hb-what">
+ <h2 id="hb-what-title">What it is</h2>
+ <div class="hb-what-text"><p>The full explanation is in <a href="README.md">README.md</a>.</p></div>
+ </div>
+ <div class="hb-fit">
+ <h2>Good for</h2>
+ <ul class="hb-tags hb-good"><li>Big headlines</li><li>Logos</li><li>Posters</li><li>Section titles</li></ul>
+ <h3>Avoid on</h3>
+ <ul class="hb-tags hb-avoid"><li>Small text</li><li>Body text</li></ul>
</div>
- <div class="lbl">Easing</div>
- <select id="ease-sel">
- <option value="ease-in-out" selected>Ease in-out</option>
- <option value="ease-out">Ease out</option>
- <option value="linear">Linear</option>
- </select>
- <div class="div"></div>
- <div class="lbl">Text</div>
- <input type="text" id="text-inp" value="OUTLINE" maxlength="10">
- <button class="rst" id="replay-btn">↺ Replay</button>
- <label class="tog"><input type="checkbox" id="loop-tog"><span>Auto-loop</span></label>
- </aside>
-</div>
+ </section>
+
+ <section class="hb-related" aria-labelledby="hb-related-title" hidden>
+ <h2 id="hb-related-title">Similar animations</h2>
+ <div class="hb-rel-list"></div>
+ </section>
+</main>
+<footer class="hb-foot"><span>Animation Handbook</span><a href="#top">Back to top ↑</a></footer>
<script>
const fillLayer=document.getElementById('fill-layer');
const strokeWrap=document.getElementById('stroke-wrap');
- let loopTimer=null;
-
+ const outlineLayer=document.getElementById('outline-layer'),strokeOnly=document.getElementById('stroke-only'),fillOnly=document.getElementById('fill-only');
+ const vars=document.documentElement.style;
+ const loopTog=document.getElementById('loop-tog'),slowTog=document.getElementById('slow-tog');
+ const txtIn=document.getElementById('txt-in');
+ const motionOk=!window.matchMedia('(prefers-reduced-motion:reduce)').matches;
const DIR_CLASSES=['dir-down','dir-left','dir-right','dir-center'];
+ let dir='up',ms=900,strokeW=2,ease='ease-in-out',timers=[];
- function applyText(t){
- ['outline-layer','fill-layer','stroke-only','fill-only'].forEach(id=>{
- document.getElementById(id).textContent=t;
- });
- fitText();
+ function dur(){return slowTog.checked?ms*3:ms}
+ function apply(){
+ vars.setProperty('--fill-dur',dur()+'ms');
+ vars.setProperty('--fill-ease',ease);
+ vars.setProperty('--stroke-w',strokeW+'px');
+ }
+ function later(fn,wait){timers.push(setTimeout(fn,wait))}
+ function applyDir(){
+ fillLayer.classList.remove(...DIR_CLASSES);
+ if(dir!=='up')fillLayer.classList.add('dir-'+dir);
}
-
function fitText(){
// Scale long words down so they never get clipped by the stage on narrow screens
- const avail=document.querySelector('.stage').clientWidth-64;
+ const avail=document.querySelector('.stage').clientWidth-48;
document.querySelectorAll('.otf-wrap,.stroke-fade-wrap').forEach(w=>{
w.style.transform='';
const s=avail>0?Math.min(1,avail/w.offsetWidth):1;
if(s<1)w.style.transform='scale('+s.toFixed(3)+')';
});
}
-
- function applyDir(){
- const dir=document.getElementById('dir-sel').value;
- fillLayer.classList.remove(...DIR_CLASSES);
- if(dir!=='up')fillLayer.classList.add('dir-'+dir);
+ function applyText(t){
+ [outlineLayer,fillLayer,strokeOnly,fillOnly].forEach(el=>{el.textContent=t;});
+ fitText();
}
-
+ // Snaps both variants back to hollow without a reverse transition, then forces a reflow so the next
+ // fill runs at full length from the start.
function reset(){
- // Snap back without a reverse transition, so the next fill runs at full length
const layers=[fillLayer,...strokeWrap.children];
layers.forEach(el=>el.style.transition='none');
fillLayer.classList.remove('filled');
@@ -208,50 +271,43 @@ body{padding-top:46px}
void fillLayer.offsetWidth;
layers.forEach(el=>el.style.transition='');
}
-
- function play(){
- clearTimeout(loopTimer);
+ // One play fills both words together. While Loop is on it then holds filled for 1400ms, snaps back
+ // to hollow at once, waits 300ms and plays again; switching Loop off lets the words finish filled.
+ // Slow motion stretches the fill itself, not the hold or the wait.
+ function cycle(){
+ apply();
reset();
- const dur=+document.getElementById('dur-sl').value;
requestAnimationFrame(()=>requestAnimationFrame(()=>{
fillLayer.classList.add('filled');
strokeWrap.classList.add('filled');
}));
- if(document.getElementById('loop-tog').checked&&!matchMedia('(prefers-reduced-motion: reduce)').matches){
- loopTimer=setTimeout(()=>{reset();loopTimer=setTimeout(play,300);},dur+1400);
- }
+ if(!loopTog.checked||!motionOk)return;
+ later(()=>{
+ if(!loopTog.checked)return;
+ reset();
+ later(cycle,300);
+ },dur()+1400);
}
+ function play(){timers.forEach(clearTimeout);timers=[];cycle()}
- document.getElementById('replay-btn').addEventListener('click',play);
- document.getElementById('dur-sl').addEventListener('input',e=>{
- document.getElementById('dur-v').textContent=e.target.value+'ms';
- document.documentElement.style.setProperty('--fill-dur',e.target.value+'ms');
- });
- document.getElementById('sw-sl').addEventListener('input',e=>{
- document.getElementById('sw-v').textContent=e.target.value+'px';
- document.documentElement.style.setProperty('--stroke-w',e.target.value+'px');
- });
- document.getElementById('stroke-pick').addEventListener('input',e=>{
- document.documentElement.style.setProperty('--stroke-color',e.target.value);
- });
- document.getElementById('fill-pick').addEventListener('input',e=>{
- document.documentElement.style.setProperty('--fill-color',e.target.value);
- });
- document.getElementById('ease-sel').addEventListener('change',e=>{
- document.documentElement.style.setProperty('--fill-ease',e.target.value);
- });
- document.getElementById('dir-sel').addEventListener('change',play);
- document.getElementById('loop-tog').addEventListener('change',e=>{
- if(e.target.checked)play();else clearTimeout(loopTimer);
- });
- document.getElementById('text-inp').addEventListener('input',e=>{
- applyText(e.target.value.toUpperCase()||'OUTLINE');play();
- });
+ document.getElementById('btn-play').addEventListener('click',play);
+ loopTog.addEventListener('change',()=>{if(loopTog.checked)play()});
+ function choices(id,pick){
+ const buttons=document.querySelectorAll('#'+id+' button');
+ buttons.forEach(b=>b.addEventListener('click',()=>{
+ buttons.forEach(x=>{x.classList.toggle('on',x===b);x.setAttribute('aria-pressed',String(x===b))});
+ pick(b.dataset);
+ }));
+ }
+ choices('dir-seg',d=>{dir=d.dir});
+ choices('speed-seg',d=>{ms=+d.ms});
+ choices('thick-seg',d=>{strokeW=+d.px});
+ choices('feel-seg',d=>{ease=d.ease});
+ choices('outline-color-sw',d=>{vars.setProperty('--stroke-color',d.c)});
+ choices('fill-color-sw',d=>{vars.setProperty('--fill-color',d.c)});
+ txtIn.addEventListener('input',()=>{applyText(txtIn.value.toUpperCase()||'OUTLINE')});
window.addEventListener('resize',fitText);
-
- fitText();
- play();
+ apply();applyDir();fitText();
</script>
-<script>(function(){var b=document.getElementById("ah-copy");if(!b)return;b.addEventListener("click",function(){fetch(location.href).then(function(r){return r.text();}).catch(function(){return document.documentElement.outerHTML;}).then(function(t){return navigator.clipboard.writeText(t);}).then(function(){b.textContent="Copied!";b.classList.add("ah-copied");setTimeout(function(){b.textContent="Copy source";b.classList.remove("ah-copied");},1500);}).catch(function(){b.textContent="Copy failed";setTimeout(function(){b.textContent="Copy source";},1500);});});})();</script>
</body>
</html>
diff --git a/index.html b/index.html
index 9d344cb1..6068f973 100644
--- a/index.html
+++ b/index.html
@@ -995,7 +995,7 @@ const CATS=[
['marquee-ticker','Marquee / Ticker','Continuous horizontal scroll with seamless loop — duplicated content makes the reset invisible.'],
['text-morphing','Text Morphing','One word transitions into another character by character — each letter slides out as the next slides in.'],
['text-gradient-animation','Text Gradient Animation','background-clip: text with animated background-position flows color through the characters.'],
- ['outline-to-fill','Outline to Fill','Hollow stroke letterforms fill with color — clip-path reveal or opacity crossfade.'],
+ ['outline-to-fill','Outline to Fill','Hollow letters fill with color, as a wipe or a fade. Best for big headlines.'],
['enter-exit-typography','Enter/Exit Typography','Each phrase comes in, stays long enough to read, then leaves. Best for slogans.'],
['rotate-word-carousel','Rotate Word Carousel','One keyword cycles through a list while the surrounding sentence stays static.'],
['glitch-text','Glitch Text','RGB-split copies jitter behind animated clip-path slices — the datamosh / signal-loss aesthetic.'],