Tag picker
A tag picker is used to select one or more tags from a list.
Examples
Contents
APIsAPIs
ISelectedTagProps
ariaHiddenInherited From: IPillProps
boolean
Whether the Pill should apply aria-hidden={true} to hide the element from screen readers.
This should only be done if some other element is responsible for reading the contents of the Pill.
ariaLabelInherited From: IPillProps
string
Optional aria label to pass to the pill. Will default to the this.props.children if this.props.children is a string.
classNameInherited From: IPillProps
string
Optional className to emit on the root element
colorInherited From: IPillProps
IColor
Background color for the pill
Ignored unless variant is set to Colored
If variant is set to Colored and this is not provided, we'll render as Standard and emit a warning to the console
containsCountfalseInherited From: IPillProps
boolean
Optional boolean to set if the pill is displaying a count of something
contentrequired
string | JSX.Element
Content to show in the pill when selected.
contentClassNameInherited From: IPillProps
string
Optional className to emit on the content
excludeFocusZoneInherited From: IPillProps
boolean
The element has been exluded from a current focusZone by default.
excludeTabStopInherited From: IPillProps
boolean
The element should not be tabable but still should be able to receieve focus.
iconPropsInherited From: IPillProps
Props used to render the pill icon
If a filled visual is provided as well, we only render the visual
and will emit a warning to the console
Using with Size = PillSize.Compact will result in no icon being rendered and a warning being printed to the console
idInherited From: IPillProps
string
Id for the root element
onBlurInherited From: IPillProps
(event: React.FocusEvent<HTMLElement>) => void
Callback to handle blur events
onClickInherited From: IPillProps
(event?: React.MouseEvent<HTMLDivElement>) => void
onClick handler for the pill itself
onFocusInherited From: IPillProps
(event: React.FocusEvent<HTMLDivElement>) => void
onFocus handler for the pill itself
onMouseEnterInherited From: IPillProps
(event: React.MouseEvent<HTMLDivElement>) => void
onMouseEnter for root element
onMouseLeaveInherited From: IPillProps
(event: React.MouseEvent<HTMLDivElement>) => void
onMouseLeave for root element
onRemoveClickInherited From: IPillProps
(event: React.MouseEvent<HTMLDivElement>) => void
Renders the remove button if provided
Handler to remove the pill
onRenderFilledVisualInherited From: IPillProps
() => JSX.Element
Custom rendering function for left-aligned visuals
Using with size = PillSize.Compact will trigger a warning in the console
and will not render anything
removeButtonTabIndexInherited From: IPillProps
number
Explicit tab index overrides any other focus-zone / focus-group controlled indexing for the remove button
sizeRegularInherited From: IPillProps
Use of iconProps, onRemoveClick, or onRenderFilledVisual in conjunction with Compact will result in those elements not being rendered
and a warning being printed to the console
tabIndexInherited From: IPillProps
number
Explicit tab index overrides any other focus-zone / focus-group controlled indexing
variantStandardInherited From: IPillProps
If this is set to Colored and color is not provided, we'll render as Standard and emit a warning to the console
ITagPickerProps<T>
areTagsEqualrequired
(first: T, second: T) => boolean
Callback to determine if two tags are identical.
ariaLabel
string
Aria label
ariaLabelledBy
string
Id of another element which labels this one for screen reader users.
Defaults to FormItem's label if this TagPicker is used within.
className
string
css class added to the tag picker.
convertItemToPillrequired
(item: T, index: number) => ISelectedTagProps
Callback which converts one of the tag items to a pill.
createDefaultItem
(searchString: string) => T | undefined
Callback to create a default item from a search string.
deliminator
string
String used to break apart a search string. If this is set, you should also define onDelimitedSearch
to handle input where the user has pasted in several items delimited
noResultsFoundTextrequired
string
Text to show when the search does not show any suggestions
onBlur
(text?: string) => void
Callback when focus has left the TagPicker.
@param text text value of the tag pick before focusing away
onDelimitedSearch
(strings: string[]) => void
Callback when the user has typed or pasted a string with the deliminator. The callback returns the equivalent of searchString.split(this.props.deliminator)
onEmptyInputFocus
() => void
Callback when the user clicks or focuses on an empty text field. This can be used to show an MRU list
onFocus
() => void
Callback when focus has entered the TagPicker input field.
onSearchChangedrequired
(searchValue: string) => void
Callback when the text value of the input tag has changed. This callback should change the suggestions and suggestionsLoading values appropriately.
onSearchChangedDebounceWait250
number
Number in milliseconds that determines how long to debounce the supplied onSearchChanged or onDelimitedSearch function for.
onSuggestionExpanded
(tag: T) => void
Callback for when the right arrow key is pressed inside the tag picker.
onTagAddedrequired
(tag: T) => void
Callback when a tag is chosen. Unless the tag is not valid, the consumer should update the suggestions list.
onTagRemovedrequired
(tag: T) => void
Callback when a tag is removed. Unless the tag is not valid, the consumer should update the suggestions list.
onTagsRemoved
(tags: T[]) => void
Callback when a group of tags is removed. Unless the tag is not valid, the consumer should update the suggestions list. If this is not
specified, then the user cannot select multiple tags for deletion.
placeholderText
string
Placeholder text to show when the input has no text and there are no selected tags
prefixIconProps
Icon props to show at the beginning of the picker control when there is nothing selected
renderSuggestionItemrequired
(itemProps: ISuggestionItemProps<T>) => JSX.Element
Callback to render the suggestion row for a given suggestion.
selectedTagsrequired
IReadonlyObservableArray<T> | T[]
List of tags currently selected by the user. This prop is 100% controlled
by the consumer. onTagAdded/onTagRemoved/onTagsRemoved must also be implemented in order to
work properly. If this value is a an item, the prop must be
updated to cause the Tag Picker to re-render. If this value is an
ObservableValue, then changing its value will cause the Tag Picker
to re-render.
shouldBlurClear
() => boolean
Function to determine if blur should clear the textfield and close the suggestions list
suggestionsrequired
IReadonlyObservableArray<T> | T[]
List of suggestions for the given search value. This prop is 100% controlled
by the consumer. onSearchChanged must also be implemented in order to
work properly. If this value is a an item, the prop must be
updated to cause the Tag Picker to re-render. If this value is an
ObservableValue, then changing its value will cause the Tag Picker
to re-render.
suggestionsContainerAriaLabel
string
Aria label of the suggestions container
suggestionsLoadingrequired
IReadonlyObservableValue<boolean> | boolean
boolean indicating if the control is waiting to generate its suggestions list. This prop is 100% controlled
by the consumer. onSearchChanged must also be implemented in order to
work properly. If this value is a an T, the prop must be
updated to cause the Tag Picker to re-render. If this value is an
ObservableValue, then changing its value will cause the Tag Picker
suggestionsLoadingText
string
String to show when results are loading