Docyrus

ErrorState

Error display with variant-specific messaging, retry actions, and expandable error details.

iOSAndroid
Preview ErrorState on your device

Scan with Expo Go

Download Expo Go, then scan the QR code to preview native components.

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-error-state

Usage

import { ErrorState } from '@/components/docyrus-native/error-state';

<ErrorState variant="network" onRetry={() => refetch()} />

<ErrorState
  variant="server"
  errorCode={500}
  errorMessage="Internal Server Error: Connection refused at db:5432"
  onRetry={() => refetch()}
  onBack={() => navigation.goBack()}
/>

API Reference

PropTypeDefaultDescription
variant'default' | 'network' | 'server' | 'timeout' | 'not-found' | 'forbidden' | 'maintenance''default'Preset variant with default icon, title, and description
iconReactNode—Custom icon to display (overrides variant emoji)
titlestring—Custom title (overrides variant default)
descriptionstring | ErrorObject—Custom description or error object with message/code
errorMessagestring—Detailed error message shown in expandable details section
errorCodestring | number—Error code displayed as a badge
onRetry() => void—Retry button press handler
retryLabelstring'Try again'Custom retry button label
isRetryingbooleanfalseShow retrying state with spinner animation
onBack() => void—Back button press handler
backLabelstring'Go back'Custom back button label
size'sm' | 'md' | 'lg''md'Component size
classNamestring—Additional CSS classes
accessibilityLabelstring—Accessibility label override

Translation Keys

Built-in copy is read through useUiTranslation() — provide these keys via <UiTranslationProvider>. Without a provider the English fallback is shown.

KeyEnglish fallbackUsed for
ui.errorState.defaultTitleSomething went wrongTitle (title prop wins)
ui.errorState.defaultDescriptionAn unexpected error occurred. Please try again.Description (description prop wins)
ui.errorState.networkTitleConnection lostTitle (title prop wins)
ui.errorState.networkDescriptionPlease check your internet connection and try again.Description (description prop wins)
ui.errorState.serverTitleServer errorTitle (title prop wins)
ui.errorState.serverDescriptionOur servers are having trouble. Please try again later.Description (description prop wins)
ui.errorState.timeoutTitleRequest timed outTitle (title prop wins)
ui.errorState.timeoutDescriptionThe server took too long to respond. Please try again.Description (description prop wins)
ui.errorState.notFoundTitleNot foundTitle (title prop wins)
ui.errorState.notFoundDescriptionThe requested resource could not be found.Description (description prop wins)
ui.errorState.forbiddenTitleAccess deniedTitle (title prop wins)
ui.errorState.forbiddenDescriptionYou don't have permission to access this resource.Description (description prop wins)
ui.errorState.maintenanceTitleUnder maintenanceTitle (title prop wins)
ui.errorState.maintenanceDescriptionWe're performing scheduled maintenance. Please check back soon.Description (description prop wins)
ui.errorState.errorPrefixErrorPrefix before the error code
ui.errorState.showDetailsShow detailsDetails toggle
ui.errorState.hideDetailsHide detailsDetails toggle
ui.errorState.retryTry againRetry button (retryLabel prop wins)
ui.errorState.retryingRetrying...Retry button while isRetrying
ui.errorState.backGo backBack button (backLabel prop wins)

Type Exports

TypeDescription
ErrorStatePropsProps for ErrorState component
ErrorStateVariant'default' | 'network' | 'server' | 'timeout' | 'not-found' | 'forbidden' | 'maintenance'
ErrorStateSize'sm' | 'md' | 'lg'

On this page