Customization
Custom Components
Provides you with the option of replacing a certain component inside the Select in order to change its appearance, structure, or functionality. To use your custom components, pass them into the customComponents prop.
You will receive two arguments for your custom component renderer function:
- Component props - all the props and functionality the original component uses in the Select.
- Inner props - actions and attributes that should be applied to the JSX elements of the component.
Example
Here is a simple example where we create a custom option component that contains a checkmark.
- Please select a value
Below is a list of every custom component you can pass to the customComponents prop, along with the componentProps and innerProps they provide.
Custom Option
Component Props
onOptionSelect
(isSelected: boolean, option: SelectOptionT, isDisabled: boolean) => void
SelectOptionT Reference: SelectOptionT
value
setValue
Dispatch<SetStateAction<T>> | ((arg: T) => void)
clearInput
() => void
focusInput
() => void
getSelectOptionsMap
() => Map<string, HTMLDivElement>
labelKey
keyof SelectOptionT
SelectOptionT Reference: SelectOptionT
clearInputOnSelect
boolean
isMultiValue
boolean
isDisabled
boolean
closeDropdown
() => void
resetFocus
() => void
isFocused
boolean
optionIndex
number
isSelected
boolean
option
isCategorized
boolean
categoryKey
keyof SelectOptionT
SelectOptionT Reference: SelectOptionT
Inner Props
onClick
(...args: any) => void
onMouseMove
(...args: any) => void
data-category
boolean
data-selected
boolean
key
string | number
ref
React.LegacyRef<HTMLDivElement>
id
string
className
string
Custom Option List
Component Props
handlePageChange
() => void
page
number
isLastPage
() => boolean | void
fetchOnScrollToBottom
boolean | undefined
displayedOptions
SelectOptionList | CategorizedSelectOptions
Types Reference: SelectOptionList
isCategorized
boolean
isLoading
boolean
handleScrollToBottom
() => void
Inner Props
wrapperClassName
string
ref
RefObject<HTMLDivElement>
listClassName
string
Custom Category
Component Props
value
categoryOptions
categoryName
keyof SelectOptionT
SelectOptionT Reference: SelectOptionT
selectedOptions
SelectOptionList | null
SelectOptionList Reference: SelectOptionList
focusedOptionIdx
number | null
renderOption
(option: SelectOptionT, index: number, focusedOptionIdx: number | null, selectedOptions: SelectOptionList | null) => React.JSX.Element
Types Reference: SelectOptionT
Inner Props
categoryHeaderClassName
string
categoryListClassName
string
Custom Input
Component Props
selectOptions
displayedOptions
SelectOptionList | CategorizedSelectOptions
Types Reference: SelectOptionList
value
selectOptionListRef
RefObject<HTMLDivElement>
setInputValue
StateSetter<string>
getOriginalOptions
() => SelectOptionList
SelectOptionList Reference: SelectOptionList
setSelectOptions
(options: SelectOptionList) => void
SelectOptionList Reference: SelectOptionList
handleInputChange
(e: ChangeEvent<HTMLInputElement>, value?: SelectOptionList) => void
SelectOptionList Reference: SelectOptionList
handleValueSelectOnKeyPress
() => void
focusedOptionIndex
number | null
focusedOptionCategory
keyof SelectOptionT
SelectOptionT Reference: SelectOptionT
focusPreviousOption
() => void
focusNextOption
(fallbackDirection?: "next" | "previous" | "opposite") => void
openDropdown
() => void
closeDropdown
() => void
clearAllValues
() => void
inputValue
string
debounceInputUpdate
boolean
preventInputUpdate
(e: ChangeEvent<HTMLInputElement>, updatedInputValue: string) => boolean
isLoading
boolean
Custom Multi-Value
Component Props
value
labelKey
keyof SelectOptionT
SelectOptionT Reference: SelectOptionT