Five forecasts are set as rows of type. Point at one and the other four dim, a card of that day's sky opens off the list's left edge, and the word itself takes the weather: snow settles on the tops of its letters, rain lands on them and runs down the strokes, fog drifts through and softens them, a storm flickers them with its flashes and the sun sweeps a warm glint across.
With the keyboard, tab to a row and the card follows focus. Escape closes the card. On touch, tap a row to pick it and tap the space around the list to close it.
How it works
The card is one card. It opens on the first row and closes when the pointer leaves the list. In between it rides from row to row on a critically damped spring, so it never overshoots, while its sky slides through it in the direction of travel.
The sky has a soft leading edge. Each sky's layer overhangs the card and fades out over the overhang, so two skies passing each other never meet in a hard seam.
The icon swaps in place. It shrinks out where it is and the next one grows in from a quarter size and a slight blur, with no bounce.
The letters are measured, not guessed. The row's text is drawn to a canvas in its own font and read back as pixels. That gives the top edge of the ink in every column, which is what snow lands on and rain runs down.
One frame loop drives all of it. The word effects and the storm's flashes share a loop that stops when the last word has let its weather go, and nothing renders per frame.
Letting go sheds the weather. Snow is shaken off in clumps and rain is thrown from the letters, with a small shake on the word.
Reduced motion drops the weather and the card's travel: the card fades in beside the row, the sky crossfades in place, and the blobs hold still.
The card and the canvas are decoration and are inert; the rows are real buttons, and the line under the list is a polite live region that announces the day you land on.
Installation
CLIManual
pnpmnpmyarnbun
pnpm dlx shadcn@latest add @uitopia/forecast-list
Copy
Usage
Copy
import ForecastList from "@/components/ui/forecast-list";<ForecastList />;
The component draws its own stage and sizes its type from the stage's width. Pass className to change the wrapper, hint to change the line under the stage (or false to remove it), restLine to change the line shown while no row is picked, and forecasts to supply your own rows. A forecast is a name, a line, an icon and a colour set, defined by the Forecast type in forecasts.ts; its kind chooses which weather the word takes on. The sky colours keep their own palette, since the sky is the subject of each card.