Input

The kit's text field: a floating or top label, hint and validation messages, prefix and suffix icons, three sizes and a multiline mode. It speaks Signal Forms natively and Reactive Forms through VigValueAccessor .

  • vig-input
  • [vigInputPrefix]
  • [vigInputSuffix]
Import
import { InputField, InputPrefix, InputSuffix } from '@vigdx/ui/input-field';

Basic

The 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.

Enter a valid email address.

Geçerli bir e-posta adresi girin.

Prefix and suffix icons

Mark any 1em icon with 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

Import 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.

{
  "name": "",
  "email": ""
}

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:

TypeScript
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.

TypeScript
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:

TypeScript
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"]

InputField styling hooks
Part Element data-state
field Positioned wrapper of the label, slots and control. —
label The visible (or floating) label. —
prefix Wrapper of the [vigInputPrefix] slot. —
input The native <input> , or <textarea> with multiline . —
suffix Wrapper of the [vigInputSuffix] slot. —
hint The vig-hint (a display: contents host; style its text part). —
disabled-reason The vig-hint with the disabled reason ( display: contents ). —
error The vig-field-error (a display: contents host; style its message part). —

Accessibility

  • The visible label is a real <label for>; with hideLabel it 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 sets aria-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 by fieldErrorIconLabel, “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.
  • required sets aria-required and 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-focus halo (--shadow-focus-error when invalid).
  • email, url and search fields turn off auto-capitalization, autocorrect and spell-check, which would mangle addresses and queries; inputMode, enterKeyHint, autocapitalize, autocorrect and spellcheck set them for other fields.

API

InputField

vig-input component
InputField props
Name Type Default Description
autocapitalize'none' | 'sentences' | 'words' | 'characters' | undefinedundefined

Text correction (autocapitalize, autocorrect, spellcheck). Left unset, it is off for email, url and search fields, which hold identifiers and queries, and the browser default otherwise.

autocompletestring | undefinedundefined
—
autocorrect'on' | 'off' | undefinedundefined

Autocorrect (autocorrect); off by default for email, url and search.

autoResizebooleanfalse

Multiline only: the textarea grows with its content (field-sizing: content), never shorter than rows. Browsers without field-sizing keep the fixed, user-resizable height.

dirtybooleanfalse
—
disabledbooleanfalse
—
disabledReasonsreadonly WithOptionalFieldTree<DisabledReason>[][]
—
enterKeyHint'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefinedundefined

Label of the virtual keyboard's Enter key, e.g. search or next (enterkeyhint).

errorMessagesRecord<string, string>—
—
errorsreadonly ValidationError.WithOptionalFieldTree[][]
—
hiddenbooleanfalse
—
hideLabelbooleanfalse

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.

hintstring | undefinedundefined
—
inputMode'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url' | undefinedundefined

Virtual keyboard hint, e.g. numeric or decimal (inputmode).

invalidbooleanfalse
—
label required string—
—
labelPositionLabelPosition'float'

float (default) rests the label inside the field; top sets it above a shorter field, for forms laid out with labels over their controls.

maxLengthnumber | undefinedundefined
—
minLengthnumber | undefinedundefined
—
multilinebooleanfalse

Renders a <textarea> instead of a single-line input.

namestring''
—
pendingbooleanfalse
—
placeholderstring | undefinedundefined
—
readonlybooleanfalse
—
requiredbooleanfalse
—
rowsnumber3
—
sizeInputSize'md'
—
spellcheckboolean | undefinedundefined

Spell-check (spellcheck); off by default for email, url and search.

touchedbooleanfalse
—
typeInputType'text'
—
value model string''
—

VigValueAccessor

directive

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.

VigValueAccessor methods
Signature Description
registerOnChange(fn: (value: unknown) => void): void
—
registerOnTouched(fn: () => void): void
—
setDisabledState(disabled: boolean): void
—
writeValue(value: unknown): void
—

Templates and directives

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 multiline field keeps it hidden.

[vigInputSuffix]InputSuffix

Marks projected content as a trailing icon inside the input; single-line only, like the prefix.

Are you sure?