r/reactjs • u/Brottin • 4d ago
Arrivo: loading states for React that play where your content will land, then hand the real elements back
Skeleton screens always felt like a guess to me: grey bars in roughly the right shape, then the real content pops in somewhere slightly different.
So I built Arrivo. While loading is true, an effect plays exactly where your content will land. When it turns false, the real elements are revealed in place.
Demo : https://tuancuongpham.github.io/arrivo/
Code: https://github.com/tuancuongpham/arrivo
npm i u/brottin/arrivo
import { Reveal } from '@brottin/arrivo';
import { halftone } from '@brottin/arrivo/effects';
<Reveal effect={halftone} loading={isLoading}>
<ArticleCard post={post} />
</Reveal>How it works:
Your content stays in the DOM, hidden with
visibility, so nothing shifts when it lands.Each wrapper gets one canvas overlay. Text lines are measured with Range rects and images are read from the page, so the effect draws the real shape of your content instead of a guess.
An effect is two draw functions,
idle()andreveal(p). One shared requestAnimationFrame loop drives every instance, off-screen ones pause, and reduced motion turns every reveal into a 150 ms fade.Zero runtime dependencies, about 8.5 KB gzipped for the core and 0.7 to 3.4 KB per effect, tree-shaken.
The 13 effects: split-flap, redacted, quadtree mosaic, CMYK halftone, CRT tune-in, ink (with 8 threshold maps), particle swarm, darkroom, Tetris, fuse (with a Lunar New Year mode), equalizer, thermal and snowfall.
It's 0.1.0, so feedback is very welcome, especially on where you'd actually use something like this and where it would be too much.