diff --git a/__stories__/helpers/constants/options-data.ts b/__stories__/helpers/constants/options-data.ts
index 44a5604f..14f5983c 100644
--- a/__stories__/helpers/constants/options-data.ts
+++ b/__stories__/helpers/constants/options-data.ts
@@ -1,10 +1,10 @@
import type { CityOption, PackageOption } from '../../types';
export const PACKAGE_OPTIONS: PackageOption[] = [
- { id: 1, name: 'react' },
+ { id: 1, name: 'react', description: 'React is a JavaScript library for creating user interfaces'},
{ id: 2, name: 'react-dom' },
{ id: 3, name: 'reactstrap' },
- { id: 4, name: 'react-scripts' },
+ { id: 4, name: 'react-scripts', description: 'Configuration and scripts for Create React App.' },
{ id: 5, name: 'react-window' }
];
diff --git a/__stories__/helpers/styled/index.ts b/__stories__/helpers/styled/index.ts
index 7949da96..f34b0812 100644
--- a/__stories__/helpers/styled/index.ts
+++ b/__stories__/helpers/styled/index.ts
@@ -387,10 +387,24 @@ export const OptionContainer = styled.div`
flex-direction: row;
`;
+export const OptionContent = styled.div`
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+`;
+
export const OptionName = styled.span`
color: #515151;
font-size: 1em;
font-weight: 600;
margin-left: 1px;
margin-bottom: 1.5px;
-`;
\ No newline at end of file
+`;
+
+export const OptionDescription = styled.span`
+ color: #515151;
+ font-size: 1em;
+ font-weight: 300;
+ margin-left: 1px;
+ margin-bottom: 1.5px;
+`;
diff --git a/__stories__/index.stories.tsx b/__stories__/index.stories.tsx
index 3b1b8029..f6e8688a 100644
--- a/__stories__/index.stories.tsx
+++ b/__stories__/index.stories.tsx
@@ -38,7 +38,9 @@ import {
CardBody,
OtherSpan,
OptionContainer,
+ OptionContent,
OptionName,
+ OptionDescription,
ReactSvg,
ChevronDownSvg,
MenuPortalElement,
@@ -798,6 +800,25 @@ export const Advanced = () => {
const getIsOptionDisabled = useCallback((x: PackageOption): boolean => x.name === PACKAGE_OPTIONS[3].name, []);
const renderOptionLabel = useCallback(
+ (option: PackageOption): ReactNode => (
+
+
+
+
+
+
+ {option.name}
+ {option.description && {option.description}}
+
+
+ ),
+ [getIsOptionDisabled]
+ );
+
+ const renderControlLabel = useCallback(
(option: PackageOption): ReactNode => (
{
themeConfig={THEME_CONFIG}
caretIcon={customCaretIcon}
getOptionValue={getOptionValue}
+ menuItemSize={70}
renderOptionLabel={renderOptionLabel}
+ renderControlLabel={renderControlLabel}
getIsOptionDisabled={getIsOptionDisabled}
/>
diff --git a/__stories__/types/index.d.ts b/__stories__/types/index.d.ts
index 5da72ee8..890342fd 100644
--- a/__stories__/types/index.d.ts
+++ b/__stories__/types/index.d.ts
@@ -14,4 +14,5 @@ export type CityOption = Readonly<{
export type PackageOption = Readonly<{
id: number;
name: string;
+ description?: string;
}>;
\ No newline at end of file
diff --git a/src/Select.tsx b/src/Select.tsx
index 5b018bc1..361a9e9e 100644
--- a/src/Select.tsx
+++ b/src/Select.tsx
@@ -152,6 +152,7 @@ export type SelectProps = Readonly<{
onInputBlur?: FocusEventHandler;
onInputFocus?: FocusEventHandler;
renderOptionLabel?: (data: OptionData) => ReactNode;
+ renderControlLabel?: (data: OptionData) => ReactNode;
getIsOptionDisabled?: (data: OptionData) => boolean;
getFilterOptionString?: (option: MenuOption) => string;
renderMultiOptions?: (params: MultiParams) => ReactNode;
@@ -261,6 +262,7 @@ const Select = forwardRef((
blurInputOnSelect,
menuItemDirection,
renderOptionLabel,
+ renderControlLabel,
renderMultiOptions,
menuScrollDuration,
filterIgnoreAccents,
@@ -313,6 +315,7 @@ const Select = forwardRef((
const getOptionLabelFn = useMemo(() => getOptionLabel || GET_OPTION_LABEL_DEFAULT, [getOptionLabel]);
const getOptionValueFn = useMemo(() => getOptionValue || GET_OPTION_VALUE_DEFAULT, [getOptionValue]);
const renderOptionLabelFn = useMemo(() => renderOptionLabel || getOptionLabelFn, [renderOptionLabel, getOptionLabelFn]);
+ const renderControlLabelFn = useMemo(() => renderControlLabel || renderOptionLabelFn, [renderControlLabel, renderOptionLabelFn]);
// Custom hook abstraction that debounces search input value (opt-in)
const debouncedInputValue = useDebounce(inputValue, inputDelay);
@@ -764,7 +767,7 @@ const Select = forwardRef((
selectedOption={selectedOption}
focusedMultiValue={focusedMultiValue}
renderMultiOptions={renderMultiOptions}
- renderOptionLabel={renderOptionLabelFn}
+ renderOptionLabel={renderControlLabelFn}
removeSelectedOption={removeSelectedOption}
/>