Field
A form field wrapper that provides accessible labeling, error handling, and state management for form inputs.
Features
- Automatic label association with form controls
- Error message display with proper ARIA attributes
- Description text support for additional context
- State management for disabled, required, readonly, and invalid states
- Seamless integration with Form component for validation
- Works with all form-related primitives (Checkbox, Select, RadioGroup, etc.) and native inputs
Installation
typo3 ui:add field
Please copy the files manually from GitHub into your project.
Read more about installing Components and Primitives.
Examples
Required Field
Mark a field as required.
With Description
Add helpful description text below the input.
Invalid State
Indicate that the field has an error and display an error message.
Disabled Field
Disable the entire field.
With Checkbox
Use with the Checkbox component.
API Reference
The following tables cover the available props of the Fluid Primitives.
field.root
Provides shared field state for labels, descriptions, errors, and controls. Renders a <div> element.
| Name | Description | Required | Default |
|---|---|---|---|
name | stringThe unique field name used to associate labels, descriptions, errors, and form values. | Yes | - |
disabled | booleanWhether the field is disabled. | No | - |
invalid | booleanWhether the field is invalid. | No | - |
required | booleanWhether the field is required. | No | - |
readOnly | booleanWhether the field is read-only. | No | - |
defaultValue | mixedThe initial value that child controls can use when rendered inside the field. | No | - |
field.label
Labels the associated form control. Renders a <label> element.
field.control
Wraps the slotted form control and wires up shared field attributes. Renders the element defined by the asChild prop.
field.description
Displays help or supporting text for the field. Renders a <div> element.
field.error
Displays validation error messages for the field. Renders a <div> element.
Anatomy
<primitives:field.root>
<primitives:field.label />
<primitives:field.control asChild="{true}">
<!-- Your form input here -->
</primitives:field.control>
<primitives:field.description />
<primitives:field.error />
</primitives:field.root>