A TextInputWithTokens
component supports all of the features of a TextInput component, but it can render a list of Tokens next to the area a user types in.
By default, the Token
component is used to render the tokens in the input. If this component does not make sense for the kinds of tokens you're rendering, you can pass a component to the tokenComponent
prop
By default, all tokens will be visible when the component is rendered.
If the component is being used in an area where it's height needs to be constrained, there are options to limit the height of the input.
Name | Type | Default | Description |
---|---|---|---|
tokens Required | TokenProps[] | The array of tokens to render | |
onTokenRemove Required | (tokenId: string|number) => void | The function that gets called when a token is removed | |
tokenComponent | React.ComponentType<any> | Token | The component used to render each token |
maxHeight | React.CSSProperties['maxHeight'] | The maximum height of the component. If the content in the input exceeds this height, it will scroll vertically | |
preventTokenWrapping | boolean | false | Whether tokens should render inline horizontally. By default, tokens wrap to new lines |
size | 'small' | 'medium' | 'large' | 'xlarge' | xlarge | The size of the tokens and text input |
hideTokenRemoveButtons | boolean | false | Whether the remove buttons should be rendered in the tokens |
validationStatus | 'error' | 'success' | Style the input to match the status | |
visibleTokenCount | number | The number of tokens to display before truncating |