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: draw Star Rating's focus ring in forced-colors mode and keep ten stars from wrapping nine and one
matind6865a4a6989
diff --git a/animations/04-micro-interactions/star-rating/README.md b/animations/04-micro-interactions/star-rating/README.mdindex df8af633..88ac6e0a 100644--- a/animations/04-micro-interactions/star-rating/README.md+++ b/animations/04-micro-interactions/star-rating/README.md@@ -38,7 +38,7 @@ The pointer position within a star decides the value — left half rounds to `.5- **Keyboard**: arrow keys step by the current increment, Home clears to 0, End jumps to max. The control must be focusable (`tabindex="0"`) and show a visible focus ring — rating with the mouse only is not enough.- **Don't rely on color alone**: fill is reinforced by the numeric readout below the row so the value survives for colorblind users and greyscale. Never encode the score in hue by itself.- **Half-star handling**: resolve the half from the pointer's horizontal position inside the hovered star, and keep the committed value and the hover preview separate so leaving the row restores the committed rating rather than a stray hover state.-- **Touch targets**: each star box is at least 44×44px and the control uses Pointer Events, so hover-preview and tap-to-commit both work on touch. Hover styling is gated behind `@media (hover: hover)`.+- **Touch targets**: each star box is at least 44×44px and the control uses Pointer Events, so hover-preview and tap-to-commit both work on touch. There is no CSS `:hover` style, so nothing stays painted after a tap; the preview comes from `pointermove`, and a finger's drag asks `document.elementFromPoint` which star is under it.- **Library equivalents**: Framer Motion can drive the pop with a `whileTap`/`animate` scale spring; many form kits (e.g. rating inputs in headless UI libraries) ship the radiogroup semantics so you only style the stars.## See alsodiff --git a/animations/04-micro-interactions/star-rating/index.html b/animations/04-micro-interactions/star-rating/index.htmlindex 61b5de0f..71006488 100644--- a/animations/04-micro-interactions/star-rating/index.html+++ b/animations/04-micro-interactions/star-rating/index.html@@ -26,8 +26,8 @@.stage{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:clamp(18px,4vh,32px);padding:clamp(16px,4vw,40px);background:var(--bg)}/* Rating control */.rate{--gap:clamp(4px,1.5vw,12px);display:inline-flex;flex-wrap:wrap;justify-content:center;max-width:100%;gap:var(--gap);outline:none;touch-action:none}- /* the row draws its own focus look, so it also switches off the site ring (.stage keeps this above body.hb :focus-visible) */- .stage .rate:focus-visible{outline:none;box-shadow:0 0 0 2px var(--bg),0 0 0 4px var(--ui-accent);border-radius:8px}+ /* the row draws its own focus look, so it also hides the site ring (.stage keeps this above body.hb :focus-visible). The outline stays, transparent, for forced-colors mode, which removes box-shadow. */+ .stage .rate:focus-visible{outline:2px solid transparent;box-shadow:0 0 0 2px var(--bg),0 0 0 4px var(--ui-accent);border-radius:8px}.star{position:relative;width:var(--star);height:var(--star);color:var(--ui-muted);cursor:pointer;transition:color var(--fill-dur) ease;-webkit-tap-highlight-color:transparent;transform-origin:center;will-change:transform}.star svg{position:absolute;inset:0;width:100%;height:100%;display:block}.star .half{position:absolute;left:0;top:0;height:100%;width:50%;overflow:hidden;color:var(--ui-accent);opacity:0}@@ -38,8 +38,8 @@.star.pop{animation:pop .42s cubic-bezier(.22,1,.36,1)}.value{font-weight:700;font-size:clamp(20px,5vw,32px)}.value small{font-weight:400;font-size:clamp(11px,1.6vw,14px);color:var(--ui-muted)}- /* More than five stars that cannot share one row wrap into two equal rows, not nine and one */- @media(max-width:845px){.rate.many{max-width:calc(5*var(--star) + 4*var(--gap) + 1px)}}+ /* More than five stars that cannot share one row wrap into two equal rows, not nine and one. Ten stars fit one row from 846px wide, or 864px with classic scrollbars, so the two rows hold up to 870px */+ @media(max-width:870px){.rate.many{max-width:calc(5*var(--star) + 4*var(--gap) + 1px)}}@media(prefers-reduced-motion:reduce){.star{transition:none}.star.pop{animation:none}}</style><link rel="stylesheet" href="../../../assets/css/demo-page.css?v=4">diff --git a/docs/superpowers/plans/2026-09-29-micro-content-part2.md b/docs/superpowers/plans/2026-09-29-micro-content-part2.mdindex a582b642..b2f881f6 100644--- a/docs/superpowers/plans/2026-09-29-micro-content-part2.md+++ b/docs/superpowers/plans/2026-09-29-micro-content-part2.md@@ -935,7 +935,11 @@ None: leave out the `details.hb-options` block.- [Button Press Scale](../button-press-scale/) — a button that shrinks as you press it- [Toggle / Switch Slide](../toggle-switch/) — another small control that animates its state- **README How it works:** unchanged-- **README Production notes:** unchanged+- **README Production notes:** unchanged, except the last sentence of the Touch targets bullet (final fix wave, below)+- **Final fix wave (after the category review):**+ - The row's focus rule keeps a transparent outline: `.stage .rate:focus-visible{outline:2px solid transparent;…}` in place of `outline:none`, as on Segmented Control. Forced-colors mode removes `box-shadow`, so the row had no focus ring there; now the outline shows as a ring in the system colour. Other browsers show the same box-shadow ring as before.+ - The rule that wraps more than five stars into two equal rows now covers windows up to 870px wide (was 845px). With classic scrollbars, ten stars wrapped nine and one between 846px and 863px: they fit one row from 864px (846px without scrollbars), and 870px leaves room for wider scrollbars. Up to 870px ten stars now sit in two rows of five.+ - README Touch targets: the last sentence no longer says hover styling is gated behind `(hover: hover)`, because the page has had no `:hover` rule since 89c0379. It says there is no CSS `:hover` style, so nothing stays painted after a tap, that the preview comes from `pointermove`, and that a finger's drag asks `document.elementFromPoint` which star is under it.- **Category line:** `04.26 · Micro-Interactions`- **Pager:** Previous: Copy to Clipboard (`../copy-to-clipboard/`) · Next: Toast Notification (`../toast-notification/`)