Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
React Native docs
FormsReact Native

Error summary

List form errors and move focus to the field that needs attention.

Public APILumenErrorSummaryReact Native

Native example

Use Error summary

Show it after a failed submit and focus it so people hear the problem first.

Error summary rendered in the Expo web renderer Lumen playground

Captured exampleExpo web renderer

Open interactive preview
Open the Error summary demo
tsx
import { LumenErrorSummary, type LumenErrorSummaryProps, LumenTextField } from '@santi020k/lumen-react-native'
import { type ComponentRef, useRef } from 'react'
import { type TextInput, View } from 'react-native'

export function SignUpErrors({ errors }: Pick<LumenErrorSummaryProps, 'errors'>) {
  const emailRef = useRef<ComponentRef<typeof TextInput>>(null)
  const passwordRef = useRef<ComponentRef<typeof TextInput>>(null)

  return (
    <View style={{ gap: 16 }}>
      <LumenErrorSummary
        errors={errors}
        onSelectError={error => {
          const field = error.name === 'email' ? emailRef.current : passwordRef.current

          field?.focus()
        }}
      />
      <LumenTextField ref={emailRef} accessibilityLabel="Email" autoComplete="email" />
      <LumenTextField ref={passwordRef} accessibilityLabel="Password" secureTextEntry />
    </View>
  )
}
React Native
A summary of sign-up errors above the form whose entries move focus to the field that needs attention.

Reference

Public API

The primary shared and platform-specific options exposed by LumenErrorSummary.

APIValues or typeDefaultDescription
errors / heading / onSelectErrormessages / title / focus callbackrequired / There is a problem / requiredShow it after a failed submit and focus it so people hear the problem first.

Native behavior

Design and accessibility

When to use it

Show it after a failed submit and focus it so people hear the problem first.

Accessibility

A heading names the summary, and each entry focuses its field.

Shared component

Available on other platforms

Apple / SwiftUIAndroid / Compose Web
React Native docsNative primitives