
Signal Forms Architecture
FreeUnderstand Angular's experimental signal-based forms API.
Free · Opens the source repo
What Signal Forms Architecture does
The Signal Forms Architecture skill provides a comprehensive guide to the experimental signal-based forms API found in Angular's packages/forms/signals directory. This API represents a significant shift from the traditional Reactive and Template-driven forms, introducing a model-driven approach that centers around a WritableSignal<T> as the single source of truth. This means that the form's value is held within the signal itself, while the form serves merely as a view, reflecting the state of the signal alongside additional form-specific metadata like validity and user interaction states.
One of the key features of this architecture is its use of Proxy-based traversal through the FieldTree, which allows developers to access nested fields intuitively without the need for manual control group creation. This lazy resolution of properties enhances the developer experience by streamlining how forms are constructed and manipulated. Additionally, the separation of schema-based logic from the form structure allows for more flexible validation and state management, enabling developers to define rules and metadata separately and apply them as needed.
The skill also covers essential components like FieldNode, which aggregates various state managers for tracking validation and submission states, and the FormField directive that binds DOM elements to form fields. This directive not only synchronizes values between the DOM and the signal but also manages user interactions seamlessly. Overall, this skill is designed for Angular developers looking to leverage the new signal-based forms API effectively, providing them with the mental models and architectural insights necessary to implement this system in their applications.
When to use it
Use this skill when working with Angular's signal-based forms to understand its architecture and best practices.
When not to use it
This skill is not suitable for developers who are not using Angular or those who prefer traditional Reactive or Template-driven forms without exploring new paradigms.
What you can build with it
Transitioning to Signal Forms
When moving from traditional Angular forms to the signal-based API, this skill provides essential insights into the architectural changes.
Implementing Custom Controls
If you're developing custom form controls, this skill guides you on how to properly integrate them with the signal-based forms API.
Understanding Form Validation
This skill helps clarify how validation works in the new API, including both synchronous and asynchronous error handling.
How to install Signal Forms Architecture
View source1. Install with the skills CLI
npx skills add angular/angular/reference-signal-forms --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by angularSignal Forms Architecture
The packages/forms/signals directory contains an experimental, signal-based forms API for Angular.
This system differs significantly from the existing Reactive and Template-driven forms.
Mental Model
-
Model-Driven: The system is built around a
WritableSignal<T>which serves as the single source of truth. Unlike Reactive Forms where theFormControlholds the value, here theSignalholds the value. The form is merely a view or projection of that signal, adding form-specific state (validity, dirty, touched). -
Proxy-Based Traversal: The form API (
form(signal)) returns aFieldTree. This object is a Proxy. It allows accessing nested fields (e.g.,myForm.user.name) without manually creating control groups. Accessing a property on the proxy lazily resolves or creates the correspondingFieldNode. -
Schema-Based Logic: Validation, disabled state, and other metadata are defined separately via Schemas. Schemas are applied to the form structure using functions like
apply,applyEach(for arrays), andapplyWhen. This separates the structure of the data from the rules governing it. -
Directives as Glue: The
[formField]directive binds a DOM element (native input or custom control) to aFieldNode. It handles:- Syncing the value between the DOM and the Signal.
- Reflecting state (valid, touched, etc.) to the UI.
- Handling user interaction events (blur, input).
Key Components
1. FieldNode (src/field/node.ts)
The central internal class representing a single field in the form graph. It aggregates several state managers:
structure: Manages parent/child relationships and signal slicing.validationState: Computesvalid,invalid,errorssignals.nodeState: Trackstouched,dirty,pristine.metadataState: Stores metadata likemin,max,required.submitState: Tracks submission status and server errors.
2. ValidationState (src/field/validation.ts)
Manages the complexity of validation:
- Synchronous Errors: Derived from schema rules.
- Asynchronous Errors: Handled via signals, including 'pending' states.
- Tree Errors: Errors that bubble up or are targeted at specific fields.
- Submission Errors: Server-side errors injected imperatively via
submit().
3. FormField Directive (src/directive/form_field_directive.ts)
The bridge between the FieldNode and the DOM.
- Selector:
[formField] - It supports:
- Native Elements:
<input>,<select>,<textarea>. - Custom Controls: Components implementing
FormUiControlorFormValueControl. - Legacy Interop: Components implementing
ControlValueAccessor(viaInteropNgControl).
- Native Elements:
4. Schema (src/api/structure.ts & src/api/rules)
Defines the behavior.
- Created via
schema(fn). - Applied via
apply(path, schema). - Rules include validators (
required,pattern,min,max) and state modifiers (disabled,hidden).
Data Flow
- Read:
form.field.value()reads directly from the underlying signal (projected to the specific path). - Write: Writing to the form (e.g., via UI) updates the underlying signal.
- Validation: A computed effect observes the value signal and runs validators defined in the schema.
Usage Example (Conceptual)
// 1. Define Model
const user = signal({name: '', age: 0});
// 2. Define Schema
const userRules = schema((u) => {
required(u.name);
min(u.age, 18);
});
// 3. Create Form
const userForm = form(user, userRules); // OR apply(userForm, userRules)
// 4. Bind in Template
// <input [formField]="userForm.name">
Important Files
packages/forms/signals/src/api/structure.ts: Public API entry points (form,apply).packages/forms/signals/src/api/control.ts: Interfaces for custom controls (FormUiControl).packages/forms/signals/src/field/node.ts: TheFieldNodeimplementation.packages/forms/signals/src/directive/form_field_directive.ts: The[formField]directive.
Supplemental Information
- Compiler & Core Integration: Details how
[formField]hooks into type-checking and the runtime.
Frequently asked questions about Signal Forms Architecture
Similar skills
Playwright Component Testing
Test React and Vue components in isolation with Playwright.
Fluent UI Blazor
Integrate Fluent UI components in Blazor applications effortlessly.
Build MCP App
Create interactive UI widgets for MCP servers.
Web Design Reviewer
Identify and fix design issues in websites efficiently.
Markstream Install
Seamlessly integrate Markstream for Markdown rendering.
GSAP & Framer Scroll Animation
Create advanced scroll animations effortlessly.
