useLoadSequence
Opens every dashboard page the same way: the cards build up top to bottom, then numbers roll, charts draw in and bars fill, with skeletons first only when the data takes longer.
import { useLoadSequence } from "@wunderui/react/charts"Playground
Installation
useLoadSequence comes with WunderUI Core and Pro, in the entry of the package from your plan. See the plans. Then import it:
import { useLoadSequence } from "@wunderui/react/charts"When to use
Use useLoadSequence for
- An app shell with dashboard pages: every page, on the first visit and on every route change, opens with the same build-up.
- A page whose cards should appear in reading order, with numbers, charts and bars starting once their card is there.
- Data that is usually quick but sometimes slow: skeletons only appear after 400 ms, and never flash.
- A replay button on a preview or a demo.
Use something else for
- useInViewAppear for one chart or block that should enter when it scrolls into view. It has no page-level sequence.
- useAnimatedNumber for a single number that counts up on its own, outside a load sequence.
- useChartReload for reloading one chart card with a skeleton and a new draw-in. It does not build up a page.
- Skeleton for the placeholders you draw while the phase is .
- Nothing for a page that should simply be there. The sequence is a statement about the product; leave it out of settings pages and forms.
Signature
Attach the hook to the root of your app shell, spread on it and on the page area, and pass the page's path as so every page opens with the sequence. The shell stays visible; nothing flies in. In , mark each card with and give it (when it appears) and (when its content starts); and turn card positions into rows, columns and delays (strictly top to bottom: a row 40 ms after the last card above it, +25 ms per card, the page built within about half a second). A card appears in place — opacity only, . Provide the phase through : the charts of hold their enter sequence until and start at , and rolls its digits while it is . Bars marked grow from their start edge. Pass while the data loads: if it is still not there after (400 ms) the phase turns — show skeletons in the cards' places — and stays there at least (500 ms) so it never flashes; data that arrives within the delay shows no skeleton.
useLoadSequence(ref: React.RefObject<HTMLElement | null>, options?: LoadSequenceOptions): LoadPhaseParameters
Returns
The phase of the sequence, as a string. Spread it on the root as and hand it down through .
Behavior and motion
The hook decides when each phase starts. Cards, numbers, charts and bars move through the stylesheet and the components that read the phase.
- State
- The phase starts as (or with ). When the shell is on screen and the tab is visible it goes on: straight to when the data is ready, or to first when is still after (400 ms). When the data arrives it waits for the skeleton's minimum time (, 500 ms), calls , becomes , and after the you returned . A new sets it back to in the same render and starts over; re-renders with the same key do nothing.
- What moves
- The shell stays visible and nothing flies in. Each card marked appears in place with only, on , at its . puts the cards in rows (by position on screen, not by DOM order) and turns them into delays: a row starts 40 ms after the last card above it, cards in a row follow 25 ms apart, capped at 450 ms. What is inside starts at : charts draw in, bars marked grow from their start edge, rolls its digits.
- Skeletons
- While the phase is or , the stylesheet hides the children of . Draw skeletons in an element with inside it: that element stays visible. A skeleton marked fades out at its own when the phase is ; set it to its card's delay in .
- Server rendering
- The server renders : is in the HTML and the page area is hidden by the stylesheet, which is what makes the first client render match. and everything else runs in effects. renders its value as plain text on the server. Without JavaScript the page area would stay hidden; add to the page so it shows its content.
- Cleanup
- Unmounting, a new and a change of cancel everything: timers, the animation frame, the and the listener for the tab becoming visible. runs, so the attributes you set in are removed.
- Reduced motion
- Nothing animates and nothing is held back: with the page area is not hidden while , cards, numbers and charts show their final state, and skeletons have no shimmer. The phases still run, so still gets called, with set; return a duration of and no delays. A longer load still shows its skeletons.
Best practices
- Do
Pass the route's path as . Every page then opens with the sequence, and re-renders on the same page never replay it.
- Do
Pass while data loads, and draw skeletons in a element. Data that arrives within 400 ms shows no skeleton at all.
- Do
In return until the cards exist. The hook asks again on the next frames, for up to 2.5 s.
- Do
Honour in : delays of and a of .
- Do
Use tabular figures () on every , so the digit columns keep their width.
- Do
Add the style that shows children, so a page without JavaScript is not empty.
- Don’t
Do not make the shell wait. Sidebar, top bar and background stay visible from the first frame; only the page area builds up.
- Don’t
Do not make the cards fly in, scale or blur. The sequence appears in place with opacity only.
- Don’t
Do not use it for settings pages, forms or anything a person is about to type in. Build-up time is waiting time there.
- Don’t
Do not return a shorter than the content needs. The phase turns when it ends, and then removes your markers; cards still fading in and bars still filling are cut off.
Notes for AI
Give your coding assistant the page or the MCP call instead of screenshots.
get_component("useLoadSequence")import { useLoadSequence } from "@wunderui/react/charts"The full library index for assistants is at /llms.txt.