FormMessage

Form messages communicate validation, help, and error states close to their controls.

Overview and decision boundary

Use FormMessage for validation, confirmation, or contextual help inside a form field.

Do not use vague messages like Invalid value.

Preview

Use at least 3 characters.

This will be visible to collaborators.

Looks good.

import { FormMessage } from '@nerio-ui/ui';<FormMessage>Use at least 3 characters.</FormMessage>

Installation and imports

Install the editable registry source, or use the matching package entrypoint when the product keeps Nerio as a workspace dependency.

pnpm dlx nerio add form-messageimport { FormMessage } from '@nerio-ui/ui';

Usage

import { FormMessage } from '@nerio-ui/ui';<FormMessage>Use at least 3 characters.</FormMessage>

Variants

VariantPurpose
neutralLow-emphasis status or message.
dangerError, destructive, or blocking state.
successPositive completion or validation state.

Anatomy

SlotPurpose
rootMessage text with tone and compact spacing.

States

StatePurpose
VisibleAppears close to the relevant control.

Motion

  • State changes should use shared motion tokens and preserve reduced-motion behavior.

Accessibility

  • Associate messages with controls through aria-describedby.
  • Use danger tone for validation errors.
  • Set role="alert" only for active validation errors that should be announced.
  • Do not replace field-level errors with toasts.

API

PropPurpose
classNameExtends the component root while preserving Nerio tokenized defaults.

Implementation contract

ContractValue
Registry itemform-message installs 5 source files into the configured components directory.
Base UINo interactive primitive required.
Registry dependenciesNone.
Package dependenciesclsx, react, tailwind-merge, tailwindcss

Styling contract

ContractValue
AuthoringComplete, statically detectable Tailwind CSS v4 recipes own component visuals.
ValuesSemantic and component --n-* variables remain the canonical customization layer.
OverridesCustomizable slots merge consumer className values with tailwindCn so conflicting utilities resolve deterministically.
Residual CSSOnly shared keyframes and scoped no-Preflight compatibility rules remain; there is no parallel visual selector layer.

Design notes

  • Use FormMessage for validation, confirmation, or contextual help inside a form field.

Do / do not

Do

Tell users how to fix an error.

Do not

Do not use vague messages like Invalid value.

Tokens

These are the primary customization points. Override semantic or component tokens instead of changing component source.

TokenPurpose
--n-color-text-tertiaryPublic customization point for this component contract.
--n-color-status-dangerPublic customization point for this component contract.
--n-color-status-successPublic customization point for this component contract.