Input
VigValueAccessor .
vig-input [vigInputPrefix] [vigInputSuffix]
import { InputField, InputPrefix, InputSuffix } from '@vigdx/ui/input-field';Basic
label rests inside the field and floats up on focus or when filled. Two-way bind [(value)] for plain signal state.
Hello, stranger.
Label on top
labelPosition="top" sets the label above a shorter field, for forms laid out with labels over their controls. multiline renders a textarea; add autoResize to let it grow with its text ( field-sizing: content , never shorter than rows ).
Hint and error
hint adds help text. Errors show once the field is touched and invalid (see Error timing below for the interacted mode); errorMessages overrides the built-in text per error kind (the i18n hook).
Visible only to your team.
Prefix and suffix icons
vigInputPrefix or vigInputSuffix ; they are decorative and mirror in RTL.
Disabled, read-only and sizes
disabled removes the field from interaction, readonly keeps it focusable and selectable. size is sm , md (default) or lg .
Reactive Forms
VigValueAccessor next to the component to use formControlName , [formControl] or ngModel . Built-in validators show the same messages; submit the empty form to see them and focusFirstInvalid move focus to the first error.
Signal Forms
vig-input implements FormValueControl<string> , so [formField] binds value, validation and interaction state with no accessor.
Valid: no · no email yet
Error messages
A message is resolved in this order: the message of the validation error (Signal Forms schema) → errorMessages for its kind → the built-in default of the active locale → errorMessages['default'] → a generic fallback. Set app-wide texts once with provideVigdxUi:
provideVigdxUi({
locale: 'en',
labels: { errors: { required: 'Please fill in this field.' } },
});Error timing
By default an error shows once the field is touched. With errorDisplay: 'interacted' it waits until the field was left and edited, or the surrounding <form> was submitted, so tabbing through an empty required field stays quiet. VigValueAccessor mirrors dirty and the form's submitted flag. Signal Forms has no submitted state (submit() only marks the fields touched), so the fields follow the <form> element's own submit event instead, which both [formRoot] and a (submit) handler calling submit() fire; field().reset() clears it again. A submit() called without a <form> reveals only the errors of fields the user edited.
To clear the form after a submit, call resetForm() on the FormGroupDirective (or NgForm) rather than only form.reset(): a plain reset leaves submitted set, so required errors would show on the fresh form, as in Angular Material.
provideVigdxUi({ errorDisplay: 'interacted' }); // default: 'touched'After a failed submit
Angular forms are novalidate, so the browser does not move focus to the first invalid field. focusFirstInvalid(root) does: it focuses the first control under root with aria-invalid="true" (the checked radio of an invalid group), scrolls it into view and returns it, or null when no invalid field can take focus. A field in an inactive tab or a closed accordion item is revealed first, as find-in-page does; fields under plain hidden or inert are skipped. The screen reader then reads that field's error. Call it after the next render so the fields show their touched state first:
private readonly injector = inject(Injector);
private readonly formRef = viewChild.required<ElementRef<HTMLFormElement>>('formRef');
save(): void {
if (this.form.invalid) {
this.form.markAllAsTouched();
afterNextRender(() => focusFirstInvalid(this.formRef()), { injector: this.injector });
return;
}
// …
} With Signal Forms, every kit control also implements focus(), so form.field().focusBoundControl() moves focus to its input (or the trigger of a select), and reset(), so form().reset() drops half-typed text and closes open panels along with the touched and dirty state.
Signal Forms models
Controls that can be emptied write null: vig-number-input and vig-slider (number | null), vig-select, vig-autocomplete, vig-radio-group and vig-select-button (T | null) and vig-date-picker (Date | null). Type those model fields as nullable and start them at null, even though Angular's guide prefers non-null models: clearing the control writes null into the field either way. Text fields use '', vig-multi-select and vig-file-upload use [].
Remove hidden fields with @if (!form.field().hidden()); the controls' hidden input is only a fallback, and Signal Forms warns about rendered hidden fields in development.
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="input"][data-part="field"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="input"]
| Part | Element | data-state |
|---|---|---|
field | — | |
label | — | |
prefix | [vigInputPrefix] slot. | — |
input | <input> , or <textarea> with multiline . | — |
suffix | [vigInputSuffix] slot. | — |
hint | vig-hint (a display: contents host; style its text part). | — |
disabled-reason | vig-hint with the disabled reason ( display: contents ). | — |
error | vig-field-error (a display: contents host; style its message part). | — |
Accessibility
- The visible
labelis a real<label for>; withhideLabelit stays as the accessible name and only the visual row goes. - Hint, disabled reason and error are linked through
aria-describedby; an invalid, touched field setsaria-invalid="true". Error texts are not live regions: when an error first appears after the user leaves the field, it is announced once ("Email: Enter a valid email address.") through a single polite live region, half a second later so it does not talk over the next field. The error starts with an error icon (named byfieldErrorIconLabel, “Error”), so it differs from the hint by more than its color. - After a failed submit, move focus to the first error with
focusFirstInvalid. - The floating label also reacts to browser autofill, which fills the field without an input event.
requiredsetsaria-requiredand adds a visual asterisk.- Prefix and suffix icons are decorative. If an icon carries meaning, say it in the label or hint.
- Focus draws a 2px outline in the primary color over the border (the error color when invalid), at least 3:1 against the page and kept in forced-colors mode, inside the
--shadow-focushalo (--shadow-focus-errorwhen invalid). email,urlandsearchfields turn off auto-capitalization, autocorrect and spell-check, which would mangle addresses and queries;inputMode,enterKeyHint,autocapitalize,autocorrectandspellcheckset them for other fields.
API
InputField
vig-input| Name | Type | Default | Description |
|---|---|---|---|
autocapitalize | 'none' | 'sentences' | 'words' | 'characters' | undefined | undefined | Text correction ( |
autocomplete | string | undefined | undefined | — |
autocorrect | 'on' | 'off' | undefined | undefined | Autocorrect ( |
autoResize | boolean | false | Multiline only: the textarea grows with its content ( |
dirty | boolean | false | — |
disabled | boolean | false | — |
disabledReasons | readonly WithOptionalFieldTree<DisabledReason>[] | [] | — |
enterKeyHint | 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefined | undefined | Label of the virtual keyboard's Enter key, e.g. |
errorMessages | Record<string, string> | — | — |
errors | readonly ValidationError.WithOptionalFieldTree[] | [] | — |
hidden | boolean | false | — |
hideLabel | boolean | false | Visually hides the label — it still names the control for assistive tech — and drops the row reserved for it, giving a shorter control for dense toolbars such as table filters. Pair it with a placeholder. |
hint | string | undefined | undefined | — |
inputMode | 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url' | undefined | undefined | Virtual keyboard hint, e.g. |
invalid | boolean | false | — |
label | string | — | — |
labelPosition | LabelPosition | 'float' |
|
maxLength | number | undefined | undefined | — |
minLength | number | undefined | undefined | — |
multiline | boolean | false | Renders a |
name | string | '' | — |
pending | boolean | false | — |
placeholder | string | undefined | undefined | — |
readonly | boolean | false | — |
required | boolean | false | — |
rows | number | 3 | — |
size | InputSize | 'md' | — |
spellcheck | boolean | undefined | undefined | Spell-check ( |
touched | boolean | false | — |
type | InputType | 'text' | — |
value | string | '' | — |
| Name | Payload | Description |
|---|---|---|
touch | void | — |
valueChange | string | — |
| Signature | Description |
|---|---|
focus(options?: FocusOptions): void | Moves focus to the control's interactive element (the input, or the
trigger of a popup control). Signal Forms calls it through
|
reset(): void | Returns the control to its pristine look: drops in-progress text, closes
an open popup, clears errors the component raised itself and the
submitted state of |
VigValueAccessor
Bridges the vigdx form fields to Reactive Forms (formControl,
formControlName) and template-driven forms (ngModel). Import it next to
the component; Signal Forms ([formField]) need no accessor.
| Signature | Description |
|---|---|
registerOnChange(fn: (value: unknown) => void): void | — |
registerOnTouched(fn: () => void): void | — |
setDisabledState(disabled: boolean): void | — |
writeValue(value: unknown): void | — |
Templates and directives
| Selector | Export | Description |
|---|---|---|
[vigInputPrefix] | InputPrefix | Marks projected content as a leading icon inside the input (e.g. a search
glyph). Any 1em-sized icon source works. Single-line inputs only: a
|
[vigInputSuffix] | InputSuffix | Marks projected content as a trailing icon inside the input; single-line only, like the prefix. |