React Native · Components
TagInput
Tag field: type and add a tag with a comma or the "done" key, remove it with the chip's × button; backspace in an empty input removes the last tag.
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Email recipients: split by space/comma/semicolon, validate
Hashtag: # is removed, only letters/digits/dashes, color by tag
- #urgent
- #design
- #frontend
Team members: from the list only, search on the server
Read only
- Turkish
- English
- Deutsch
Import
TagInput
componentTag field: type and add a tag with a comma or the "done" key, remove it with the chip's × button; backspace in an empty input removes the last tag. Rules are the same as the web TagInput (@yasinsensoy/core/tag-rules): duplicates, limit, length, pattern and validation; the reason for a rejected text is written below. A pasted list is split at separators.
Examples
TagRejectReason
typeWhy a tag wasn't added.
TagValidator
typeTag validator. Returns true (or nothing) when valid, false or an error message to show when invalid.
Examples
TagSuggestion
typeSuggestion: text, or a value + display name.
TagInputProps
interfaceTagInput props.
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
variant? | FieldVariant | "outline" | Appearance. See FieldVariant. |
value? | readonly string[] | Tags (controlled). | |
defaultValue? | readonly string[] | Initial tags (uncontrolled). | |
onValueChange? | (tags: string[]) => void | When the tags change. | |
onTagAdd? | (tag: string) => void | When a tag is added. | |
onTagRemove? | (tag: string) => void | When a tag is removed. | |
onReject? | (text: string, reason: TagRejectReason, message: string) => void | When a text cannot be added (the message is already shown below). | |
items? | readonly TagSuggestion[] | Suggestions: filtered as you type and shown as tappable chips under the field; tags already added are not shown. | |
allowCustomValue? | boolean | true | Allow adding text not in the suggestions. |
separators? | readonly string[] | [","] | Separators that split the text while typing or pasting. |
max? | number | Maximum tags; when given a 3/10 counter shows. | |
maxLength? | number | Maximum characters of a tag. | |
pattern? | RegExp | Pattern the whole tag must match. | |
validate? | TagValidator | Extra validation: return false or a message if invalid. | |
transform? | (text: string) => string | Transforms the text before adding (e.g. lowercasing). | |
allowDuplicates? | boolean | false | Allow the same tag more than once. |
addOnBlur? | boolean | true | The typed text becomes a tag on blur. |
tone? | Tone | ((tag: string) => Tone) | "neutral" | Tag color, or a color per tag. |
renderTag? | (tag: string) => ReactNode | Render the tag content yourself. | |
inputValue? | string | Text in the input (controlled). | |
onInputChange? | (text: string) => void | When the text in the input changes. | |
placeholder? | string | Text shown while the box is empty. | |
icon? | IconProp | Icon at the start of the box. | |
clearable? | boolean | Button that removes all tags. | |
readOnly? | boolean | Read-only. | |
accessibilityLabel? | string | Screen reader label. | |
style? | StyleProp<ViewStyle> | Style of the box. |