Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 04 Fields

Text field

Label, input, hint and error as one control. The label, hint and error are tied to the input, so screen readers read all three.

Use it in Angular
import { TextFieldComponent } from '@okaapi-ui/angular';
// Works with formControlName, [formControl] and ngModel.
Works with

With a hint

We only use it for order updates.

Angular
<ui-text-field
  label="Email"
  type="email"
  hint="We only use it for order updates."
  autocomplete="email"
  formControlName="email"
/>

With an error

Pass the translated message. The input gets aria-invalid, a thicker border, and the message is announced. Colour is never the only sign.

Angular
<ui-text-field
  label="Full name"
  formControlName="name"
  [error]="form.controls.name.invalid ? 'Enter your full name' : undefined"
/>

Disabled

Disable it through the form control, as with any input.

Angular
order = new FormControl({ value: 'ORD-1042', disabled: true });

<ui-text-field label="Order number" [formControl]="order" />

In Arabic

بنستخدمه لتحديثات الطلب بس.

Angular
<!-- dir="rtl" on the page or any ancestor -->
<ui-text-field label="البريد الإلكتروني" type="email" hint="بنستخدمه لتحديثات الطلب بس." />

When to use something else

If you needUse
Several lines of textTextarea
A unit or currency beside the valueInput group
A number with − and + buttonsNumber field
Search with a clear buttonSearch field

Inputs

NameTypeDefaultWhat it does
labelstring — Required. The visible label, tied to the input.
type'text' | 'email' | 'password' | 'search' | 'tel' | 'url''text'The input type.
hintstring — Help text under the input, read with it.
errorstring — The translated error. Marks the input invalid and announces the message.
autocompletestring — The browser autofill hint, such as email or name.
testIdstring — data-testid on the input, for tests.

Keyboard and screen readers

  • The label, hint and error are tied to the input, so all three are read.
  • An error is announced when it appears.