Form
Use blackwork/form when a form needs managed values, validation, and submission. Use Field alone when the application already owns that state.
blackwork/form combines TanStack Form state management with Blackwork field components. TanStack Form handles values, validation, and submission; Blackwork provides field styles and bindings for common controls.
Install the required TanStack Form dependency first:
Bash
pnpm add @tanstack/react-formWhen to use
- Forms that need values, validation, and submission
- Reuse
TextField,TextareaField, orCheckboxField
For an input that only needs a label and description, use Field.
Usage
Usage
Examples
Built-in fields
Built-in fields
Custom field
Select, Combobox, and other controls need manual field bindings. The input example below shows how to connect a control inside form.AppField using Field.
Custom field
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
formrequired | { handleSubmit: () => unknown } | — | Form instance from useAppForm. Required on Form. |
labelrequired | ReactNode | — | Visible label on TextField, TextareaField, and CheckboxField. |
description | ReactNode | — | Help text rendered under the control. |
Notes
Formcallsform.handleSubmit()when submitted.SubmitButtonsets theButtonloading state fromisSubmitting.- Keep validation close to the field that owns it; use form-level validation for rules that depend on multiple values.
Note
useAppForm must run in a client component.