API Reference
June 5, 2026 ยท View on GitHub
This document describes the complete public API of form-lens-angular.
Alpha notice: FormLens is currently in alpha. The public API is intentionally small and may change between alpha releases.
provideFormLens(config?)
Registers all FormLens services and initializers in the Angular DI tree.
Call this once in your app.config.ts providers array.
import { provideFormLens } from 'form-lens-angular';
export const appConfig: ApplicationConfig = {
providers: [
provideFormLens(),
// or with config:
provideFormLens({ overlayInvalidControls: true }),
],
};
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
config | FormLensConfig | No | Optional configuration object. All fields are optional. |
Returns
EnvironmentProviders โ pass directly into the providers array.
FormLensConfig
Configuration object passed to provideFormLens().
interface FormLensConfig {
overlayInvalidControls?: boolean;
enabled?: boolean;
panelPosition?: 'left' | 'right';
hotkey?: string;
detailLevel?: 'minimal' | 'detailed';
}
Fields
| Field | Type | Default | Status | Description |
|---|---|---|---|---|
overlayInvalidControls | boolean | true | โ Implemented | Highlights invalid controls in the DOM with an outline. |
enabled | boolean | true | ๐ Reserved | Reserved for future use. Not yet active. |
panelPosition | 'left' | 'right' | 'right' | ๐ Reserved | Reserved for future use. Not yet active. |
hotkey | string | 'ctrl+shift+f' | ๐ Reserved | Reserved for future use. Not yet active. |
detailLevel | 'minimal' | 'detailed' | 'detailed' | ๐ Reserved | Reserved for future use. Not yet active. |
FormLensDirective
Selector: [formLens]
A structural directive that registers a FormGroup with the FormLens inspector. Must be applied to an element that also has [formGroup].
Import
import { FormLensDirective } from 'form-lens-angular';
@Component({
imports: [ReactiveFormsModule, FormLensDirective],
})
Usage
<form [formGroup]="myForm" formLens formLensName="My Form">
<!-- controls -->
</form>
Inputs
| Input | Type | Required | Default | Description |
|---|---|---|---|---|
formLensName | string | No | 'Untitled form' | Display name shown in the inspector panel. |
Lifecycle
ngOnInitโ registers the form inFormLensRegistryand begins live state observation.ngOnDestroyโ unregisters the form and clears any active highlight.
FormLensOverlayService
Controls the visibility of the inspector panel overlay.
Import
import { FormLensOverlayService } from 'form-lens-angular';
Injection
@Component({ ... })
export class MyComponent {
private readonly overlay = inject(FormLensOverlayService);
}
Methods
open()
Opens the inspector panel. Has no effect if the panel is already open.
this.overlay.open();
close()
Closes the inspector panel. Has no effect if the panel is already closed.
this.overlay.close();
toggle()
Toggles the panel between open and closed.
this.overlay.toggle();
Properties
isOpen
Signal<boolean> โ reflects the current open/closed state of the panel. Reactive.
const open = this.overlay.isOpen; // Signal<boolean>
Public exports summary
The following symbols are exported from form-lens-angular:
// Provider
export { provideFormLens } from './lib/core/formlens.provider';
// Directive
export { FormLensDirective } from './lib/registration/form-lens.directive';
// Overlay service
export { FormLensOverlayService } from './lib/overlay/formlens-overlay.service';
// Config type
export type { FormLensConfig } from './lib/core/formlens.config';
Everything else is internal. Do not rely on internal symbols โ they are not part of the public contract and may change without notice.