Generation Error
Where the reply would have been: what happened in plain words for each reason (timeout, rate limit, network, blocked, server), the prompt kept, Retry with its own loading state, Edit prompt, and an error id to copy.
The decision inside it
Retry waits for the rate limit
A rate limit counts down and enables Retry when it reaches zero. A Retry button that fails again for the next 30 seconds teaches people never to press it.
When to use it
Use Generation Error where an AI reply failed: it says what happened for the reason you pass, keeps the prompt, and offers Retry (with a countdown for rate limits) and Edit. Return a promise from onRetry to show the loading state.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Layro's Generation Error for this.
Install it: npx shadcn@latest add @layro/generation-error
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/generation-error.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @layro registry with your CLI token: see the Namespaced tab.
Usage
import { GenerationError } from "@/components/ui/generation-error";
export function ReplyError({ prompt, resend, edit }: { prompt: string; resend: () => Promise<void>; edit: () => void }) {
return <GenerationError reason="rate_limit" retryAfter={30} prompt={prompt} onRetry={resend} onEdit={edit} errorId="gen_8f2c41a9" />;
}API reference
“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Prop | Type | Notes |
|---|---|---|
reason | GenerationErrorReason | Why it failed. Picks the title and description. Default "unknown". |
title | string | Overrides the title for the reason. |
description | string | Overrides the description for the reason. |
prompt | string | The prompt that failed, shown as a quote so nothing is lost. |
retryAfter | number | Seconds until a retry can work. Counts down and enables Retry at zero. |
onRetry | () => void | Promise<unknown> | Send the same prompt again. Return a promise to show a loading state while it runs. |
onEdit | () => void | Put the prompt back in the composer to change it. |
variant | "card" | "inline" | "card" stands in for the reply; "inline" is one line under a message. Default card. |
errorId | string | A reference for support, copyable. |
Dependencies
npm packages
clsxlucide-reacttailwind-mergeLayro foundations, installed alongside it
layro-themeStates
All of them are drawn by the component. None is left for you to design.
- Timeout
- Rate limit
- Network
- Blocked
- Server
- Retrying
- Inline
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances
Lifetime access
Every component, and everything we ship next.
- All 232 components, source included
- Every template, and everything released after you buy
- shadcn CLI or download — React 18/19, Tailwind v4
- One payment. No subscription.