diff --git a/components/lib/treeselect/TreeSelect.js b/components/lib/treeselect/TreeSelect.js
index c04667d49b..8f0e3b0e6d 100644
--- a/components/lib/treeselect/TreeSelect.js
+++ b/components/lib/treeselect/TreeSelect.js
@@ -634,6 +634,7 @@ export const TreeSelect = React.memo(
};
const createContent = () => {
+ const message = ObjectUtils.getJSXElement(props.emptyMessage, props) || localeOption('emptyMessage');
const emptyMessageProps = mergeProps(
{
className: cx('emptyMessage')
@@ -671,7 +672,7 @@ export const TreeSelect = React.memo(
__parentMetadata={{ parent: metaData }}
>
- {hasNoOptions &&
{props.emptyMessage || localeOption('emptyMessage')}
}
+ {hasNoOptions && {message}
}
>
);
};
diff --git a/components/lib/treeselect/treeselect.d.ts b/components/lib/treeselect/treeselect.d.ts
index 4549877164..9d0c4384a7 100644
--- a/components/lib/treeselect/treeselect.d.ts
+++ b/components/lib/treeselect/treeselect.d.ts
@@ -411,8 +411,9 @@ export interface TreeSelectProps extends Omit | undefined;
/**
* Text to display when there is no data.
+ * @defaultValue No available options
*/
- emptyMessage?: string | undefined;
+ emptyMessage?: React.ReactNode | ((props: TreeSelectProps) => React.ReactNode) | undefined;
/**
* An array of keys to represent the state of the treeselect expansion state in controlled mode.
*/