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.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
fix: stop Focus Ring zooming iOS, cutting its widest ring and blurring a visitor
matin4a9d2a0a54aa
diff --git a/animations/04-micro-interactions/focus-ring/README.md b/animations/04-micro-interactions/focus-ring/README.mdindex 4bf06cc2..68394293 100644--- a/animations/04-micro-interactions/focus-ring/README.md+++ b/animations/04-micro-interactions/focus-ring/README.md@@ -1,7 +1,7 @@# Focus Ring Animation## What it is-A focus ring is the outline that shows which item the keyboard is on. Animating it, so the ring closes in around each item as you press Tab, makes every move easier to follow. It shows only when the keyboard is used, so people who click with a mouse do not see rings appear.+A focus ring is the outline that shows which item the keyboard is on. Animating it, so the ring closes in around each item as you press Tab, makes every move easier to follow. It shows when the keyboard is used (and when you click into a text field, since you type there next), so people who click buttons and links with a mouse do not see rings appear.## When to use it- Every interactive element on every page — focus rings are mandatory for WCAG 2.4.7 compliancediff --git a/animations/04-micro-interactions/focus-ring/index.html b/animations/04-micro-interactions/focus-ring/index.htmlindex cd2b45cf..397f5c27 100644--- a/animations/04-micro-interactions/focus-ring/index.html+++ b/animations/04-micro-interactions/focus-ring/index.html@@ -25,12 +25,15 @@*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}.stage{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:16px;background:#0b0b0d}.form{display:flex;flex-direction:column;gap:12px;width:100%;max-width:340px}- /* A window this short gives the stage 260px, less than the form needs: the stage and the form give up some spacing, the items keep their size */- @media(min-width:601px) and (max-height:620px){.stage{padding:8px}.form{gap:8px}}+ /* A window this short gives the stage 260px, less than the form needs: the stage and the form give up some spacing, the items keep their size.+ The bottom keeps 11px, the reach of the widest ring (Thick, Large gap, Wide), so the last item's ring is not cut. */+ @media(min-width:601px) and (max-height:620px){.stage{padding:5px 8px 11px}.form{gap:8px}}.field{display:flex;flex-direction:column;gap:6px}.field label{font-size:11px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-muted)}/* Reset browser outline */.focusable{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:inherit;font-size:12px;padding:10px 12px;border-radius:4px;width:100%;outline:none;min-height:44px;transition:border-color var(--ring-dur) ease}+ /* iOS zooms the whole page when a text field or menu under 16px gets focus */+ @media(pointer:coarse){input.focusable,select.focusable{font-size:16px}}.focusable::placeholder{color:var(--ui-muted);opacity:1}.form-btn{background:var(--ui-accent);color:#000;border:none;font-family:inherit;font-weight:bold;padding:0 20px;cursor:pointer}.form-link{color:var(--ui-accent);text-decoration:none;font-family:inherit;padding:10px 2px;display:inline-block;line-height:24px}@@ -204,8 +207,10 @@function stopRun(){runTimers.forEach(clearTimeout);runTimers=[];items.forEach(el=>el.classList.remove('is-demo'))}// The ring closes in on item i for ringDur and stays 460ms, then moves on; the last one is let go the same way.// The run only adds a class and never moves the real focus (that would take a keyboard user's place and open the phone keyboard);- // a stage item that has the real focus is blurred first, so two rings never show at once.- document.getElementById('btn-demo').addEventListener('click',()=>{+ // a stage item that has the real focus is blurred first, so two rings never show at once. The arrival press is not the visitor's:+ // it does nothing while the visitor is already in the form.+ document.getElementById('btn-demo').addEventListener('click',e=>{+ if(!e.isTrusted&&stage.contains(document.activeElement))return;stopRun();if(stage.contains(document.activeElement))document.activeElement.blur();items.forEach((el,i)=>later(()=>{if(i)items[i-1].classList.remove('is-demo');el.classList.add('is-demo')},i*ringDur,i*460));diff --git a/docs/superpowers/plans/2026-09-29-micro-content-part1.md b/docs/superpowers/plans/2026-09-29-micro-content-part1.mdindex 0f17ce22..54542eff 100644--- a/docs/superpowers/plans/2026-09-29-micro-content-part1.md+++ b/docs/superpowers/plans/2026-09-29-micro-content-part1.md@@ -79,6 +79,7 @@ Each section says what "stops" also undoes.- The stage keeps only the demo: counters, readouts, captions, notes, teaching overlays and on-stage buttons that only drive the demo go (each section lists them).- The page owns the stage's size, border and corners. The old `--stage-h`, the stage's `height`, `flex`, `min-width`, `border` and `border-radius`, and the phone rules that made the stage `height:auto` go. The demo's own `.stage` rule keeps its background, its flex centring, `position:relative` and `overflow:hidden` where it has them, and the padding and gap its section gives.- Heights were measured with the site font on the phone stage (343×300, and 288×300 at 320px wide) and the laptop stage (960×327, which is what a 1366×657 screen gets). Every stage in this half fits the default height, so no page sets `--hb-stage-h`, and none takes typed text that grows, so none uses `hb-grow`. The measured height of each stage's content is in its section.+ - **The 260px short stage.** A window at least 601px wide and at most 620px tall (1280×590, 1366×560, 667×375, 812×375) gives the stage 260px, and five stages in this half need more. Each has a `@media(min-width:601px) and (max-height:620px)` rule that gives up spacing only: the controls keep their 44px and the buttons their size. Hover State `.stage{padding:10px}` (the six cards need 236px); Focus Ring `.stage{padding:5px 8px 11px}.form{gap:8px}` (the form needs 242px, and the bottom keeps 11px for the widest ring); Button Press Scale `.stage{gap:20px}`; Toggle / Switch Slide `.stage{gap:20px;padding:20px}`; Form Field Morph `.stage{padding:8px}.form{gap:12px}`. Phones and stages of 300px and more are not affected.- **Site font on controls:** stage buttons, inputs, selects and textareas get `font-family:inherit`, because form controls do not take the page font by themselves.- **Focus looks on the stage:** the shared stylesheet draws the site's focus ring on every focused element (`body.hb :focus-visible`, specificity 0,2,1). A stage control with its own focus look beats the site ring with a stronger selector: Focus Ring's rings, Form Field Morph's fields and Toggle / Switch Slide's track. A control without one keeps the site ring.- **Grey stage text:** `:root`'s `--ui-muted` becomes `#8a8a92`, as in Part 2 (the site's own muted grey), so every stage rule that uses it changes at once. It is 5.7:1 on the stage's `#0b0b0d` and 5.5:1 on the cards' `#111114`; the old `#77777e` is 4.4:1 and 4.2:1. Stage text below 11px goes up to 11px.@@ -107,7 +108,7 @@ Each section says what "stops" also undoes.- **Slow motion:** css. `later()` triples each card's movement (Speed), not its 270ms and 50ms holds.- **Reduced motion:** the demo's rule stays: the cards change look at once, without the transition. Show me still switches each card's look on and off in turn.- **Stage font:** site font. `.hcard-name` and `.card-link` get `font-size:15px` and `font-weight:700`.-- **Stage:** the six cards stay, two to a row on every screen (the phone rule that made one column goes). The small "Technique 1" to "Technique 6" labels go, and the names become plain: "Color change", "Grow", "Lift", "Underline" (the link text of the underline card), "Arrow nudge" (with its →) and "Sweep". `.hgrid` gets `gap:10px`; `.hcard` gets `min-height:72px` and `padding:14px 12px`; the stage gets `padding:16px`. The wrapper `div` around the grid keeps `width:100%`. `hb-dots`: yes. Measured: 270px on a phone, 284px at 320px, 270px on a laptop.+- **Stage:** the six cards stay, two to a row on every screen (the phone rule that made one column goes). The small "Technique 1" to "Technique 6" labels go, and the names become plain: "Color change", "Grow", "Lift", "Underline" (the link text of the underline card), "Arrow nudge" (with its →) and "Sweep". `.hgrid` gets `gap:10px`; `.hcard` gets `min-height:72px` and `padding:14px 12px`; the stage gets `padding:16px`. The wrapper `div` around the grid keeps `width:100%`. `hb-dots`: yes. Measured: 270px on a phone, at 320px wide and on a laptop (six cards of 72px make a 236px grid, with 32px of padding and 2px of border). On the 260px short stage, `@media(min-width:601px) and (max-height:620px){.stage{padding:10px}}` lets the padding give way, so the cards keep their size and nothing overflows.- Two changes move to transform and opacity (see the preamble). Today the underline grows by `width` and the lift adds a `box-shadow`.- The underline: `.h-underline .card-link::after` gets `width:100%`, `transform:scaleX(0)` and `transform-origin:left`, and a `transform` transition. It grows with `transform:scaleX(1)` on hover, `:active` and `.is-demo`.- The lift: `.h-lift` gets `overflow:visible` and keeps only its `translateY(-4px)`, with a `transform` transition. Its shadow moves to `.h-lift::after` (`content:'';position:absolute;inset:0;border-radius:inherit;box-shadow:0 8px 24px rgba(0,0,0,.6);opacity:0;pointer-events:none;transition:opacity var(--dur) var(--ease)`), which fades in (`opacity:1`) on hover, `:active` and `.is-demo`.@@ -231,11 +232,11 @@ None: leave out the `details.hb-options` block.- **Description:** A ring closes in around the item the Tab key reaches. Best for forms and menus.- **Step 1:** Press Tab — help line: "Click the first field and press Tab to move through the form, or press Show me."- **Player bar:** Show me · Slow motion (css). No Reset (see Removed).-- **What the visitor does:** the Tab key moves the real focus through the text field, the menu, the button and the link, and each one draws its ring on `:focus-visible`, as today. A mouse click on the menu, the button or the link shows no ring; the text field shows one on click too, because browsers treat a field you type in as keyboard focus.+- **What the visitor does:** the Tab key moves the real focus through the text field, the menu, the button and the link, and each one draws its ring on `:focus-visible`, as today. A mouse click on the button or the link shows no ring; the text field shows one on click too, because browsers treat a field you type in as keyboard focus, and Chrome does the same for the menu.- **Show me:** draws the ring on the four items in turn with `is-demo`: the text field, the menu, the button and the link.- Item i (0 to 3) gets `is-demo` with `later(ring, i*ringDur, i*460)`, and the item before it loses it at the same moment. The last one loses it with `later(end, 4*ringDur, 4*460)`, back to rest. `ringDur` is Speed: each ring closes in, then holds 460ms.- At the defaults the ring moves at 0, 600, 1200 and 1800ms and goes at 2400ms, or about 3.5 s with Slow motion.- - At the start the run also blurs a stage item that has the real focus.+ - At the start the run also blurs a stage item that has the real focus. The arrival press is the exception: it is the shared script's, not the visitor's, so when the visitor is already in the form the page ignores an untrusted Show me press (`e=>{if(!e.isTrusted&&stage.contains(document.activeElement))return; ...}`) and never takes a visitor's place in a field. The visitor's own Show me press still blurs and runs.- The run never moves the real focus (owner decision). Moving it would take a keyboard or screen-reader user's place on the page when Show me runs on arrival, scroll the page, and open the on-screen keyboard on phones. So the ring is drawn the way the other do-it pages draw a pretend hover.- The four ring-style rules and the reduced-motion rule each list `.focusable.is-demo` beside `.focusable:focus-visible`, so the same `ring-in` animation plays.- Stops on `hb:input` and on a trusted `focusin` inside the stage (a Tab press into the form sends no `hb:input`); stopping removes `is-demo` from all four items.@@ -243,7 +244,10 @@ None: leave out the `details.hb-options` block.- **Slow motion:** css (the `ring-in` keyframes and the border transition). `later()` triples each ring's closing-in (Speed), not the 460ms holds.- **Reduced motion:** the demo's rule stays, extended to the `is-demo` rings: the ring shows at once, without closing in. Show me still moves the ring from item to item.- **Stage font:** site font. `.focusable`, `.form-btn` and `.form-link` get `font-family:inherit` in place of `monospace`.-- **Stage:** the form stays: Full name, Country, Submit Form and Forgot password?. The step strip above it (`.tab-indicator`, "1 · Text" to "4 · Link") goes, because it is a readout of where the focus is. The field labels become 11px; their grey is `--ui-muted`. `.form` gets `gap:12px` and the stage `padding:16px`. The ring-style rules (specificity 0,3,0) already beat the site's focus ring. `hb-dots`: yes. Measured: 286px on phones and laptops.+- **Stage:** the form stays: Full name, Country, Submit Form and Forgot password?. The step strip above it (`.tab-indicator`, "1 · Text" to "4 · Link") goes, because it is a readout of where the focus is. The field labels become 11px; their grey is `--ui-muted`. `.form` gets `gap:12px` and the stage `padding:16px`. `hb-dots`: yes. Measured: 288px on phones and laptops (a 254px form, 32px of padding and 2px of border).+ - **The ring-style rules need the `.stage` prefix.** Written `.stage .ring-solid .focusable:focus-visible` (and the same for `.is-demo` and the other three styles), they are 0,4,0. Without the prefix they are 0,3,0 and tie with the site's inward stage rule (`.hb-page .stage :focus-visible`), which comes later in the shared stylesheet and wins, so a real Tab press would draw the ring at `outline-offset:-3px` whatever Ring gap says.+ - **The 260px short stage.** The form needs 242px. `@media(min-width:601px) and (max-height:620px){.stage{padding:5px 8px 11px}.form{gap:8px}}` gives up spacing only; the items keep their 44px. The bottom keeps 11px because the widest ring (Thick ring, Large gap, Wide style: a 4px outline 6px out, and a shadow reaching 11px) would otherwise be cut by the stage's edge under the last item; the top has 14px to spare.+ - **iOS zoom.** The fields are 12px, and iOS zooms the whole page when a text field or menu under 16px gets focus. `@media(pointer:coarse){input.focusable,select.focusable{font-size:16px}}` makes them 16px on touch screens; their 44px height stays.**Main settings**@@ -271,7 +275,7 @@ None: leave out the `details.hb-options` block.- **README What it is:** rewritten:- > A focus ring is the outline that shows which item the keyboard is on. Animating it, so the ring closes in around each item as you press Tab, makes every move easier to follow. It shows only when the keyboard is used, so people who click with a mouse do not see rings appear.+ > A focus ring is the outline that shows which item the keyboard is on. Animating it, so the ring closes in around each item as you press Tab, makes every move easier to follow. It shows when the keyboard is used (and when you click into a text field, since you type there next), so people who click buttons and links with a mouse do not see rings appear.- **README Key parameters:**