Fable.Lit / browser-native animation

Hydrated. Then animated.

View the source on GitHub ↗

Switch the theme for a page-wide crossfade. Remove a basket item to see rows glide into place, then reset to replay. Try the counter, palette and panel too.

Animations follow your reduced-motion preference. Browsers without View Transitions still update normally.

Theme

The page is light, and was already when it arrived.

How the hydration demo works

The six cards below arrived as HTML from .NET. Each is an independent Elmish program that adopts its own markup when the script loads: the nodes stay, and the loops never touch each other. The third arrived inside a shadow root of its own, styles included, which is why the page's card styling stops at its edge. The fourth is the other way round: its shadow root is only a frame with slots, and the card it frames is ordinary light DOM, styled by this page like the two at the top. The last two share one piece of state that only the server knows in time to matter — whether you asked for dark — so it is written into the page below them, and into the html element before any of this was sent. Both islands start from the value their markup was rendered from, neither knows about the other, and the page is never briefly the wrong colour. A seventh card arrived empty, because it is not an island at all: it is a custom element, the browser builds it, and it reads that same state from the store.

Counter

Value: 0

Basket

Remove a row and watch the others move into place.

Crate 40
Pallet 2
Drum 7

Total: 49 in 3 lines.

Panel

Step 1 of 3: measure

Elsewhere on the page

This card was not told about the switch. It reads the same store, so it says light too.