Skip to content
Product block

Error State With Retry

Failed-to-load panel with a visible retry, a copyable error reference and the stack tucked behind a disclosure.

131 lineslucide-reactAdded 8 Aug 2026Updated 2 Sept 2026
  • error
  • retry
  • failed
  • exception
  • fallback

What's included

  • components/error-state-retry.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add error-state-retry

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Start a page with this section — add more, order them, and leave with the page source.

Preview

Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.

Source

components/error-state-retry.tsx
'use client'

/**
 * <ErrorStateRetry> — a failed-to-load panel that can actually recover.
 *
 * What separates a usable error state from a dead end:
 *
 *  - A retry that shows it is retrying. A button that silently re-fires and
 *    fails again reads as broken, so the busy state is explicit.
 *  - The technical detail behind a <details>, not on the surface. Users do
 *    not want a stack trace; the one person who does need it — the
 *    colleague they forward the screenshot to — needs it to be there.
 *  - A copyable error id. "Something went wrong" with no reference is
 *    unactionable for support.
 *
 * `role="alert"` announces the failure immediately, since a section that
 * silently swaps from spinner to error is invisible to a screen reader.
 */

import * as React from 'react'
import { RefreshCw, CircleAlert, Copy, Check } from 'lucide-react'

export interface ErrorStateRetryProps {
  title?: string
  description?: string
  /** Shown behind a disclosure — stack, response body, whatever helps. */
  detail?: string
  errorId?: string
  onRetry?: () => Promise<void>
  supportHref?: string
  className?: string
}

export function ErrorStateRetry({
  title = 'We could not load this',
  description = 'The request failed before it finished. Your data is safe — nothing was changed.',
  detail = 'GET /api/v1/projects → 503 Service Unavailable\n  upstream: projects-api\n  duration: 30012ms (timeout)',
  errorId = 'err_7f3a92c4b81e',
  onRetry,
  supportHref,
  className = '',
}: ErrorStateRetryProps) {
  const [busy, setBusy] = React.useState(false)
  const [copied, setCopied] = React.useState(false)

  async function retry() {
    if (busy) return
    setBusy(true)
    try {
      await onRetry?.()
    } finally {
      setBusy(false)
    }
  }

  async function copyId() {
    if (!navigator.clipboard) return
    await navigator.clipboard.writeText(errorId)
    setCopied(true)
    window.setTimeout(() => setCopied(false), 1600)
  }

  return (
    <div
      role="alert"
      className={`flex flex-col items-center justify-center rounded-2xl border border-border/60 bg-card/60 px-6 py-12 text-center ${className}`}
    >
      <span className="inline-flex h-12 w-12 items-center justify-center rounded-2xl bg-destructive/10 text-destructive">
        <CircleAlert className="h-6 w-6" />
      </span>

      <h2 className="mt-5 text-lg font-bold tracking-tight">{title}</h2>
      <p className="mx-auto mt-2 max-w-md text-sm text-muted-foreground">{description}</p>

      <div className="mt-6 flex flex-wrap items-center justify-center gap-3">
        <button
          type="button"
          onClick={retry}
          disabled={busy}
          className="inline-flex items-center gap-2 rounded-xl bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-60"
        >
          <RefreshCw
            aria-hidden
            className={`h-4 w-4 ${busy ? 'motion-safe:animate-spin motion-reduce:[animation-duration:1.6s]' : ''}`}
          />
          {busy ? 'Retrying' : 'Try again'}
        </button>

        {supportHref ? (
          <a
            href={supportHref}
            className="rounded-xl border border-border/60 bg-background px-4 py-2.5 text-sm font-medium transition-colors hover:bg-muted"
          >
            Contact support
          </a>
        ) : null}
      </div>

      {errorId ? (
        <div className="mt-5 flex items-center gap-2 text-xs text-muted-foreground">
          <span>Reference</span>
          <code className="rounded bg-muted px-1.5 py-0.5 font-mono">{errorId}</code>
          <button
            type="button"
            onClick={copyId}
            aria-label="Copy error reference"
            className="rounded p-1 transition-colors hover:bg-muted hover:text-foreground"
          >
            {copied ? (
              <Check aria-hidden className="h-3.5 w-3.5 text-emerald-500" />
            ) : (
              <Copy aria-hidden className="h-3.5 w-3.5" />
            )}
          </button>
        </div>
      ) : null}

      {detail ? (
        <details className="mt-6 w-full max-w-lg text-start [&_summary::-webkit-details-marker]:hidden">
          <summary className="cursor-pointer list-none text-center text-xs font-medium text-muted-foreground transition-colors hover:text-foreground">
            Technical details
          </summary>
          <pre className="mt-3 whitespace-pre-wrap break-words rounded-xl bg-muted/60 p-3 text-start font-mono text-xs text-muted-foreground">
            {detail}
          </pre>
        </details>
      ) : null}
    </div>
  )
}

