Pills input¶
Pills input allows users to enter multiple items, such as tags or email addresses, into a single input field.
Usage¶
Pill Input is a control that lets users enter text, transforming each entry into a distinct "pill". A new entry is added when the Enter key is pressed or when separated by commas or semicolons. Existing pills can be deleted as needed.

When to use¶
- To add tags to categorize content, making it easier for users to classify and find items based on keywords.
- To enter email addresses or names, allowing users to easily add or remove recipients.
- For selecting multiple options from a wide range of choices.
Best practices¶
- Guide users with examples in the placeholder, like "Enter tags, separated by commas."
- If needed, set a maximum number of pills to keep the interface clean.
- Offer autocomplete suggestions as required.
- Provide validation when necessary.
Design¶
Elements¶

1. Label (optional), 2. Pills, 3. Container, 4. Helper text (optional)
Interaction states¶

Label (optional)¶
Effective labeling helps users understand what information to enter.
- Keep labels short and clear (should not be wider than the input field).
- Mandatory fields are marked with an
*-asterisk. - Labels can be placed on top of fields or to the left (in RTL languages). Prefer top placement of labels, since it provides a consistent left edge alignment, improving scannability.

Validation¶
Real-time validation can be implemented to ensure that entered text meets specific criteria.

Responsive behavior¶
When space is limited, pills are stacked to ensure adaptability across various screen sizes.

Code¶
Usage¶
import { SiPillsInputComponent } from '@siemens/element-ng/pills-input';
@Component({
imports: [SiPillsInputComponent, ...]
})
import { SiPillsInputComponent } from '@siemens/element-ng/pills-input'; Input Properties¶
| Name | Type | Default | Description |
|---|---|---|---|
| disabled ¶ | boolean | false | Whether the pills-input is disabled. |
| errormessageId ¶ | string | `${this.id()}-errormessage` | This ID will be bound to the Implements SiFormItemControl |
| id ¶ | string | `__si-pills-input-${SiPillsInputComponent.idCounter++}` | The identifier of the pills-input. Will be generated if not provided. Implements SiFormItemControl |
| inputElementAriaLabel ¶ | TranslatableString | $localize`:@@SI_PILLS_INPUT.INPUT_ELEMENT_ARIA_LABEL:Create item` | The aria-label for the inner input where users enter new items. |
| labelledby ¶ | string | `${this.id()}-label` | ID that should be assigned to the label element inside the SiFormItemComponent. If the target control is not of type input, select or button, it cannot be referenced by a label. Instead, aria-labelledby must be used to create a reference to a label. In such a case, an implementation of SiFormItemControl must provide the id of the label in labelledby. SiFormItemComponent will apply the id to the label so that it can be used inside the control to reference it in the aria-labelledby attribute. Implements SiFormItemControl |
| placeholder ¶ | TranslatableString | undefined | The placeholder to be shown if no value is currently present. | |
| readonly ¶ | boolean | false | Whether the pills-input is readonly |
import { SiPillsInputCsvDirective } from '@siemens/element-ng/pills-input'; Input Properties¶
| Name | Type | Default | Description |
|---|---|---|---|
| pillsInputCsvItemRegex ¶ | RegExp | undefined | undefined | Regex to validate an input string item. Inherited from |
Attributes and Methods¶
| Name | Type | Default | Description |
|---|---|---|---|
| (readonly) separatorRegexinherited ¶ | WritableSignal<RegExp> | SEPARATOR_REGEX | Regex to split the input value into segments. Inherited from |
Types Documentation¶
Represents a translatable string. This can either be a translation key, e.g. ACTIONS.EDIT that will be automatically translated when displayed on the UI or a pre-translated string, e.g. Edit. Equivalent to a normal string in usage and functionality.
Common interface for form item controls. Controls that should be connected to SiFormItemComponent must implement this interface and must be provided using the SI_FORM_ITEM_CONTROL token.
-
Generated ID that the SiFormItemComponent will assign to the element containing the error messages. Implementations of SiFormItemControl must generate this ID and assign it to the
aria-describedbyattribute of their focusable elements.errormessageId:
readonlystring | Signal<string>¶ -
The actual id of the control that should be used in the
forattribute of a label.id?:
readonlystring | Signal<string | undefined>¶ - readonly
If the control is meant to be used a checkbox. This affects the label positioning.
-
ID that should be assigned to the label element inside the SiFormItemComponent.
If the target control is not of type input, select or button, it cannot be referenced by a label. Instead, aria-labelledby must be used to create a reference to a label. In such a case, an implementation of SiFormItemControl must provide the id of the label in labelledby. SiFormItemComponent will apply the id to the label so that it can be used inside the control to reference it in the aria-labelledby attribute.
labelledby?:
readonlystring | Signal<string | undefined> | null¶
Except where otherwise noted, content on this site is licensed under MIT License.