ChipInput
A ChipInput allows users to create chips to filter content or make selections. Chips are created by typing characters or words and pressing the Enter key.
Guidelines
Using chip inputs
The ChipInput component utilizes a TextInput, enabling users to filter information by typing text that transforms into a chip. These chips can be edited by clicking directly on them or removed by interacting with the embedded remove button within each chip.
Use the ChipInput when users need to simplify a complex filtering process or when they need to edit the filters applied there.
Avoid using ChipInput if the filtering process is simple and doesn't require custom edits. In case you need to select static options that don't require editing, consider using a Checkbox group instead.
Specifications
ChipInputs include the following items:
- TextInput
The user can type letters or words within this input to create the chips and filter the information. - Chip or chips
The chip or chips created are stacked next to each other, and they are editable and can be removed.
Refer to the ChipInput component in Codex Figma.
Types
Depending on the placement of the chips, there are two types of ChipInput:
- Chips within the input field
In this case, when the chips are created they are placed next to the input’s placeholder text, and they are stacked next to each other. - Chips separated from the input field
In this case, the chips are placed in a light gray box above the input field once they are created.
Interaction states
ChipInput has the following visually separate states:
- Default
- Hover on input
- Focus or active
- Filled
- Disabled
- Hover on chip’s remove button
- Error default
- Error focus
- Error filled
- Hover on editable chip
- Focused editable chip
- Editing the chip
Demos
Configurable
Name | Value |
---|---|
Props | |
chipAriaDescription | |
separateInput | |
status | |
disabled | |
View | |
Reading direction |
Basic Usage
Pass an array of chip data to the input using v-model:input-chips
. When the user adds or removes a chip, the array will automatically be updated.
Text for the aria-label
of each chip's "remove" button is a required prop.
With icons
Chips added by the user cannot be added with icons, but icons can be included in chips provided by the parent component.
With placeholder
Placeholder and other attributes of the <input>
element can be bound to the ChipInput component and will be passed down to the <input>
element within.
Disabled
Form field
A ChipInput can be wrapped in the Field component to add features like a semantic label, description and help text, validation messages, and more. See the Field page for more information.
Vue usage
Attributes passed to input
This component will pass any HTML attributes applied to it, except for CSS class, to the <input>
element within the component.
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
chipAriaDescription (required) | aria-description of each input chip.Text must be provided for accessibility purposes. This prop is temporary and will be removed once T345386 is resolved. | string | - | |
inputChips (required) | Current chips present in the input. Provided by v-model binding in the parent component. | ChipInputItem[] | - | |
separateInput | Whether the text input should appear below the set of input chips. By default, the input chips are inline with the input. | boolean | - | false |
status | status attribute of the input. | ValidationStatusType | 'default' , 'error' | 'default' |
disabled | Whether the input is disabled. | boolean | - | false |
Events
Event name | Properties | Description |
---|---|---|
update:input-chips | inputChips ChipInputItem[] - The new set of inputChips | When the input chips change. |