Before you paste

  • Styling is Tailwind utility classes on semantic tokens (bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.
  • Install: npm i lucide-react
  • Every prop has a default, so it renders standalone before you wire it up.

Where it goes

Drop it at components/error-state-retry.tsx and import it where you need the section:

import { ErrorStateRetry } from '@/components/error-state-retry'

Customize

2 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.

Props

Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.

PropTypeDefault
titlestring'We could not load this'
descriptionstring—
detailShown behind a disclosure — stack, response body, whatever helps.string—
errorIdstring'err_7f3a92c4b81e'
onRetry() => Promise<void>—
supportHrefstring—
classNamestring''

Not using React?

The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.

This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.

error-state-retry.html
<!--
  Error State With Retry — markup from the Hoverlab catalog.

  This is the block rendered once to HTML and wrapped as a component
  file. It is not a port of the React source: the Tailwind classes carry
  the design, which is the part that took the work, and they are the same
  in every framework.

  This block is interactive in React and the handlers are NOT here.
  Buttons, toggles and menus render in their initial state and do
  nothing until you wire them up.
-->
<div role="alert" class="flex flex-col items-center justify-center rounded-2xl border border-border/60 bg-card/60 px-6 py-12 text-center ">
  <span class="inline-flex h-12 w-12 items-center justify-center rounded-2xl bg-destructive/10 text-destructive">
    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-alert h-6 w-6" aria-hidden="true">
      <circle cx="12" cy="12" r="10"></circle>
      <line x1="12" x2="12" y1="8" y2="12"></line>
      <line x1="12" x2="12.01" y1="16" y2="16"></line>
    </svg>
  </span>
  <h2 class="mt-5 text-lg font-bold tracking-tight">We could not load this</h2>
  <p class="mx-auto mt-2 max-w-md text-sm text-muted-foreground">The request failed before it finished. Your data is safe — nothing was changed.</p>
  <div class="mt-6 flex flex-wrap items-center justify-center gap-3">
    <button type="button" class="inline-flex items-center gap-2 rounded-xl bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-60"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-refresh-cw h-4 w-4" aria-hidden="true"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path><path d="M8 16H3v5"></path></svg>Try again</button>
  </div>
  <div class="mt-5 flex items-center gap-2 text-xs text-muted-foreground">
    <span>Reference</span>
    <code class="rounded bg-muted px-1.5 py-0.5 font-mono">err_7f3a92c4b81e</code>
    <button type="button" aria-label="Copy error reference" class="rounded p-1 transition-colors hover:bg-muted hover:text-foreground">
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy h-3.5 w-3.5" aria-hidden="true">
        <rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect>
        <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path>
      </svg>
    </button>
  </div>
  <details class="mt-6 w-full max-w-lg text-start [&amp;amp;_summary::-webkit-details-marker]:hidden">
    <summary class="cursor-pointer list-none text-center text-xs font-medium text-muted-foreground transition-colors hover:text-foreground">Technical details</summary>
    <pre class="mt-3 whitespace-pre-wrap break-words rounded-xl bg-muted/60 p-3 text-start font-mono text-xs text-muted-foreground">GET /api/v1/projects → 503 Service Unavailable
  upstream: projects-api
  duration: 30012ms (timeout)</pre>
  </details>
</div>
  • This is rendered HTML, not a translation of the React source. The Tailwind classes carry the design and work in any framework.
  • It is one frame: the component in its initial state, with no props applied beyond the defaults.
  • This block is interactive in React — toggles, menus or form state. None of that survives here; the markup is the closed/default state and the handlers are gone. Re-wire them in your own framework.
  • Requires Tailwind, and the design tokens the classes reference (bg-card, text-muted-foreground, and so on). The template ZIPs ship a globals.css that defines them.

What each framework gets across the whole catalog — effects convert properly; this rung is markup.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

Used in these pages

Want the whole screen instead of this one section? Open a page and copy it entire.

7 more blocks in Empty & Error States

All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.

Browse Empty & Error States

Shipping one commercially

Copying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.

  • A commercial licence for everything in the catalog
  • Unlimited bundle exports, in Vue, Svelte and Tailwind
  • One payment — no subscription, nothing to renew
Pro — $79 once

More Empty & Error States blocks

View category
Open the full page for this block

Empty State With Illustration

Two variants — nothing created yet, versus filters excluded everything — because offering "create your first" to a bad filter is the classic bug.

Empty & Error States131 lines1 dep
Open the full page for this block

404 With Search & Suggestions

A 404 that helps: a real GET search form that works without JavaScript, likely destinations, and home as the fallback rather than the headline.

Empty & Error States146 lines1 dep
Open the full page for this block

Shimmer Skeleton List

Loading placeholders with varied row widths and a sweep that is motion-safe only, falling back to a flat tint under reduced motion.

Empty & Error States88 linesNo deps
Open the full page for this block

Permission Denied (403)

The state where the page exists and the account is not on the list: names who can grant access, sends the request, and leaks nothing about what is inside.

Empty & Error States175 lines1 dep
Open the full page for this block

Offline With Queued Changes

Leads with what still works — three edits saved on this device — instead of with the failure. The retry backoff counts down in the open, and the three things that genuinely cannot work offline are named rather than discovered.

Empty & Error States173 lines1 dep
Open the full page for this block

Empty Because of Filters

The empty state for a list emptied by its own filters: every active filter shown as a removable chip ordered by how many results it would restore, with clear-all deliberately second.

Empty & Error States186 lines1 dep
Open the full page for this block

Scheduled Maintenance Window

Planned downtime with a live countdown, an end time in the reader’s timezone, what still works — and a different sentence once the window overruns rather than a negative timer.

Empty & Error States228 lines1 dep