Skip to content

Form for Angular

AngularForm Infrastructure

State manager and validation orchestrator for a native <form>. It discovers AbsoluteUI controls and Form Field-wrapped native controls, validates them on submit, runs cross-field rules and an optional cancellable async validator with a timeout, shows an Error Summary linking to each invalid field, serializes values, applies server errors, tracks dirty/touched/submitting state, and resets every control consistently.

  • Native form firstEnhances a plain form element and discovers every AbsoluteUI control inside it, including wrapped native fields.
  • Cross-field rulesRules that read several fields, such as matching emails, run on submit and live after the first attempt.
  • Async validationAn optional server check runs after local constraints, with cancellation and a timeout.
  • Error summaryA failed submit lists every error as links that move focus to the field.
  • State and server errorsTracks dirty, touched, and submitting state, applies server errors, and resets every control consistently.

Behavior, design tokens, and limitations are described on the Form page; this page covers the Angular API.

import { Component } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { AuiForm } from '@absoluteui/angular/form';
import { AuiTextInput } from '@absoluteui/angular/text-input';
import { AuiButton } from '@absoluteui/angular/button';
@Component({
selector: 'app-signup',
imports: [ReactiveFormsModule, AuiForm, AuiTextInput, AuiButton],
template: `
<form auiForm [formGroup]="signup" focusOnInvalid="summary" (submitted)="save()">
<aui-text-input label="Email" type="email" name="email" [required]="true" formControlName="email"></aui-text-input>
<button type="submit" auiButton variant="primary">Sign up</button>
</form>`,
})
export class SignupComponent {
readonly signup = new FormGroup({ email: new FormControl('', { nonNullable: true, validators: [Validators.required, Validators.email] }) });
save(): void {
// this.signup.getRawValue() is valid here.
}
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiForm } from '@absoluteui/angular/form';

Defaults for every instance: provideAbsoluteUIConfig({ components: { form: { ... } } }) (see Configuration).

Class AuiForm; template reference #ref="auiForm".

AbsoluteUI Form: <form auiForm (submitted)="save($event.values)">. Complements Angular forms: AbsoluteUI controls also report validity to Angular through their Validator, so formGroup.valid and the AbsoluteUI state agree. Bind (submitted) rather than (ngSubmit): ngSubmit fires before AbsoluteUI validation.

Server rendering: Renders in the browser only; on the server the element stays empty.

Input Type Default Description
rules readonly CrossFieldRule[] '' Cross-field rules { fields, validate(values), target? }. Run on validate/submit and live on every edit after the first submit. The first failing rule per target wins.
validate AsyncFormValidator Async validator (values, AbortSignal) => Promise<FormErrors>.
summaryTitle string Error summary heading. Default: localized “There is a problem”. Applied when the summary is created, on update(), and on global configuration changes.
summaryHost HTMLElement Element that hosts the error summary. Read only when the summary is first created (on the first failed submission); changing it afterwards has no effect. Default: a <div> inserted as the form’s first child on the first failed submit (removed on destroy).
focusOnInvalid FocusOnInvalid 'summary' Where focus moves after a failed submission. Without a summary, focus always goes to the first invalid field.
errorSummary boolean true Render an error summary on failed submission. When false, messages that belong to no field are announced assertively.
submitMode SubmitMode 'event' ‘event’: emit aui-submit only. ‘native’: then call HTMLFormElement.submit() unless aui-submit was prevented (the submitter’s name/value is included).
asyncTimeoutMs number '10000' Async validator timeout in ms (integer 100..120000). On timeout the signal aborts with a TimeoutError.
locale string 'en-US' Locale of the summary heading and form-level messages.
Output Payload Description
(submitted) FormSubmitDetail Valid submission: values and the abort signal of the submit. Re-emits aui-submit.
(invalidSubmit) FormInvalidDetail Submission blocked by errors (the summary and focus are already handled). Re-emits aui-invalid.
(stateChange) FormState dirty, touched, submitting, submitCount, or valid changed (deduplicated). Re-emits aui-state-change.
(formReset) null The form was reset (reset() or a native reset). Re-emits aui-reset.

Call them through a viewChild query or a template reference.

Method Description
getValues(): Readonly<Record<string, unknown>> | undefined Current values of the registered controls.
checkValidity(): boolean Run synchronous validation now and show the messages; true when valid.
submit(): void Run the submit pipeline (validation, then submitted or invalidSubmit).
setErrors(errors: Readonly<Record<string, string>>): void Show server or cross-field errors by field name.
clearErrors(): void Remove server or custom errors set with setErrors.
reset(): void Reset the form and every control to its initial values and clear messages.

Pattern: Native <form> with the GOV.UK error summary pattern: validate on submit, then move focus to a summary of links to each invalid field.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Form: Accessibility and performance.