Reroute

Animated Failover Diagram for React

Your hub at the top, wired by a cable to one option on a wheel of many. Requests run down the cable into the live option. Pick another, spin the wheel or arrow to it, and the cable lifts out, the wheel turns it round to the socket and the cable drops in with a click. When the live option goes down, its request bounces back up the cable and the wheel turns on to the next healthy one, then back again once it recovers.

  • Interaction
  • AI
  • Diagram

Uses clsx, tailwind-merge

Inspired by Agno

Open in ChatGPTOpen in Claude
flowtrue
flowDuration1200ms
speed1.00×
<Reroute />

The demo follows as you drag.

Fernwood gateway

One endpoint, six model providers

All providers up

  1. Watching for outages…
Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Reroute: Your hub at the top, wired by a cable to one option on a wheel of many. Requests run down the cable into the live option. Pick another, spin the wheel or arrow to it, and the cable lifts out, the wheel turns it round to the socket and the cable drops in with a click. When the live option goes down, its request bounces back up the cable and the wheel turns on to the next healthy one, then back again once it recovers.
This demo, Model Failover: An inference gateway over six model providers that drills its own outages: the live provider drops, the wheel reroutes, and it turns back once the provider recovers. Take one down yourself.

1. Install it:
   npx shadcn@latest add @keyframeui/reroute-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/reroute-demo.json instead.)
   It adds the demo, components/reroute-demo.tsx, and the component, components/ui/reroute.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Reroute> on its own.

3. These props set its feel. Change them before you change the file:
   - flow (default true): Run requests down the cable as small comets while an option is plugged in.
   - flowDuration (default 1200): How long each comet takes to run down the cable, in ms.
   - speed (default 1): How fast a reroute plays, as a multiple of the default pace: the cable lifting out and dropping back in, the wheel turning, the socket's click, a failed request bouncing and the name changing. `2` is twice as fast.

4. Don't change, in components/ui/reroute.tsx:
   - Every moving part animates by transform and opacity only, through WAAPI and inline styles the engine writes; React draws the first layout in `cqw` and never re-renders per frame.
   - A turn's keyframes are sampled round the rim, and a tile crossing the far side gets two hidden frames at one offset, so nothing sweeps back across the wheel.
   - The JS `bezier` curves match the WAAPI easings, so a new pick takes the wheel up mid-flight from exactly where it is.
   - The cable lifts before the wheel turns and lowers `drop.lead` before the turn ends, following the new option in; comets run only while it's seated, on screen and on a visible tab.
   - Under reduced motion there's no turning, cable or comets: the wheel jumps and the name cross-fades. The options stay a `radiogroup` whose live option holds the only tab stop.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/reroute.md

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/reroute.tsx and installs clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/reroute

Examples

Finished sections built with Reroute. Each one installs whole, with the component included.

Deploy Regions

A new project's region picker in electric blue: spin the wheel, press a region or use the arrow keys.

New project · Step 2 of 3

Where should it run?

Spin the wheel or use the arrow keys. Latency is measured from your browser.

Replicas follow in the two nearest regions.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Reroute: Your hub at the top, wired by a cable to one option on a wheel of many. Requests run down the cable into the live option. Pick another, spin the wheel or arrow to it, and the cable lifts out, the wheel turns it round to the socket and the cable drops in with a click. When the live option goes down, its request bounces back up the cable and the wheel turns on to the next healthy one, then back again once it recovers.
This demo, Deploy Regions: A new project's region picker in electric blue: spin the wheel, press a region or use the arrow keys.

1. Install it:
   npx shadcn@latest add @keyframeui/reroute-regions-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/reroute-regions-demo.json instead.)
   It adds the demo, components/reroute-regions-demo.tsx, and the component, components/ui/reroute.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Reroute> on its own.

3. These props set its feel. Change them before you change the file:
   - flow (default true): Run requests down the cable as small comets while an option is plugged in.
   - flowDuration (default 1200): How long each comet takes to run down the cable, in ms.
   - speed (default 1): How fast a reroute plays, as a multiple of the default pace: the cable lifting out and dropping back in, the wheel turning, the socket's click, a failed request bouncing and the name changing. `2` is twice as fast.

4. Don't change, in components/ui/reroute.tsx:
   - Every moving part animates by transform and opacity only, through WAAPI and inline styles the engine writes; React draws the first layout in `cqw` and never re-renders per frame.
   - A turn's keyframes are sampled round the rim, and a tile crossing the far side gets two hidden frames at one offset, so nothing sweeps back across the wheel.
   - The JS `bezier` curves match the WAAPI easings, so a new pick takes the wheel up mid-flight from exactly where it is.
   - The cable lifts before the wheel turns and lowers `drop.lead` before the turn ends, following the new option in; comets run only while it's seated, on screen and on a visible tab.
   - Under reduced motion there's no turning, cable or comets: the wheel jumps and the name cross-fades. The options stay a `radiogroup` whose live option holds the only tab stop.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/reroute.md

