Field

Fields compose labels, controls, descriptions, and validation messages.

Overview and decision boundary

Use Field to compose a label, description, control, and message into one accessible form unit.

Do not scatter messages away from the control they describe.

Preview

Names appear in navigation, tables, and activity.

Use a clear internal name.

import { Field, Input } from '@nerio-ui/ui';<Field label="Project name" description="Shown in workspace navigation." message="Use at least 3 characters." invalid><Input /></Field>

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 fieldimport { Field, Input } from '@nerio-ui/ui';

Usage

import { Field, Input } from '@nerio-ui/ui';<Field label="Project name" description="Shown in workspace navigation." message="Use at least 3 characters." invalid><Input /></Field>

Variants

VariantPurpose
defaultDefault variant using semantic Nerio tokens.
invalidInvalid is part of the public component contract.

Anatomy

SlotPurpose
rootField container that controls spacing and state.
labelAccessible name for the control.
descriptionOptional helper text before interaction.
messageValidation or help text after interaction.

States

StatePurpose
NeutralDescription and message can provide helper text.
InvalidMessage explains how to recover.

Motion

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

Accessibility

  • Generates stable ids for label, description, and message relationships.
  • Clones a single React control child to wire id and aria-describedby, and only sets invalid state for invalid fields.
  • Preserves a child control id when supplied and merges existing aria-describedby values.
  • Uses role="alert" for message text only when invalid is true.
  • Supports one form control child; compose custom markup directly when a field needs multiple controls.
  • Keep helper text and error text close to the field.

API

PropPurpose
classNameExtends the component root while preserving Nerio tokenized defaults.

Implementation contract

ContractValue
Registry itemfield installs 5 source files into the configured components directory.
Base UINo interactive primitive required.
Registry dependencieslabel, form-message
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 Field to compose a label, description, control, and message into one accessible form unit.

Do / do not

Do

Use Field as the default wrapper for production form rows.

Do not

Do not scatter messages away from the control they describe.

Tokens

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

TokenPurpose
--n-field-gapPublic customization point for this component contract.
--n-color-text-secondaryPublic customization point for this component contract.
--n-color-text-tertiaryPublic customization point for this component contract.
--n-color-status-dangerPublic customization point for this component contract.