Skip to Content
Fields and text input

Fields and text input

Associate one native control with a label, help text and an application-owned error.

Interactive example React 19 · local alpha

Choose a name you will remember.

These associations are explicit.

Add a short title before continuing.

Usage

The example assumes the stylesheet and a Theme are already present.

import { Field, TextField, TextArea } from "@pane-ui/react"; <> <Field label="Email address" description="Used for your reply." required> <TextField type="email" name="email" autoComplete="email" /> </Field> <Field label="Notes" description="Up to 240 characters."> <TextArea name="notes" maxLength={240} /> </Field> </>;

API

Prop / exportType / defaultPurpose
Field.label, childrenReactNode; requiredLabel and one native library control.
description, errorReactNode; optionalNonempty error marks the control invalid; both establish descriptions.
controlIdstring; generated if omittedIdentifies the control, overriding its child id.
required, disabledboolean; optionalPropagate to the control with Field ownership rules.
TextField.typetext (default), email, password, search, tel, url, numberRestricted native input types.
TextArea.rowsnumber; default 4Other textarea attributes remain native.
LabelNative label props / HTMLLabelElement refStandalone label; explicitly connect with htmlFor.
FieldDescription, FieldErrorNative p props / HTMLParagraphElement refsStandalone help/error text, without automatic associations.
Other native props / refsField: div; TextField: input; TextArea: textareaRefs point to wrapper or native control respectively.

Behavior and composition

Field wraps exactly one TextField, TextArea, Select or Slider. Its stable generated ID keeps label/control associations consistent through SSR. id on Field identifies the wrapper; controlId identifies the input. Existing aria-describedby values merge and deduplicate with help/error IDs.

A Field’s explicit required value takes precedence over its control. Field disabled cannot be undone by a child, while a child may add its own disabled restriction. A nonempty error sets invalid state and associated text; it does not run validation or create a live region. Use error text that tells the user how to recover.

Native name, value/defaultValue, onChange, form, reset, readOnly and constraint validation remain available. Refs focus the native inputs. Keyboard editing remains browser-owned. For custom composition, use standalone Label/help/error with explicit htmlFor, id, aria-describedby and aria-invalid rather than adding duplicate labels within Field. Checkbox and Switch already own their labels.

Last updated on