Skip to Content

Error State

A centred message for a failed load, with an optional retry.

import { ErrorState } from "@dapplelight/signet-ui/components/error-state"

export function Demo() {
  return <ErrorState message="We couldn't load your invoices." onRetry={() => {}} />
}

Installation

npm i @dapplelight/signet-ui

Usage

import { ErrorState } from "@dapplelight/signet-ui/components/error-state"
import { refetch } from "./actions"

<ErrorState message="Could not load invoices." onRetry={refetch} />

Examples

Retry

import { useState } from "react"
import { ErrorState } from "@dapplelight/signet-ui/components/error-state"

export function Demo() {
  const [tries, setTries] = useState(0)
  return (
    <ErrorState
      message={`Request timed out. Retried ${tries} time${tries === 1 ? "" : "s"}.`}
      onRetry={() => setTries((n) => n + 1)}
    />
  )
}

Without message

import { ErrorState } from "@dapplelight/signet-ui/components/error-state"

export function Demo() {
  return <ErrorState />
}

API Reference

ErrorState

Renders with role="alert". The heading and button text come from the labels provider (somethingWentWrong, tryAgain).

PropTypeDefaultDescription
messagestringnoneDetail under the heading.
onRetry() => voidnoneShows a retry button when set.