# Fallback chain

A routing order as one path or as the rows a settings page edits: attempts in order, their states in words, and a fixed geometry that holds while the mode changes.

Live variants: https://design.arcadia.is/components/fallback-chain

```tsx
import { FallbackChain } from "@arcadia/ui";
```

```tsx
import { FallbackChain } from "@arcadia/ui";

<FallbackChain
  attempts={TWO}
  title="Route preview"
  route="chat.completions"
  illustrative
  request={{ label: "Request", detail: "chat.completions", meta: "one request" }}
  response={{ label: "Response", meta: "first answer wins" }}
/>
```

## Accessibility

The head is a status region, so a mode change and the count that goes with it are announced. Every attempt is a list item and a focus stop, described by its own detail card; the request, the response and Retry follow in the same tab order. The wires are hidden from assistive technology, and each state stands in words, never in colour alone.

Hover and keyboard focus open the same detail, and the detail stays in the accessibility tree as the node's description. Under reduced motion the running light stands still at its node's end, a reorder jumps, and the active, failed and excluded strokes stay distinct.

Under `presentation="flow"` the region is named Example request route, and the arrows carry the direction, so a reader reads which way each request goes. The tab order, the list items and their descriptions hold.

In rows, every switch and move button carries its model's name, and the status region reads the chain in words.

`illustrative` is not decoration: it tells a reader, in the chip and the status line, that these paths are a preview and not live traffic. Leave it on wherever nothing is being routed right now.

## API reference

### FallbackChain

- `attempts` (`readonly FallbackAttempt[]`, required): The attempts, in the order the router reads them. In `rows`, the chain first, then what is out of it.
- `layout` (`"path" | "rows"`, default `"path"`): `path`: the routing diagram. `rows`: the same order as rows a settings page edits, each with its place in words ("Primary", "Fallback 2"), a switch to include it and arrows to move it, its provider, model, region and note on one line. An attempt `skipped` is excluded and one `unavailable` stands out of the chain with its reason; every other status is in the chain.
- `title` (`string`): The heading ("Route preview", "Fallback order"). Omit where a section already names it.
- `level` (`3 | 4 | 5 | 6`, default `3`): The heading's level in the page.
- `description` (`string`, default `"Models are tried in this order when the first does not answer."`): One line under a `rows` heading.
- `route` (`string`): The route the request takes ("chat.completions", "/v1/messages").
- `mode` (`"failover" | "balance" | "share"`, default `"failover"`): What the preview reads for.
- `request` (`{ label?: string; detail?: string; meta?: string }`): The request's own words, in its node at the start of the chain.
- `response` (`{ label?: string; detail?: string; meta?: string }`): The response's own words, in its node at the end of the chain.
- `illustrative` (`boolean`): Marks the paths as a preview, never live traffic.
- `illustrativeLabel` (`string`, default `"Illustrative preview"`): The preview's words.
- `compact` (`boolean`): Folds provider, model and region into the detail at every width.
- `presentation` (`"flow"`): The parent owns the heading; show the selected example as directional flow.
- `flowRequests` (`readonly string[]`): Ordered account IDs for separate example requests; repeat an ID for multiple requests.
- `details` (`boolean`, default `true`): Each node's detail card, on hover and focus. false where the page beside it already says it all.
- `badges` (`boolean`, default `true`): Each node's corner word: its place, weight or share. false where the order is plain to see.
- `onReorder` (`(ids: string[], movedId: string) => void`): Lets the person put the attempts in order: drag a node up or down, or press Alt+Up or Alt+Down on a focused one. Called once, on drop, with every id in its new order and the one that moved. The chain shows attempts as given: the page reorders them.
- `reorderLabel` (`string`, default `"Drag to reorder"`): The drag's words for assistive tech and the pointer's tip.
- `now` (`number`): The moment "started" is read from (epoch ms).
- `onRetry` (`() => void`): One act when every attempt failed. Omit where a failed chain is not retried here.
- `onToggle` (`(id: string, included: boolean) => void`): `rows`: called when an attempt joins or leaves the chain. Without it and `onReorder`, the rows are a read-out.
- `readOnly` (`boolean`): `rows`: the chain is shown but not changed here.
- `readOnlyReason` (`string`): `rows`: why it cannot be changed here, in the product's words.
- `rootStyle` (`RootStyle<FallbackChainKnobs>`): Typed StyleX override: where the chain sits and its --fallback-chain-* knobs.
- `className` (`string`): An extra class beside the hook, for a page's own CSS.
