Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 74 ยท Forms

Signal Forms

Meet Angular's experimental signal forms: a model signal as the single source of truth, field state as signals, schema validation, and how it compares with reactive forms.

Reactive forms work well, but they were designed before signals existed. A FormGroup keeps its own copy of your data, exposes changes through RxJS observables, and mixes mutable control objects with your plain data. If your component state is already made of signals, that means two worlds: your signals, and a form model that you must keep synchronized with them by hand.

Signal forms are Angular's answer. Instead of building a tree of control objects, you hand the framework a signal that holds your data, and it derives the form state around it. The data is the single source of truth, and every piece of field state (value, errors, touched, dirty) is itself a signal. This lesson explains the idea, shows the shape of the API, and lets you run a small stand-in that behaves the same way.

Status: experimental. Signal forms arrived as a preview feature in the Angular 21 era and, as far as this lesson's author knows, remained a preview afterwards. Preview APIs may be renamed or reshaped in minor releases (the binding directive in particular has been renamed during the preview). Check the official documentation and release notes for your Angular version before using it in production, and treat the code below as a description of the idea rather than a stable reference. For anything you ship today, reactive forms remain the established choice.

Real versus stand-in. The typescript and html blocks are real Angular (to the best of the author's knowledge for the preview) and read-only, because the site cannot run the Angular compiler. The runnable examples are stand-ins: a tiny signal implementation plus a small form engine that follows the same model-first idea. They are not Angular code, and the real API differs in names, features and typing.

The idea: the model is the form

In reactive forms the flow is: build controls, read form.value, call patchValue to push data in. In signal forms the flow is much shorter:

  1. You create a writable signal with your data, for example signal({ email: '', password: '' }).
  2. You call form(model, schema). It returns a field tree that mirrors the shape of the data.
  3. Each field in the tree is a function; calling it returns that field's state, whose properties are signals.
  4. When the user types, Angular writes the new value into your model signal. When you set the model yourself, the fields follow.
flowchart LR
  M["model signal<br/>your data"] --> T["field tree<br/>form(model, schema)"]
  T --> S["field state signals<br/>value, errors, touched, dirty"]
  S --> V["template bindings"]
  V -->|"user types"| T
  T -->|"writes back"| M
  X["model.set(...)<br/>from your code"] --> M

Data flows down into field state; user input flows back into the same model signal.

Because the model is an ordinary signal, you can use it anywhere signals work: in computed() values, in effect(), in templates, or passed to a service. There is no separate form.value snapshot that can drift away from your state.

The shape of the API (read-only)

This sketch shows the preview API as of this writing. Names such as the binding directive have changed between preview releases, so look at your version's docs for the exact spelling.

TypeScript
import { Component, signal } from '@angular/core';
import { form, FormField, required, email, minLength, validate } from '@angular/forms/signals';

interface SignupData {
  name: string;
  email: string;
  password: string;
  confirm: string;
}

@Component({
  selector: 'app-signup',
  imports: [FormField],
  templateUrl: './signup.component.html',
})
export class SignupComponent {
  protected readonly model = signal<SignupData>({ name: '', email: '', password: '', confirm: '' });

  protected readonly signupForm = form(this.model, (path) => {
    required(path.name, { message: 'Please enter your name.' });
    required(path.email, { message: 'Email is required.' });
    email(path.email, { message: 'That does not look like an email address.' });
    minLength(path.password, 8, { message: 'Use at least 8 characters.' });

    validate(path.confirm, ({ value, valueOf }) =>
      value() === valueOf(path.password) ? null : { kind: 'mismatch', message: 'Passwords do not match.' },
    );
  });
}

Read the schema as a list of rules attached to paths in the data. path.email is a handle for "the email field", not its value, so one function declares all the rules for the whole form in one place. Validation rules like required and email are plain functions you import, much like the built-in validators you already know. A custom rule receives a context from which it can read the field's own value and the value of other fields, which is how a cross-field rule such as "passwords match" is written without a group-level validator.

The template binds an input to a field with a directive, then reads state as signals:

HTML
<form (submit)="save($event)">
  <label for="email">Email</label>
  <input id="email" type="email" [formField]="signupForm.email" />

  @if (signupForm.email().touched() && signupForm.email().invalid()) {
    @for (error of signupForm.email().errors(); track error.kind) {
      <p class="error" role="alert">{{ error.message }}</p>
    }
  }

  <button type="submit" [disabled]="signupForm().invalid()">Create account</button>
</form>

Note the two call forms: signupForm.email is the field (what you bind), and signupForm.email() is its state (what you read). The root signupForm() summarizes the whole form, so invalid() there is true while any field is invalid. The preview also offers rules for conditional behavior (marking fields disabled, hidden or read-only depending on other values) and a submit() helper that marks everything touched and runs your save function only when the form is valid.

Field state is just signals

Because the model and the state are signals, things that needed RxJS before become ordinary derived values. A live hint such as "how many characters are left" is a computed() over the model, and it needs no subscription:

TypeScript
protected readonly passwordHint = computed(() => {
  const missing = 8 - this.model().password.length;
  return missing > 0 ? `${missing} more characters needed` : 'Long enough';
});

No valueChanges.pipe(...), no toSignal, no subscriptions to clean up. Reading a signal inside a template or computed automatically tracks exactly the pieces you use, and change detection can update only what changed. The same goes for errors(), touched() and the rest of a field's state.

A runnable stand-in

The first stand-in has two parts. A very small signal implementation (the reading function plus set) and computed, then a createForm() function that takes a model signal and a schema, and returns fields whose state is derived from the model. Two things to watch: typing writes into the model, and setting the model from code moves the fields.

The stand-in's computed is simplified: it caches until any signal changes, where real signals track precisely which signals each computation read. See signals basics for the real behavior.

TypeScript Stand-in: a model signal and derived field state

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

Compare this with the reactive-forms stand-in in Reactive Forms. There, each control owned a value and you pushed data in with patchValue. Here the line model.set(...) is the whole update API, and the field state is always an honest view of the model. There is no way for the form and your data to disagree.

Schema validation and cross-field rules

Declaring all rules in one schema function has a practical effect: a rule can depend on any other field without the group-validator workaround from the validation lesson. In the second stand-in, a validate rule receives the field's value plus a valueOf helper. Two rules use it: password confirmation, and an email that is required only when the user ticked the newsletter box. A submit() helper marks every field touched, refuses to run while the form is invalid, and otherwise calls your save function.

TypeScript Stand-in: cross-field rules and submit

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

The summary lines show why a model-first design is pleasant. The confirmation rule re-evaluates when the password changes, with no manual updateValueAndValidity() call, and the conditional email rule reacts to the newsletter field. The stand-in cannot show the real library's extras, such as hiding or disabling fields from rules, but the principle is the same.

Signal forms versus reactive forms

Reactive forms Signal forms (preview)
Source of truth the FormGroup tree your model signal
State access properties and observables signals (value(), errors(), touched())
Reacting to change valueChanges with RxJS computed() and effect()
Validation validator functions per control, group validators for cross-field one schema, rules can read any field
Typing typed controls (nonNullable needed) follows your model's type
Maturity stable and widely used experimental, API may change

Reactive forms keep a big advantage today: a large ecosystem of tutorials, libraries and answers, and a stable API. Signal forms read better if your app is already signal-first, and they remove a whole category of bugs. A sensible plan is to keep existing forms reactive, and try signal forms on new, low-risk forms once their status in your Angular version suits your project.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. In signal forms, what is the single source of truth for the data?

    You pass your own writable signal to form(). User input writes into it, and setting it from code updates the fields, so form and data cannot disagree.
  2. 2. In the sketch, what is the difference between signupForm.email and signupForm.email()?

    The field is what you bind in the template; calling it returns the state object whose properties (value, errors, touched, invalid) are signals.
  3. 3. Why can a schema rule validate "passwords match" without a group-level validator?

    Rules are attached to paths in one schema function, and the rule's context can read other fields' values, so any field may depend on any other.
  4. 4. What is the honest status of signal forms in this lesson?

    It is a preview feature, so check the docs and release notes for your Angular version, and keep reactive forms for forms you cannot afford to rewrite.
  5. 5. Which RxJS-based mechanism does signal forms replace for reacting to field changes?

    Because field state is signals, derived values become computed() values and reactions become effect() instead of subscribing to valueChanges.

Summary

  • Signal forms (preview) put your data in a signal and derive the form around it; field state (value, errors, touched, dirty) is exposed as signals.
  • form(model, schema) returns a field tree; the schema declares rules by path, and rules can read other fields.
  • User input writes into the model, and model.set(...) moves the fields: there is no second copy to synchronize.
  • Derived form information is plain computed(), with no subscriptions to clean up.
  • The feature is experimental and its API has already changed during the preview, so check the docs for your version and keep reactive forms for production forms that must stay stable.
  • The Angular snippets are read-only; the signal and form engine here are stand-ins, simplified (for example, computed recomputes after any change).

Next: Dynamic Forms and Custom Form Controls