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.

fix: Dynamic Island (04.41): in forced colors the focus ring keeps its own color, so it stays visible in light themes

matin3a9aa172df0f
diff --git a/animations/04-micro-interactions/dynamic-island/README.md b/animations/04-micro-interactions/dynamic-island/README.md
index ccae8dc1..6e1ad700 100644
--- a/animations/04-micro-interactions/dynamic-island/README.md
+++ b/animations/04-micro-interactions/dynamic-island/README.md
@@ -60,7 +60,7 @@ function spring(z) {
}
```
-The same transition runs whichever two shapes it goes between, so picking another notification while one is open morphs the card directly. The clip also decides where the button can be pressed, so the small pill gets a larger invisible target (124 × 48px). The button is the whole box, so its own outline would not follow the shape: the focus ring is a second clipped layer 3px larger than the shape, behind it. In forced-colors mode the phone keeps its own colors and the ring takes the system highlight color; the outline stays, transparent, as a fallback where the ring cannot keep its color. While a card is open the status bar fades out, and a polite live region reads out the message when the visitor opened it, not when Show me did. On larger screens the content also comes into focus from a slight blur; phones skip the blur. Under reduced motion a resting pill stays in place and the card fades in over it at its own size, so nothing grows or moves. A card only changes while the shape is fully faded: picking another notification fades the open card (or one still fading out after a close) out, puts the new content and size in place while it is hidden, and fades it in again. The picked notification is kept at once, so a press that calls such a switch off halfway still opens the picked card next time, and the focus ring is a hollow outline there, so nothing of it shows through a fading card.
+The same transition runs whichever two shapes it goes between, so picking another notification while one is open morphs the card directly. The clip also decides where the button can be pressed, so the small pill gets a larger invisible target (124 × 48px). The button is the whole box, so its own outline would not follow the shape: the focus ring is a second clipped layer 3px larger than the shape, behind it. In forced-colors mode the phone keeps its own colors, and so does the ring: a system color such as the highlight is dark in light themes and would vanish against the dark phone, while the ring's own orange stands out against it in every theme. The outline stays, transparent, as a fallback where the ring cannot keep its color. While a card is open the status bar fades out, and a polite live region reads out the message when the visitor opened it, not when Show me did. On larger screens the content also comes into focus from a slight blur; phones skip the blur. Under reduced motion a resting pill stays in place and the card fades in over it at its own size, so nothing grows or moves. A card only changes while the shape is fully faded: picking another notification fades the open card (or one still fading out after a close) out, puts the new content and size in place while it is hidden, and fades it in again. The picked notification is kept at once, so a press that calls such a switch off halfway still opens the picked card next time, and the focus ring is a hollow outline there, so nothing of it shows through a fading card.
## Key parameters
| Parameter | Default | Effect |
@@ -75,7 +75,7 @@ The same transition runs whichever two shapes it goes between, so picking anothe
- **Clip the content with the shape**: put the content inside the clipped layer, not beside it. A shrinking clip outruns a fade, so content laid over the shape shows on the page around it for a moment at the start of every close.
- **Leave room for the bounce**: a spring goes past the target size, and a clip cannot show more than its box. Make the box larger than the largest card by the overshoot, or the corners turn square for a moment at the peak.
- **`linear()` support**: the spring curve needs `linear()` (Chrome and Edge 113, Firefox 112, Safari 17.2). Check with `CSS.supports()` and fall back to a `cubic-bezier()` that overshoots about as far: `cubic-bezier(.3, 1.4, .5, 1)` goes about 5% past the end and `cubic-bezier(.3, 1.75, .45, 1)` about 16%.
-- **Hit area and focus**: the clip also clips pointer hits. Give the small pill a target of at least 44 × 44px, draw the focus ring as a clipped layer of its own, and in forced-colors mode give that ring the `Highlight` system color (with `forced-color-adjust: none`), keeping a transparent outline as a fallback.
+- **Hit area and focus**: the clip also clips pointer hits. Give the small pill a target of at least 44 × 44px and draw the focus ring as a clipped layer of its own. In forced-colors mode, if the island keeps its own colors (`forced-color-adjust: none`), let the ring keep its own color too: its contrast is then measured against colors you know, while a system color such as `Highlight` is dark in light themes and can vanish against a dark island. Keep a transparent outline as a fallback.
- **Accessibility**: make the pill a real `<button>` with `aria-expanded`, announce a new message in a polite `role="status"` region, never move the focus into the card, and let Escape close it.
- **Framer Motion**: `<motion.div layout style={{ borderRadius: 30 }} />` animates a size change with transforms and keeps the corner radius right; give the children `layout` too, so they are scaled back and their text does not stretch.
- **GSAP**: the Flip plugin records the pill's box and animates to the card's; `gsap.to(shape, { clipPath: "inset(0% 6% 14% 6% round 30px)", ease: "elastic.out(1, 0.6)" })` animates the clip itself with a bounce.
diff --git a/animations/04-micro-interactions/dynamic-island/index.html b/animations/04-micro-interactions/dynamic-island/index.html
index c6dba242..80e7031e 100644
--- a/animations/04-micro-interactions/dynamic-island/index.html
+++ b/animations/04-micro-interactions/dynamic-island/index.html
@@ -76,8 +76,9 @@
.isl.still,.isl.still *{transition:none!important}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
/* Larger screens: the content comes into focus as it fades in (a phone skips the blur) */
@media(min-width:601px) and (min-height:501px){.c{filter:blur(6px)}}
- /* Forced colors: the phone keeps its own colors (a black pill on black would vanish), and the focus ring takes the system highlight */
- @media(forced-colors:active){.screen,.shape,.pill,.ring{forced-color-adjust:none}.ring,.pill{--ui-accent:Highlight}}
+ /* Forced colors: the phone keeps its own colors (a black pill on black would vanish), and so does its focus ring: a system color
+ is dark in light themes, but the ring's own color stands out against the dark phone in every theme */
+ @media(forced-colors:active){.screen,.shape,.pill,.ring{forced-color-adjust:none}}
/* Reduced motion: a resting pill shows; a card fades in over it and out at its own size (a new one after the open one fades out).
The focus ring is a hollow outline here, sized by the same values, so nothing of it shows through a fading card. */
@media(prefers-reduced-motion:reduce){