Document Chain
ProThe documents behind one purchase, side by side: request, order, receipt, invoice and payment, each with its status, linked to the next.
Installation#
Usage#
The chain draws the documents you give it and fetches nothing. Map each stage of your lineage to a step, and put a connector between two steps. With Next.js, pass Link through asChild so moving between documents stays client side.
The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.
Have a license? Unlock it here
Anatomy#
import {
DocumentChain,
DocumentChainStep,
DocumentChainLink,
DocumentChainLabel,
DocumentChainId,
DocumentChainMeta,
DocumentChainCount,
DocumentChainConnector,
} from "@/components/ui/document-chain"Compact#
variant="compact" fits the chain on one small line for a table row or a page header. The id stands in for the type, which a screen reader still hears, and the meta drops out.
| Supplier | Amount | Documents |
|---|---|---|
| Ferretería Nadal | €4,905.60 | |
| Papelera Montseny | €612.40 | |
| Transports Ebre | €1,180.00 |
Vertical#
orientation="vertical" stacks the chain for a side panel, with the connectors running down the status marks.
- Done€4,820.00
- Done€4,820.00
- Done3 of 3 lines
- Exception€4,905.60
- Not created yetPayment Not scheduled
States#
A step carries one of six states. current is the stage the purchase is waiting on; the document you are looking at is selected, a separate prop, so the two never compete.
Connectors#
A connector is solid once the step before it is done and dashed while it is not. Mark a link that does not hold, such as an invoice that matches no receipt, as broken.
Several documents#
A partial delivery leaves several receipts, a split bill several invoices. Show the count, and wrap it in a DropdownMenuTrigger to list them.
API reference#
DocumentChain
The ordered list that holds the steps and connectors. On a narrow screen a horizontal chain scrolls sideways with faded edges instead of overflowing the page. Every part accepts className, merged last.
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "compact" | "default" | Stacked label, id and meta, or a single small line for table rows and headers. |
| orientation | "horizontal" | "vertical" | "horizontal" | A strip, or a column for side panels. |
| aria-label | string | "Document chain" | Names the list for a screen reader. Say whose documents they are. |
| Data attribute | Description |
|---|---|
| data-variant | default or compact. |
| data-orientation | horizontal or vertical. |
DocumentChainStep
One stage of the chain. Draws its status mark and lays out whatever parts you put in it.
| Prop | Type | Default | Description |
|---|---|---|---|
| status | "done" | "current" | "pending" | "exception" | "blocked" | "missing" | "pending" | The state of the stage. missing is a stage with no document yet, drawn as a quiet placeholder. |
| selected | boolean | false | The document on screen. Gets a faint chip and sets aria-current="page" on its link. |
| statusLabel | string | - | The status as read by a screen reader. Use it to translate. |
| Data attribute | Description |
|---|---|
| data-status | The stage status. |
| data-selected | Present on the selected step. |
DocumentChainLink
Makes the whole step clickable. Wrap the label and id in it; the status is attached as its description.
| Prop | Type | Default | Description |
|---|---|---|---|
| asChild | boolean | false | Renders your own element, such as a Next.js Link or a button, instead of an a. |
DocumentChainLabel
The document type, such as Order or Invoice. In the compact variant it is read out but hidden when the step has an id.
DocumentChainId
The document number, in tabular numerals.
DocumentChainMeta
A short fact, such as an amount or a date. Hidden in the compact variant.
DocumentChainCount
How many documents the stage holds. On its own it is text; put it in a DropdownMenuTrigger or PopoverTrigger with asChild and it becomes a button that lists them.
| Prop | Type | Default | Description |
|---|---|---|---|
| count* | number | - | The number of documents. |
| children | ReactNode | - | What they are, such as "receipts". Read out but hidden in the compact variant. |
DocumentChainConnector
The line between two steps. Hidden from screen readers.
| Prop | Type | Default | Description |
|---|---|---|---|
| status | "complete" | "pending" | "broken" | - | Solid, dashed, or dashed in red with a break. When unset it is solid after a done step and dashed after any other. |
| Data attribute | Description |
|---|---|
| data-status | The connector status, when set. |