Tag Input
Escreva etiquetas como chips removíveis: Enter ou uma vírgula adiciona uma, Backspace remove a última; funciona como controlo de formulário.
Disponível em
Angular: disponível Vue: disponível React: disponível React Native: ainda não disponível
Uso
- design
- planning
- q3
Press Enter or type a comma to add a tag.
<div class="demo-stack" style="max-width: 28rem">
<div soneField [invalid]="!!error()">
<label soneFieldLabel for="demo-tags">Tags</label>
<sone-tag-input inputId="demo-tags" [(value)]="tags" placeholder="Add tag…"
[max]="6" [maxVisible]="4" [suggestions]="suggestions"
(rejected)="onRejected($event)" (added)="error.set(null)" />
@if (error(); as e) {
<p soneFieldError>{{ e }}</p>
} @else {
<p soneFieldDescription>Press Enter or type a comma to add a tag.</p>
}
</div>
</div>Importação
import {
SoneTagInputComponent,
} from "@surface-one/angular/tag-input";Referência da API
SoneTagInputComponentComponente
Tags as removable chips — a ControlValueAccessor of `string[]`. Enter or a comma adds the typed tag (a pasted "a, b, c" adds three), Backspace in the empty field removes the last one. Duplicates are refused case-insensitively.
| Nome | Tipo | Padrão |
|---|---|---|
valuebidirecional | readonly string[] | [] |
placeholder | string | "" |
ariaLabelThe text field's accessible name. | string | null | $localize`Add tag` |
inputId | string | null | null |
maxAt most this many tags; further ones are rejected with reason `max`. | number | null | null |
maxVisibleShow this many chips and a "+N more" toggle for the rest. | number | null | null |
suggestionsOffered while typing (a native `<datalist>`). | readonly string[] | [] |
validateReturn `false` to refuse a tag (reason `invalid`). | ((tag: string) => boolean) | null | null |
variantThe chips' badge variant. | BadgeVariant | "secondary" |
disabled | boolean | false |
invalid | boolean | false |
| Nome | Tipo |
|---|---|
added | string |
removed | string |
rejected | SoneTagRejection |