Skip to main content

API Reference

Core Props

PropTypeDefaultDescription
tagsITagsrequiredCurrent tags state object
updateState(tags: ITags) => voidrequiredFunction to update tags state
keysForTagstring' 'Character(s) that trigger tag creation
suggestionsstring[][]Array of suggestions for autocomplete
labelstringundefinedLabel text shown above the input
placeholderstring'Enter tags...'Input placeholder text
maxTagsnumberundefinedMaximum number of tags allowed
disabledbooleanfalseDisable the input

Types

ITags Interface

interface ITags {
tag: string; // Current input value
tagsArray: string[]; // Array of created tags
}

Event Props

PropTypeDescription
onTagPress(index: number, tag: string) => voidCalled when a tag is pressed
onTagDelete(index: number, tag: string) => voidCalled when a tag is deleted
onFocus() => voidCalled when input is focused
onBlur() => voidCalled when input loses focus
onChangeText(text: string) => voidCalled when input text changes

Style Props

PropTypeDescription
containerStyleStyleProp<ViewStyle>Main container style
inputContainerStyleStyleProp<ViewStyle>Input wrapper style
inputStyleStyleProp<TextStyle>Input text style
tagStyleStyleProp<ViewStyle>Tag container style
tagTextStyleStyleProp<TextStyle>Tag text style
deleteIconStylesStyleProp<ImageStyle>Delete icon style
labelStyleStyleProp<TextStyle>Label text style

Autocomplete Props

PropTypeDefaultDescription
maxSuggestionsnumber5Maximum suggestions to show
highlightMatchedTextbooleanfalseHighlight matched text
caseSensitivebooleanfalseCase-sensitive matching
showAutocompleteBorderbooleantrueShow borders between suggestions
autocompleteSuggestionStyleStyleProp<ViewStyle>-Suggestion item style
autocompleteSuggestionTextStyleStyleProp<TextStyle>-Suggestion text style

Custom Rendering Props

PropTypeDescription
renderTag(tag: string, index: number, onDelete: () => void) => ReactNodeCustom tag renderer
renderDeleteButton(onDelete: () => void, tag: string, index: number) => ReactNodeCustom delete button
renderSuggestion(suggestion: string, index: number, isHighlighted: boolean, onPress: () => void) => ReactNodeCustom suggestion renderer

Methods

Access these methods via a ref:

interface TagInputMethods {
focus(): void;
blur(): void;
clear(): void;
addTag(tag: string): void;
removeTag(index: number): void;
getTags(): string[];
}

Example usage:

const tagInputRef = useRef<TagInputMethods>(null);

// Later in your code
tagInputRef.current?.focus();