components / conversation
Error Notice
A failed reply with a plain explanation and an optional retry.
previewerror-notice
Error
Something went wrong
The model did not respond in time. Your message was not lost.
install
bash
npx shadcn@latest add https://turnui.xyz/r/error-notice.jsonprops
| prop | type | default | description |
|---|---|---|---|
| title | string | "Something went wrong" | Short headline. |
| message | ReactNode | — | What happened, in plain words. |
| onRetry | () => void | — | Shows a retry button when set. |
| retrying | boolean | false | Disables the button and shows "Retrying…". |
| retryLabel | string | "Retry" | Button text. |
accessibility
- Announced immediately as role="alert".
- The error is stated in text; the red edge is only decoration.
- While retrying, the button stays focusable but inert, so keyboard focus is not lost. Keep the notice mounted until the retry produces output.
source
tsx
import * as React from "react";
import { cn } from "@/lib/utils";
import { Button } from "./button";
/** A failed reply, with an optional retry. Keep it mounted until the retry produces output so focus is not lost. */
export function ErrorNotice({
title = "Something went wrong",
message,
onRetry,
retrying = false,
retryLabel = "Retry",
className,
}: {
title?: string;
/** What happened, in plain words. */
message?: React.ReactNode;
/** Shows a retry button when set. */
onRetry?: () => void;
/** Disables the button and shows "Retrying…" while the retry is in flight. */
retrying?: boolean;
retryLabel?: string;
className?: string;
}) {
return (
<div role="alert" className={cn("relative overflow-hidden rounded border bg-muted/20 py-3 pl-4 pr-3", className)}>
<span aria-hidden className="absolute inset-y-0 left-0 w-0.5 bg-red-500" />
<div className="font-mono text-[11px] uppercase tracking-wider text-red-700 dark:text-red-400">Error</div>
<div className="mt-1.5 text-sm font-medium">{title}</div>
{message && <p className="mt-0.5 text-sm text-muted-foreground">{message}</p>}
{onRetry && (
<Button size="sm" variant="outline" className="mt-3" onClick={onRetry} disabled={retrying} focusableWhenDisabled>
{retrying ? "Retrying…" : retryLabel}
</Button>
)}
</div>
);
}