FormField
Form field wrapper providing label, description, and validation message layout.
Import#
Inside Form, a named field automatically reads its value and validation state from Formisch.
Top-level fields accept a string name; nested and array fields use a path such as
['users', 0, 'email']. Outside Form, the component remains a standalone layout primitive.
Pass the schema type to validate names at compile time:
Slot Structure#
Label, description, and hint area above a control slot with validation feedback.
Examples#
Basic#
Label, hint, description, and help text with a single control.
With Validation#
Bind to a Formisch store and show validation feedback without a render prop.
Horizontal Layout#
Use orientation="horizontal" for form-like row layouts.
Sizes#
Preview the field typography scale from xs to xl.
Manual Error#
Force error state with a custom error message.
Render Context#
Use render-function children to react to error state.
Nested Path#
Use array path names for nested form fields.
API Reference#
Attributes#
root1 attributeData Attributes
| Data Attribute | Description |
|---|---|
| data-orientation | Stores the rendered orientation. |
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
| as | T | undefined | div | The HTML element or component to render as. |
| children | ComponentOrElement<FormFieldT.RenderContext> | undefined | — | Children of the field, can be a render function. |
| class | ClassValue | — | Class applied to the component root or trigger element. |
| classes | FormFieldT.Classes | undefined | — | — |
| description | JSX.Element | — | Description text shown below the label. |
| error | boolean | string | JSX.Element | — | Custom error message or force error state. |
| help | JSX.Element | — | Help text shown below the control when no error is present. |
| hint | JSX.Element | — | Hint text shown near the label. |
| id | string | undefined | — | Unique identifier for the form field. |
| label | JSX.Element | — | Label for the field. |
| name | FormFieldT.Name<TSchema> | undefined | — | The name of the field (key in form state). |
| orientation | "horizontal" | "vertical" | undefined | — | — |
| ref | JSX.HTMLElementTags[T] extends { ref?: infer Ref; } ? Ref : never | undefined | — | — |
| required | boolean | undefined | false | Whether the field is required. |
| size | "xs" | "sm" | "md" | "lg" | "xl" | undefined | — | — |
| style | JSX.CSSProperties | undefined | — | — |
| styles | FormFieldT.Styles | undefined | — | — |