FieldError

An announced validation message tied to a field.

  • Composed
  • New in 0.1
import { FieldError, fieldErrorPrimitive } from "nitro-ui-sdk/field-error";
HeroUI Native
FieldError
Expo UI
No counterpart
  • FieldError example screen, light appearance
    Light
  • FieldError example screen, dark appearance
    Dark
On this page

FieldError displays a validation message near its field. Use it with a custom field layout, or use the error part on TextField, TextArea or SecureField.

Anatomy

import { FieldError } from "nitro-ui-sdk/field-error";

<FieldError.Root>Enter a valid address.</FieldError.Root>;
Part Description
Root Displays the message as an alert. Style keys are root and text.

Usage

import { FieldError } from "nitro-ui-sdk/field-error";

<FieldError.Root>Enter a valid address.</FieldError.Root>;

Variants and sizes

The message uses the footnote size and semantic danger color.

States

Empty content hides the alert. A newly appearing or replaced message is announced once when announce is enabled.

Props

FieldError.Root

Prop Type Default Description
children string — Localized validation message.
announce boolean true Announce each new visible message.
styles PartStyles<FieldErrorPart, FieldErrorVariant, FieldErrorSize, FieldErrorState> — Style resolvers keyed by part.
agentId string — Identity in a reused view.

Controller API

Read-only. The component has no attached controller actions.

Styles

import { FieldError } from "nitro-ui-sdk/field-error";

<FieldError.Root children="Enter a valid address." styles={{ text: ({ state }) => ({ text: { fontWeight: state.visible ? "semibold" : "regular" } }) }} />;

Resolvers receive tokens, variant, size, and state. State includes visible.

Accessibility

The native alert role gives the message a spoken name. When the editor already announces its own validation error, set announce={false} on the visible FieldError to avoid a second announcement.

Agent API

Read-only.

Platform notes

iOS Android
Implementation Renderer views with UIKit accessibility semantics. Renderer views with TalkBack semantics.
Verification Native iOS harness in the example app. Kotlin is written for Android. The Android NDK is unavailable on this machine, so no Android build was run.