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.
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
Choose something else when
Examples
Labeled text input
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
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Optional class hook applied to the public root element owned by the component. |
label | Child | — | Visible field label. |
description | Child | — | Helper text announced with the control. |
error | Child | — | Validation message and invalid state. |
required | boolean | 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
| Property | Type | Required | Description |
|---|---|---|---|
label | Child | Yes | Visible field label. |
hint | Child | No | Inherited hint attribute accepted by Field. |
error | Child | No | Validation message and invalid state. |
success | Child | No | Inherited success attribute accepted by Field. |
warning | Child | No | Inherited warning attribute accepted by Field. |
required | boolean | No | Marks the field as required. |
optional | boolean | No | Inherited optional attribute accepted by Field. |
id | string | No | Inherited id attribute accepted by Field. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
children | Child | No | Inherited children attribute accepted by Field. |
FormMessageProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Inherited children attribute accepted by Field. |
tone | "success" | "warning" | "danger" | "neutral" | No | Inherited tone attribute accepted by Field. |
id | string | No | Inherited id attribute accepted by Field. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
FieldsetProps
| Property | Type | Required | Description |
|---|---|---|---|
legend | Child | No | Inherited legend attribute accepted by Field. |
hint | Child | No | Inherited hint attribute accepted by Field. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
children | Child | No | Inherited children attribute accepted by Field. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | No component state contract is exposed; the application owns the rendered content and surrounding behavior. |
| DOM target | Native input attributes target the owned form control; wrapper-specific props stay on the documented component root. |
Anatomy and related components
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
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | forms |
| Component import | @tavojs/ui/field |
| Explicit CSS import | @tavojs/ui/css/field |
| Preview | Interactive preview available on this page |