For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /dolan/input.md.

Input

A single-line text field with an optional label, helper text and error message.

Installation

npx @blotch/dolan add input
import { UiInput } from '../components/ui/input';

Usage

src/app/app.ts
import { Component, signal } from '@angular/core';
import { UiInput } from '../components/ui/input';

@Component({
  selector: 'app-root',
  imports: [UiInput],
  template: `
    <ui-input label="Email" placeholder="you@example.com" [(value)]="email" />
  `,
})
export class App {
  protected readonly email = signal('');
}
  • [(value)] updates your signal on every keystroke. Setting the signal from code updates the field too.
  • The field shows a focus ring while it has focus.
  • class styles the whole block of label, field and message, so use it for spacing such as class="mt-4".

Helper text and errors

<ui-input
  label="Username"
  helperText="At least 3 characters"
  [(value)]="username"
/>
<ui-input
  label="Password"
  type="password"
  [error]="passwordError()"
  [(value)]="password"
/>
  • helperText shows small muted text under the field.
  • A non-empty error replaces the helper text with red text and turns the ring red. The field shakes when an error first appears.

Types

<ui-input label="Password" type="password" [(value)]="password" />

type goes to the underlying <input> element, which takes text, number and password.

Disabled

<ui-input label="Account ID" value="ACC-12345" disabled />

A disabled field dims and ignores typing.

Signal Forms

UiInput implements Angular's FormValueControl, so it works with the [formField] directive of Signal Forms (see Forms).

  • It emits touch when the field loses focus, as a native <input> does. So the field counts as touched, and an error can show as soon as the user leaves the field.
  • A form's maxLength() and readonly() reach the field.
  • focusBoundControl() focuses it and opens the keyboard.
  • For a number field, use <input type="number"> (see Numbers). UiInput holds a string.
src/app/app.ts
import { Component, computed, signal } from '@angular/core';
import { form, FormField, required } from '@angular/forms/signals';
import { UiInput } from '../components/ui/input';

@Component({
  selector: 'app-root',
  imports: [FormField, UiInput],
  template: `
    <ui-input label="Name" [formField]="profile.name" [error]="nameError()" />
  `,
})
export class App {
  readonly #model = signal({ name: '' });

  protected readonly profile = form(this.#model, (s) => {
    required(s.name, { message: 'Enter your name' });
  });

  protected readonly nameError = computed(() => {
    const name = this.profile.name();
    return name.touched() ? (name.errors()[0]?.message ?? '') : '';
  });
}

API

UiInput

InputTypeDefaultDescription
valuestring''The text. Supports [(value)].
labelstring''Text above the field. Hidden when empty.
accessibility-labelstring''The field's name for screen readers when it has no label.
placeholderstring''Hint shown while the field is empty.
typestring'text'The <input> element's type, such as password.
helperTextstring''Muted text under the field. Hidden while error is set.
errorstring''Error text. Turns the ring red and shakes the field.
disabledbooleanfalseDims the field and ignores typing.
classstring''Extra Tailwind classes for the outer block.
maxLengthnumber—The most characters the field takes. Signal Forms sets it from maxLength().
readonlybooleanfalseThe text can't be changed. Signal Forms sets it from readonly().
OutputTypeDescription
valueChangestringEmits the text on every keystroke, for [(value)].
changedstringEmits the text on every keystroke.
focusedvoidEmits when the field gains focus.
blurredvoidEmits when the field loses focus.
touchvoidEmits when the field loses focus, for forms.

Accessibility

  • A screen reader reads the field with its label, which becomes the native <input>'s accessibility-label, and then the text in it. The label above the field isn't a stop of its own, so it isn't read twice.
  • A field without a label takes its name from accessibility-label, for a field under a label of your own, such as one of several fields under one heading. Without either, a screen reader reads only the placeholder. label wins when both are set.
  • Tests find it by its label too: getByRole('textbox', { name: 'Email' }) returns the <input>. A password field has no ARIA role, so find it with getByAccessibilityLabel('Password').
  • Textarea: a multi-line field
  • Label: a caption for other controls
  • Forms: forms and the on-screen keyboard
  • <input>: the element underneath