SelectCommonProps interface

Signature

  1. export interface SelectCommonProps<T>

Import

  1. import { SelectCommonProps } from '@grafana/ui';

Properties

PropertyTypeDescription
“aria-label”stringAria label applied to the input field
allowCreateWhileLoadingboolean
allowCustomValueboolean
autoFocusbooleanFocus is set to the Select when rendered
backspaceRemovesValueboolean
classNamestring
closeMenuOnSelectboolean
componentsanyUsed for custom components. For more information, see react-select
defaultValueany
disabledboolean
filterOption(option: SelectableValue<T>, searchQuery: string) => boolean
formatCreateLabel(input: string) => stringFunction for formatting the text that is displayed when creating a new value
formatOptionLabel(item: SelectableValue<T>, formatOptionMeta: FormatOptionLabelMeta<T>) => React.ReactNode
getOptionLabel(item: SelectableValue<T>) => React.ReactNode
getOptionValue(item: SelectableValue<T>) => string
idstringThe id to set on the SelectContainer component. To set the id for a label (with htmlFor),
inputIdstringThe id of the search input. Use this to set a matching label with htmlFor
inputValuestring
invalidboolean
isClearableboolean
isLoadingboolean
isMultiboolean
isOpenboolean
isOptionDisabled() => boolean
isSearchablebooleanDisables the possibility to type into the input
isValidNewOption(inputValue: string, value: SelectableValue<T> | null, options: OptionsOrGroups<unknown, GroupBase<unknown>>) => booleanallowCustomValue must be enabled. Determines whether the “create new” option should be displayed based on the current input value, select value and options array.
loadingMessagestringMessage to display isLoading=true
maxMenuHeightnumber
maxVisibleValuesnumber
menuPlacement‘auto’ | ‘bottom’ | ’top’
menuPosition‘fixed’ | ‘absolute’
menuShouldPortalbooleanSetting to false will prevent the menu from portalling to the body.
minMenuHeightnumber
noOptionsMessagestringThe message to display when no options could be found
onBlur() => void
onChange(value: SelectableValue<T>, actionMeta: ActionMeta) => {} | void
onCloseMenu() => void
onCreateOption(value: string) => voidallowCustomValue must be enabled. Function decides what to do with that custom value.
onFocus() => void
onInputChange(value: string, actionMeta: InputActionMeta) => void
onKeyDown(event: React.KeyboardEvent) => void
onOpenMenu() => void
openMenuOnFocusboolean
optionsArray<SelectableValue<T>>
placeholderstring
prefixJSX.Element | string | nullitem to be rendered in front of the input
renderControlControlComponent<T>Use a custom element to control Select. A proper ref to the renderControl is needed if ‘portal’ isn’t set to null
showAllSelectedWhenOpenboolean
tabSelectsValueboolean
valueSelectValue<T> | null
widthnumber | ‘auto’Sets the width to a multiple of 8px. Should only be used with inline forms. Setting width of the container is preferred in other cases.

“aria-label” property

Aria label applied to the input field

Signature

  1. ['aria-label']?: string;

allowCreateWhileLoading property

Signature

  1. allowCreateWhileLoading?: boolean;

allowCustomValue property

Signature

  1. allowCustomValue?: boolean;

autoFocus property

Focus is set to the Select when rendered

Signature

  1. autoFocus?: boolean;

backspaceRemovesValue property

Signature

  1. backspaceRemovesValue?: boolean;

className property

Signature

  1. className?: string;

closeMenuOnSelect property

Signature

  1. closeMenuOnSelect?: boolean;

components property

Used for custom components. For more information, see react-select

Signature

  1. components?: any;

defaultValue property

Signature

  1. defaultValue?: any;

disabled property

Signature

  1. disabled?: boolean;

filterOption property

Signature

  1. filterOption?: (option: SelectableValue<T>, searchQuery: string) => boolean;

formatCreateLabel property

Function for formatting the text that is displayed when creating a new value

