Sajari UI

TagInput

TagInput component is a robust, minimal and performant input field for creating multiple tags.

Import

Usage

Here's a basic usage of the TagInput component.

Editable Example
example tag

Sizes

Editable Example
example tag

Max tags

Editable Example
example tag

Editable

Editable Example
example tag

Read Only

Editable Example
example tag

Remove on backspace

Editable Example
example tag

Allow line break

Editable Example
example tag

Validator

Editable Example
example tag

Add tag on blur

Editable Example
example tag

Props

The TagInput component composes PseudoBox so you can pass all PseudoBox props, and React.InputHTMLAttributes.

NameTypeDefaultDescription
tagsstring[]requiredA string array containing a list of tags.
onChangefunctionrequiredA function that receives the updated tags, used to update your state.
placeholderstringThe placeholder for the inner input field.
sizesm, mdmdThe size of the input field.
maxTagsnumberSet the maximum number of tags allowed. Once reached, the inner input field will be hidden. Defaults to undefined which is unlimited.
editablebooleanfalseIf enabled, a user can click a tag and change it's value directly.
readOnlybooleanfalseIf enabled, tags cannot be edited or removed and the inner input field is hidden.
removeOnBackspacebooleantrueIf enabled, a user can delete a tag if they press backspace when focused on the inner input field or a specific tag input field.
allowLineBreakbooleanfalseIf enabled, tags will be broken into a new line when the container is overflow.
validatorfunctionA function that receives a specific tag value that a user is attempting to add and returns a boolean indicating if it is valid. If invalid, the tag will not be added.
tagRender(props: {tag: string, onUpdate: function, onDelete: function, index: number}) => JSX.ElementCustom render view for tags.
hasInputWrapperbooleantrueIf true, use form input style.
splitCharstringAdd multiple items by splitting the input value by the provided string.
addTagsOnBlurbooleanfalseIf enabled, a tag will be added or updated on blur.
onInputChange(string) => voidA callback function when the input changes.