@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
80 lines (79 loc) • 4.26 kB
TypeScript
import { BoxProps, ElementProps, Factory, MantineColor, Primitive, StylesApiProps } from '../../core';
import { ComboboxItem, ComboboxLikeProps, ComboboxLikeRenderOptionInput, ComboboxLikeStylesNames } from '../Combobox';
import { __BaseInputProps, __InputStylesNames, ClearSectionMode, InputClearButtonProps, InputVariant } from '../Input';
import { ScrollAreaProps } from '../ScrollArea';
export type SelectStylesNames = __InputStylesNames | ComboboxLikeStylesNames;
export interface SelectProps<Value extends Primitive = string> extends BoxProps, __BaseInputProps, ComboboxLikeProps<Value>, StylesApiProps<SelectFactory>, ElementProps<'input', 'onChange' | 'size' | 'value' | 'defaultValue'> {
/** Controlled component value */
value?: Value | null;
/** Uncontrolled component default value */
defaultValue?: Value | null;
/** Called when value changes */
onChange?: (value: Value | null, option: ComboboxItem<Value>) => void;
/** Called when the clear button is clicked */
onClear?: () => void;
/** Determines whether the select should be searchable @default false */
searchable?: boolean;
/** Displays check icon near the selected option label @default true */
withCheckIcon?: boolean;
/** Aligns unchecked labels with the checked one @default false */
withAlignedLabels?: boolean;
/** Position of the check icon relative to the option label @default 'left' */
checkIconPosition?: 'left' | 'right';
/** Message displayed when no options match the search query or when there is no data */
nothingFoundMessage?: React.ReactNode;
/** Controlled search value */
searchValue?: string;
/** Default search value */
defaultSearchValue?: string;
/** Called when search changes */
onSearchChange?: (value: string) => void;
/** Allows deselecting the selected option by clicking it @default true */
allowDeselect?: boolean;
/** Displays clear button in the right section when component has value @default false */
clearable?: boolean;
/** Determines how the clear button and rightSection are rendered @default 'both' */
clearSectionMode?: ClearSectionMode;
/** Props passed down to the clear button */
clearButtonProps?: InputClearButtonProps;
/** Props passed down to the hidden input */
hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;
/** A function to render content of the option, replaces the default content of the option */
renderOption?: (item: ComboboxLikeRenderOptionInput<ComboboxItem>) => React.ReactNode;
/** Props passed down to the underlying `ScrollArea` component in the dropdown */
scrollAreaProps?: ScrollAreaProps;
/** Controls color of the default chevron, by default depends on the color scheme */
chevronColor?: MantineColor;
/** Automatically selects the highlighted option when input loses focus @default false */
autoSelectOnBlur?: boolean;
/** Opens dropdown when input receives focus (requires searchable={true}) @default true */
openOnFocus?: boolean;
}
export type SelectFactory = Factory<{
props: SelectProps;
ref: HTMLInputElement;
stylesNames: SelectStylesNames;
variant: InputVariant;
signature: <Value extends Primitive = string>(props: SelectProps<Value>) => React.JSX.Element;
}>;
export declare const Select: (<Value extends Primitive = string>(props: SelectProps<Value>) => React.JSX.Element) & import("../..").ThemeExtend<{
props: SelectProps;
ref: HTMLInputElement;
stylesNames: SelectStylesNames;
variant: InputVariant;
signature: <Value extends Primitive = string>(props: SelectProps<Value>) => React.JSX.Element;
}> & import("../..").ComponentClasses<{
props: SelectProps;
ref: HTMLInputElement;
stylesNames: SelectStylesNames;
variant: InputVariant;
signature: <Value extends Primitive = string>(props: SelectProps<Value>) => React.JSX.Element;
}> & Record<string, never> & import("../..").FactoryComponentWithProps<{
props: SelectProps;
ref: HTMLInputElement;
stylesNames: SelectStylesNames;
variant: InputVariant;
signature: <Value extends Primitive = string>(props: SelectProps<Value>) => React.JSX.Element;
}> & {
displayName?: string;
};