Skip to content

ChipInput

A ChipInput allows users to create chips to filter content or make selections.

Guidelines

When to use chip inputs

The TextInput is utilized to build the ChipInput component, allowing information to be filtered by typing text that is transformed into a chip.

  • Create chips by entering letters or words and pressing the Enter key, clicking outside, or tabbing out.
  • Edit chips by clicking directly on them and typing.
  • Remove chips using its remove button.

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

Specification of ChipInput.

ChipInputs include the following items:

  1. TextInput
    The user can type letters or words within this input to create the chips and filter the information.
  2. Chip or chips
    The chip or chips created are stacked next to each other, and they are editable and can be removed.

Component limitations

The base min-width for the ChipInput component is set at @size-1600 (equivalent to 256px in the default Codex theme), but it can be customized to a smaller width if needed. There is no maximum width set.

Chips can vary in length as needed and will expand in width based on text length, with ellipsis applied if text exceeds the available width. Chips may stack into multiple lines within the input when needed.

Refer to the ChipInput component in Codex Figma.

Types

Depending on the placement of the chips, there are two types of ChipInput:

  1. 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.
  2. Chips separated from the input field
    In this case, the chips are placed in a box with Gray50 background in light mode above the input field once they are created.

Chip input types based on chip placement: chips within the input or chips separated from the input.

Interaction states

ChipInput has the following visually separate states:

Interaction states of ChipInput: default, hover on input, focus-active, filled, disabled, hover on chip’s remove button, error default, error focus, error filled, hover on editable chip,focus on editable chip and chip being edited.

  1. Default
  2. Hover on input
  3. Focus or active
  4. Filled
  5. Disabled
  6. Hover on chip’s remove button
  7. Hover on editable chip
  8. Focused editable chip
  9. Editing the chip
  10. Error default
  11. Error hover
  12. Error filled

Best practices

Consider the following recommendations when using chip inputs.

ChipInput with four chips included.

Do:
  • Use ChipInput to enable users to input multiple items within a single field.

ChipInput with just one chip included.

Don't:
  • Use ChipInput if only a single item input is anticipated. In this case, consider using alternative components like Select instead.

Keyboard navigation

KeyFunction
TabIt moves the focus between the chips within the input. When the focus is placed on the last chip, it moves the focus to the input to create more chips. While typing in the input, pressing it creates a chip with the typed text and then moves the focus to the next interactive element in tab order.
Shift + TabIt moves the focus to the previous chip within the input or to the previous interactive element in the page.
EnterWhile typing in the input, pressing Enter creates a chip with the typed text and keeps the input focused. If focused on a chip, pressing Enter makes the chip editable.
EscWhile typing in the input, pressing Esc creates a chip with the typed text. Once the chip is created, the input loses focus. When any of the chips or input is focused, pressing Esc removes the focus from the focused element.
backspaceIf the focus is placed on a chip, this key removes the chip and moves the focus to the previous chip. If it removes the last chip, it moves the focus to the input. If the cursor is at the start of the input, it moves the focus to the last chip.
Left arrow / Right arrowArrow keys navigate between the chips within the input when they are focused.

Demos

Configurable

chip 1
chip 2
NameValue
Props
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.

chip 1
chip 2

With icons

Chips added by the user cannot be added with icons, but icons can be included in chips provided by the parent component.

Camera
Article

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

chip 1
chip 2

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.

Alternative names help others easily find the function

With chip validation

To test chip text before a new chip is added, pass in a validation function via the chipValidator prop. If the chip text fails validation, a new chip will not be added and the "error" status will be set.

If you need access to the current value of the text input, for validation or other purposes, you can use v-model to bind a string ref to the ChipInput, just like you would with a TextInput.

In the example below, the input value is bound with v-model and is used to show the number of remaining characters allowed as the user is typing. A chipValidator is passed in that tests whether the text is 10 or fewer characters.

Alternative names help others easily find the function
10

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 nameDescriptionTypeDefault
inputChips(required)Current chips present in the input.

Provided by v-model binding in the parent component.
ChipInputItem[]
inputValueCurrent value of the text input. This prop is optional and should only be used if you need to keep track of the text input value for some reason (e.g. for validation).

Optionally provided by v-model:input-value binding in the parent component.
string|numbernull
separateInputWhether the text input should appear below the set of input chips.

By default, the input chips are inline with the input.
booleanfalse
statusstatus attribute of the input.ValidationStatusType'default'
chipValidatorValidation function for chip text. If it returns false, the chip will not be added and the error status will be set.ChipValidator(value: string|number)[]
disabledWhether the input is disabled.booleanfalse

Events

Event namePropertiesDescription
update:input-chipsinputChips ChipInputItem[] - The new set of inputChipsWhen the input chips change.
update:input-valueinputValue string|number - The new input valueWhen the input value changes. Only emitted if the inputValue prop is provided.