Chapter 04 Fields
Chip input
A text field that collects several short values, such as toppings, email addresses or skills. Each value becomes a tag with its own named remove button. Screen readers hear each value being added and removed, and focus never falls off the field.
import { ChipInputComponent } from '@okaapi-ui/angular';
// The value is a string[]. Works with formControlName, [formControl] and ngModel.Toppings
Type, then Enter or a comma. Backspace in the empty field moves to the last tag; Enter on its × removes it and moves focus to the next.
Cheese Olives
Press Enter after each one.
Value: [ "Cheese", "Olives" ]
<ui-chip-input
label="Toppings"
hint="Press Enter after each one."
formControlName="toppings"
/>In Arabic
جبنة
<ui-chip-input label="الإضافات" removeLabel="إزالة"
[addedLabel]="added" [removedLabel]="removed" formControlName="toppings" />
added = (c: string) => `تمت إضافة ${c}`;
removed = (c: string) => `تمت إزالة ${c}`;When to use something else
Inputs
| Name | Type | Default | What it does |
|---|---|---|---|
label | string | — | Required. Names the field and the list of tags. |
hint | placeholder | string | — | Help under the field; text in the empty field. |
removeLabel | string | 'Remove' from labels | First word of each × button's name. Translate it. |
addedLabel | removedLabel | (chip: string) => string | `${c} added` from labels | What screen readers hear after a change. Translate them. |
Keyboard and screen readers
| Keys | What they do |
|---|---|
| Enter or , | Add what is typed as a tag. |
| Backspace | In an empty field, move to the last tag’s remove button. |
| Enter or Space | On a remove button, remove that tag. |
- Each tag has its own remove button, named after its value.
- Adding and removing are announced, and focus moves to the next tag or back to the field.