TokenInput
View Source
Allow users to add and delete multiple items, optionally using autocompletion as they type to find each item when paired with Combobox.Popover.
apple
pears
oranges
bananas
kiwis
Props
Accepts WrapView props.
onChange
(event: {
added: boolean
token: T
tokenIndex: number
tokens: T[]
}) => voidCallback when a token has been added or removed.
renderInput
(
inputProps: object,
options: {
addToken: (token: T) => void
clearInputValue: () => void
removeToken: (token: T, focusIndex?: number) => void
selectFirstToken: () => void
selectLastToken: () => void
}
) => React.ReactElementControl how the internal input is rendered, inputProps must be passed
through to the rendered input.
renderToken
(
token: T,
options: {
keyboardControls: {
onKeyDown: (e: React.KeyboardEvent) => void
tabIndex: number
}
removeToken: (token: T, focusIndex?: number) => void
selectFirstToken: () => void
selectLastToken: () => void
selectNextToken: () => void
selectPreviousToken: () => void
tokenIndex: number
}
) => React.ReactElementControl how a token is rendered. As long as this function returns a string, it will use a default badge, otherwise pass any custom component and functionality you need.
size
stringtokens
ArrayControlled set of tokens.