Signature

  1. formatCreateLabel?: (input: string) => string;

formatOptionLabel property

Signature

  1. formatOptionLabel?: (item: SelectableValue<T>, formatOptionMeta: FormatOptionLabelMeta<T>) => React.ReactNode;

getOptionLabel property

Signature

  1. getOptionLabel?: (item: SelectableValue<T>) => React.ReactNode;

getOptionValue property

Signature

  1. getOptionValue?: (item: SelectableValue<T>) => string;

id property

The id to set on the SelectContainer component. To set the id for a label (with htmlFor),

Signature

  1. id?: string;

inputId property

The id of the search input. Use this to set a matching label with htmlFor

Signature

  1. inputId?: string;

inputValue property

Signature

  1. inputValue?: string;

invalid property

Signature

  1. invalid?: boolean;

isClearable property

Signature

  1. isClearable?: boolean;

isLoading property

Signature

  1. isLoading?: boolean;

isMulti property

Signature

  1. isMulti?: boolean;

isOpen property

Signature

  1. isOpen?: boolean;

isOptionDisabled property

Signature

  1. isOptionDisabled?: () => boolean;

isSearchable property

Disables the possibility to type into the input

Signature

  1. isSearchable?: boolean;

isValidNewOption property

allowCustomValue must be enabled. Determines whether the “create new” option should be displayed based on the current input value, select value and options array.

Signature

  1. isValidNewOption?: (inputValue: string, value: SelectableValue<T> | null, options: OptionsOrGroups<unknown, GroupBase<unknown>>) => boolean;

loadingMessage property

Message to display isLoading=true

Signature

  1. loadingMessage?: string;

maxMenuHeight property

Signature

  1. maxMenuHeight?: number;

maxVisibleValues property

Signature

  1. maxVisibleValues?: number;

menuPlacement property

Signature

  1. menuPlacement?: 'auto' | 'bottom' | 'top';

menuPosition property

Signature

  1. menuPosition?: 'fixed' | 'absolute';

menuShouldPortal property

Setting to false will prevent the menu from portalling to the body.

Signature

  1. menuShouldPortal?: boolean;

minMenuHeight property

Signature

  1. minMenuHeight?: number;

noOptionsMessage property

The message to display when no options could be found

Signature

  1. noOptionsMessage?: string;

onBlur property

Signature

  1. onBlur?: () => void;

onChange property

Signature

  1. onChange: (value: SelectableValue<T>, actionMeta: ActionMeta) => {} | void;

onCloseMenu property

Signature

  1. onCloseMenu?: () => void;

onCreateOption property

allowCustomValue must be enabled. Function decides what to do with that custom value.

Signature

  1. onCreateOption?: (value: string) => void;

onFocus property

Signature

  1. onFocus?: () => void;

onInputChange property

Signature

  1. onInputChange?: (value: string, actionMeta: InputActionMeta) => void;

onKeyDown property

Signature

  1. onKeyDown?: (event: React.KeyboardEvent) => void;

onOpenMenu property

Signature

  1. onOpenMenu?: () => void;

openMenuOnFocus property

Signature

  1. openMenuOnFocus?: boolean;

options property

Signature

  1. options?: Array<SelectableValue<T>>;

placeholder property

Signature

  1. placeholder?: string;

prefix property

item to be rendered in front of the input

Signature

  1. prefix?: JSX.Element | string | null;

renderControl property

Use a custom element to control Select. A proper ref to the renderControl is needed if ‘portal’ isn’t set to null

Signature

  1. renderControl?: ControlComponent<T>;

showAllSelectedWhenOpen property

Signature

  1. showAllSelectedWhenOpen?: boolean;

tabSelectsValue property

Signature

  1. tabSelectsValue?: boolean;

value property

Signature

  1. value?: SelectValue<T> | null;

width property

Sets the width to a multiple of 8px. Should only be used with inline forms. Setting width of the container is preferred in other cases.

Signature

  1. width?: number | 'auto';