states
what takes the rows' place while a collection loads, when it fails and when it has nothing to show, and the job's place when nothing's left. each state says what happened in its own words.
bunx --bun shadcn@latest add @mk/statesserves constellation, quanta, trisys, orbit, and artifacts.
example
retry the failed request to load two sample runs. the action restores the collection in place.
the runs did not loadthe request timed out. try the same request again.
the runs did not loadthe request timed out. try the same request again.
loading
still skeleton bars at the 48 px table measure. the named status announces loading once; the bars stay silent.
three rows
the default
five rows
a longer collection
three rows
the default
five rows
a longer collection
the rows take shape before their words arrive
failed
a failure is an alert with its glyph, the reason and a retry when recovery is possible. omit the callback when the reader cannot retry.
the runs did not loadthe request timed out. try the same request again.
this run log is unavailablethe sample log has expired. open another run.
the runs did not loadthe request timed out. try the same request again.
this run log is unavailablethe sample log has expired. open another run.
empty
words can stand alone. add actions when the reader can fill the collection, and use the optional media slot for an app's own figure.
no failed runsfailed runs appear here when a task needs another look.
without actions
nothing needs recovery
nothing queuedadd a task to start the next run.
with actions and media
start from here
no failed runsfailed runs appear here when a task needs another look.
without actions
nothing needs recovery
nothing queuedadd a task to start the next run.
with actions and media
start from here
clear
clear is a claim, so it prints only after a complete read. it takes a JobSheet’s box with no paper: the sentence starts where the cue does, and the reason and the door land where the why and the primary do. the panel holds the height of the work that’s gone at every width, so its edge doesn’t jump when the last thing clears.
the sentence prints as large as its rows hold it: display at a full panel, hero below it, and a smaller step only when the words need one. its lines fill from the first.
parts
LoadingState- rows at the table’s height, read out once.
rowsandlabelset how many and what’s loading. FailedState- the failed glyph, what failed and why. pass
onRetrywhen the reader can try again. EmptyState,EmptyStateMedia,EmptyStateText,EmptyStateActions- an optional figure, what’s missing and how to fill it.
ClearState- the job sheet’s box with no paper. print it in the job’s place, right after what stands over it, and name it with
aria-labelledbyand the title’sid. ClearStateTitle- the claim, one sentence with its full stop. an
h1untilrendersays otherwise. ClearStateReason- what makes it true, in one sentence.
ClearStateDoor- the way to everything that didn’t count.