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¶

- Label (optional), 2. Pills, 3. Container, 4. Message (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, ...]
})
SiPillsInputComponent API Documentation¶
si-pills-inputCommon 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.
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 aria-describedby attribute of the pills-input. Use this to reference the element containing the error message(s) for the pills-input. It will be picked by the SiFormItemComponent if the pills-input is used inside a form item. |
| id ¶ | string | __si-pills-input-${SiPillsInputComponent.idCounter++} | The identifier of the pills-input. Will be generated if not provided. |
| 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 | |
| placeholder ¶ | string | The placeholder to be shown if no value is currently present. | |
| readonly ¶ | boolean | false | Whether the pills-input is readonly |
SiPillsInputCsvDirective API Documentation¶
[siPillsInputCsv]Input Properties¶
| Name | Type | Default | Description |
|---|---|---|---|
| pillsInputCsvItemRegex ¶ | RegExp | undefined |
Attributes and Methods¶
| Name | Type | Default | Description |
|---|---|---|---|
| (readonly) separatorRegex ¶ | WritableSignal<RegExp> | SEPARATOR_REGEX | Regex to split the input value into segments. |
Types Documentation¶
Variable |
|---|
| 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. | |||||
|---|---|---|---|---|---|
|
Translatable import imported from @siemens/element-translate-ng |
|---|
|
| Interface for form error mapper. It resolves a key to either a translatable string or function which is called with the validation error for its key and should return a translatable string. | |
|---|---|
| |
|
| ||||||||||||
| ||||||||||||
|
| |||||||||||
| |||||||||||
| |||||||||||
|
| ||||||||||||
| ||||||||||||
|
Except where otherwise noted, content on this site is licensed under MIT License.