Email Relays

An email API's relays with a switch each. Pause relays and the mail moves on to whichever is still up.

Delivery relays

Pause a relay and mail moves to the next one.

18,204

sent today

  • PelicanSending
  • CourierPaused
  • HarborStanding by
  • BeaconStanding by
Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Reroute: Your hub at the top, wired by a cable to one option on a wheel of many. Requests run down the cable into the live option. Pick another, spin the wheel or arrow to it, and the cable lifts out, the wheel turns it round to the socket and the cable drops in with a click. When the live option goes down, its request bounces back up the cable and the wheel turns on to the next healthy one, then back again once it recovers.
This demo, Email Relays: An email API's relays with a switch each. Pause relays and the mail moves on to whichever is still up.

1. Install it:
   npx shadcn@latest add @keyframeui/reroute-email-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/reroute-email-demo.json instead.)
   It adds the demo, components/reroute-email-demo.tsx, and the component, components/ui/reroute.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Reroute> on its own.

3. These props set its feel. Change them before you change the file:
   - flow (default true): Run requests down the cable as small comets while an option is plugged in.
   - flowDuration (default 1200): How long each comet takes to run down the cable, in ms.
   - speed (default 1): How fast a reroute plays, as a multiple of the default pace: the cable lifting out and dropping back in, the wheel turning, the socket's click, a failed request bouncing and the name changing. `2` is twice as fast.

4. Don't change, in components/ui/reroute.tsx:
   - Every moving part animates by transform and opacity only, through WAAPI and inline styles the engine writes; React draws the first layout in `cqw` and never re-renders per frame.
   - A turn's keyframes are sampled round the rim, and a tile crossing the far side gets two hidden frames at one offset, so nothing sweeps back across the wheel.
   - The JS `bezier` curves match the WAAPI easings, so a new pick takes the wheel up mid-flight from exactly where it is.
   - The cable lifts before the wheel turns and lowers `drop.lead` before the turn ends, following the new option in; comets run only while it's seated, on screen and on a visible tab.
   - Under reduced motion there's no turning, cable or comets: the wheel jumps and the name cross-fades. The options stay a `radiogroup` whose live option holds the only tab stop.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/reroute.md

Props

items Required

TypeRerouteItem[]

The options round the wheel, in order, as { id, name, icon, detail? }. icon is an inline SVG or an <img> centered on the tile; name and detail (a latency, a region) show under the socket while it's live. The option after the live one sits to its right.

hub

TypeReact.ReactNode

What sits in the hub tile at the top: your mark, drawn in white on the accent. Defaults to a small fork glyph.

value

Typestring

The option you want routed to, when you control it. If it's down, the wheel sits on the next healthy one until it's back.

defaultValue

Typestring

The option routed to first, when you don't control it. Defaults to the first item.

onValueChange

Type(id: string) => void

Called when the visitor picks an option (a press, the arrow keys or a spin), or autoplay moves on.

down

Typestring[]

Ids of options that are down. They dim, wear a dot and are skipped; if the live one goes down, its request bounces and the wheel reroutes to the next healthy option.

onRoute

Type(id: string | null, reason: "pick" | "autoplay" | "failover" | "recover") => void

Called whenever the live option changes, with why: a pick, autoplay, an outage, or the picked option coming back. id is null when every option is down.

autoplay

Typeboolean | numberDefaultfalse

Turn to the next healthy option on a timer: true for every 2.8s, or a number of ms. It waits while the pointer is over it, while it has focus and off screen.

flow

TypebooleanDefaulttrue

Run requests down the cable as small comets while an option is plugged in.

flowDuration

TypenumberDefault1200

How long each comet takes to run down the cable, in ms.

speed

TypenumberDefault1

How fast a reroute plays, as a multiple of the default pace: the cable lifting out and dropping back in, the wheel turning, the socket's click, a failed request bouncing and the name changing. 2 is twice as fast.

label

TypestringDefault"Route"

Accessible name for the group of options, such as "Model provider".

className

Typestring

Extra classes for the root. Set the accent (hub, cable, socket) with --reroute-accent (#ff3b1f, #ff5a3c in dark), the color of a down option's dot and bounce with --reroute-down (ink) and the wheel's height with --reroute-height (clamp(15rem, 54cqw, 21rem)).