Multiselect
A recipe: several values from a list, an array for Signal Forms — the Combobox with several values: chips for the chosen, a search for the list. No component of its own.
Usage
Usage
Bug
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScComboboxChip, ScComboboxChipRemove, ScComboboxChips, ScComboboxEmpty, ScComboboxInput, ScComboboxItem, ScComboboxItemIndicator, ScComboboxList,How it is made
scCombobox with multiple holds the value, an array: the chips show it (each with its remove button), the input searches, and the list stays open while options are checked. Its value is two-way or a [formField]; your buttons can set it too (Select all, Clear).
import { ScComboboxMultiple, ScComboboxChips, ScComboboxChip, ScComboboxChipRemove, ScComboboxInput, ScComboboxPortal, ScComboboxPopup, ScComboboxEmpty, ScComboboxList, ScComboboxItem, ScComboboxItemIndicator,} from '@semantic-components/ui';<div scCombobox multiple #picker="scCombobox" [(value)]="labels"> <div scComboboxChips> @for (item of picker.value(); track item) { <span scComboboxChip [value]="item"> {{ item }} <button scComboboxChipRemove>…</button> </span> } <input scComboboxInput aria-label="Labels" /> </div> <ng-template scComboboxPortal> <div scComboboxPopup> <div scComboboxList aria-label="Labels"> <div scComboboxItem value="Bug">Bug <span scComboboxItemIndicator>…</span></div> </div> </div> </ng-template></div>Accessibility
- The Combobox's: one tab stop; ↓ opens the list, Enter checks or unchecks the option, Escape closes it; the list is multi-selectable.
- Backspace in an empty input removes the last chip; ← and → reach the chips, each remove button named by you («Remove Bug»).
- Name it: a field's label, or aria-label on the input.
Examples
Form
import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form, validate } from '@angular/forms/signals';import { ScComboboxChip, ScComboboxChipRemove, ScComboboxChips, ScComboboxEmpty, ScComboboxInput, ScComboboxItem, ScComboboxItemIndicator,Select all
0 of 6 chosen
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScButton, ScComboboxChip, ScComboboxChipRemove, ScComboboxChips, ScComboboxEmpty, ScComboboxInput, ScComboboxItem, ScComboboxItemIndicator,RTL
خطأ
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import { ScComboboxChip, ScComboboxChipRemove, ScComboboxChips, ScComboboxEmpty, ScComboboxInput, ScComboboxItem, ScComboboxItemIndicator,