Navigated to /docs/ui/components/field

Field

Label, hint, validation message, required state, and ARIA wiring around one form control.

Preview

A live, theme-aware example rendered with the published component.

Loading preview…

Import

Import the component from its dedicated entry point to keep the dependency and generated bundle explicit.

TSX
tsximport { Field } from "@tavojs/ui/field";

Normal Tavo.js applications load component styles through the Tavo.js UI plugin. If the application manages component CSS manually, also import @tavojs/ui/css/field.

When to use

Use it when

Use Field around TextInput, Select, Textarea, or another single control when it needs a visible label and correctly connected supporting or validation text.

Choose something else when

Field is not the input itself and is not a form submission boundary. Use TextInput for the native control and FormControl for the enclosing form.

Examples

Labeled text input

TSX
tsximport { Field } from "@tavojs/ui/field";
import { TextInput } from "@tavojs/ui";

export function FieldExample1() {
  const emailError: string | undefined = undefined;
  return (
    <>
      <Field label="Email" error={emailError}><TextInput type="email" /></Field>
    </>
  );
}

Common props and defaults

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
labelChild

Visible field label.
descriptionChild

Helper text announced with the control.
errorChild

Validation message and invalid state.
requiredboolean

false

Marks the field as required.

Complete TypeScript API

Import from @tavojs/ui/field. Published exports: Field, FieldProps, FieldRoot, Fieldset, FieldsetProps, FormMessage, FormMessageProps, Legend.

FieldProps

PropertyTypeRequiredDescription
labelChild

Yes

Visible field label.

hintChild

No

Inherited hint attribute accepted by Field.

errorChild

No

Validation message and invalid state.

successChild

No

Inherited success attribute accepted by Field.

warningChild

No

Inherited warning attribute accepted by Field.

requiredboolean

No

Marks the field as required.

optionalboolean

No

Inherited optional attribute accepted by Field.

idstring

No

Inherited id attribute accepted by Field.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

childrenChild

No

Inherited children attribute accepted by Field.

FormMessageProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by Field.

tone"success" | "warning" | "danger" | "neutral"

No

Inherited tone attribute accepted by Field.

idstring

No

Inherited id attribute accepted by Field.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

FieldsetProps

PropertyTypeRequiredDescription
legendChild

No

Inherited legend attribute accepted by Field.

hintChild

No

Inherited hint attribute accepted by Field.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

childrenChild

No

Inherited children attribute accepted by Field.

State ownership and DOM target

ConcernContract
StateNo component state contract is exposed; the application owns the rendered content and surrounding behavior.
DOM targetNative input attributes target the owned form control; wrapper-specific props stay on the documented component root.

Anatomy and related components

This component exposes one public component root rather than a compound member API.

Limitations

Field is not the input itself and is not a form submission boundary. Use TextInput for the native control and FormControl for the enclosing form.

Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.

Accessibility

Adds id, aria-describedby, and aria-invalid to child controls.

  • Adds id, aria-describedby, and aria-invalid to child controls.

Component status

ContractCurrent value
Maturitystable
Categoryforms
Component import@tavojs/ui/field
Explicit CSS import@tavojs/ui/css/field
PreviewInteractive preview available on this page