Skip to main content
Reactive forms provide a model-driven approach to handling form inputs whose values change over time. They use explicit and immutable data structures to manage the state of forms at a given point in time.

Setting Up Reactive Forms

Import ReactiveFormsModule in your component or module:

FormControl

FormControl is the basic building block that tracks the value and validation status of an individual form control.

Creating a FormControl

packages/forms/src/model/form_control.ts

Using FormControl in Templates

FormControl State and Updates

packages/forms/src/model/form_control.ts

Non-Nullable FormControl

packages/forms/src/model/form_control.ts

FormGroup

FormGroup tracks the value and validity state of a group of FormControl instances.

Creating a FormGroup

packages/forms/src/model/form_group.ts

Using FormGroup in Templates

Nested FormGroups

packages/forms/src/model/form_group.ts
Template with nested FormGroup:

FormGroup Methods

packages/forms/src/model/form_group.ts

FormArray

FormArray tracks the value and validity state of an array of controls. Use it for dynamic forms where the number of controls is not known in advance.

Creating a FormArray

packages/forms/src/model/form_array.ts

Dynamic Form Example

FormArray Methods

packages/forms/src/model/form_array.ts

FormBuilder

The FormBuilder service provides convenience methods to reduce boilerplate when creating forms.

Basic Usage

packages/forms/src/form_builder.ts

FormBuilder with Nested Groups and Arrays

packages/forms/src/form_builder.ts

NonNullableFormBuilder

packages/forms/src/form_builder.ts

Reactive Forms Best Practices

FormBuilder reduces boilerplate and makes your form creation code more readable.
Extract complex form sections into their own components with ControlValueAccessor.

Observing Form State

Next Steps

Form Validation

Learn about built-in and custom validators

Template-Driven Forms

Compare with template-driven approach