Form
@rockshin/tao-uiCollects and validates field values with an antd-aligned API (rules, dependencies, Form.List) on top of the rc-form engine.
When to use
Use Form with Form.Item when fields need a value store, rule validation, or submit handling. Use the lighter FormField when you manage state yourself.
Direct Form.Item children have 4px bottom spacing when a feedback row is present (--tao-size-unit), or 20px otherwise (--tao-padding-md). --tao-form-field-item-gap overrides either default. Stack and FormSection manage spacing for items placed inside them. noStyle adds neither a shell nor spacing, and standalone FormField layout is unchanged.
At the default 12–14px message sizes, the reserved line is 18px high; with its 2px top margin and 4px trailing gap, feedback occupies 24px. Larger custom message text can increase the line height.
Form.Item reserves one feedback line when it has validation rules or an explicit help, extra or validateStatus. Single-line validation messages can appear or disappear without moving subsequent fields or buttons. Longer messages wrap and expand the space naturally to avoid overlapping content. Fields without validation or feedback do not reserve an empty row. Use help="" to keep the row when controlling messages manually.
Recommended
- Declare validation as rules on Form.Item; the required mark is inferred from rules.
- Use dependencies for cross-field rules such as password confirmation.
- Use Form.useForm() for imperative control (setFieldsValue, resetFields, submit).
- Values written through
setFields— including the controlledfieldsprop — clear stale validation errors for fields whose value changed; includeerrors/warningsin the same entry to provide fresh validation state. - Set size or disabled on Form to cascade them to every control inside.
Avoid
- Do not bind the same name in two mounted Form.Items.
- Do not mix manual value/onChange props with a bound Form.Item on the same control.
Examples
Basic usage
Validation
Horizontal layout
Complete form
Combine fields, sections, and actions into an end-to-end entry and submission flow.
Basic details about you.
Optional. Used for recovery.
Configure your workspace.
Cross-field validation
Validate against another field and update feedback when the related value changes.
Dynamic field lists
Add and remove repeated fields with Form.List, keeping form values and field indexes aligned.
Scroll to a claim field
Get the instance with Form.useForm(), a Form ref, or Form.useFormInstance(). Array paths and full Form.List paths such as ['claims', 0, 'email'] are supported.
Defaults to scrollMode: 'if-needed' and block: 'nearest'. Accepts behavior, block, inline, boundary, scrollMode and other scroll options; focus: true focuses the control after starting the scroll. Only mounted fields can be located; reveal conditional or unmounted tab content first. Custom controls must forward ref (a DOM node or an instance with nativeElement) or id.