An open source design system that's fully customizable and agent ready
TypeScript
feat(icon): standardize icon slots to ReactNode across all components (#1746)
Cindy Zhangbfc5d4bfbb9d
diff --git a/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx b/packages/core/src/CheckboxInput/XDSCheckboxInput.tsxindex 6656fbb6ba..3cb4dc7b06 100644--- a/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx+++ b/packages/core/src/CheckboxInput/XDSCheckboxInput.tsx@@ -20,6 +20,7 @@ import {useTransition,type ChangeEvent,type FocusEvent,+ type ReactNode,} from 'react';import * as stylex from '@stylexjs/stylex';import {@@ -291,7 +292,7 @@ export interface XDSCheckboxInputProps extends Omit<XDSBaseProps, 'onChange'> {/*** Icon to display before the label text.*/- labelIcon?: XDSIconType;+ labelIcon?: ReactNode | XDSIconType;/*** Status indicator for the checkbox.* When set with a message, displays a colored message box below the checkbox.diff --git a/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx b/packages/core/src/DropdownMenu/XDSDropdownMenu.tsxindex 9de58dd919..ad518c8419 100644--- a/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx+++ b/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx@@ -86,7 +86,7 @@ export interface XDSDropdownMenuItemData {label: string;onClick?: () => void;isDisabled?: boolean;- icon?: XDSIconType;+ icon?: ReactNode | XDSIconType;}export interface XDSDropdownMenuDivider {diff --git a/packages/core/src/DropdownMenu/XDSDropdownMenuItem.tsx b/packages/core/src/DropdownMenu/XDSDropdownMenuItem.tsxindex bc1ec6597e..966beab1f2 100644--- a/packages/core/src/DropdownMenu/XDSDropdownMenuItem.tsx+++ b/packages/core/src/DropdownMenu/XDSDropdownMenuItem.tsx@@ -19,7 +19,7 @@ import {useCallback, type ReactNode} from 'react';import * as stylex from '@stylexjs/stylex';import type {StyleXStyles} from '@stylexjs/stylex';import {XDSIcon} from '../Icon';-import type {XDSIconType} from '../Icon';+import {renderIconSlot, type XDSIconType} from '../Icon';import {XDSText} from '../Text';import {colorVars,@@ -75,7 +75,7 @@ const itemSizeStyles = stylex.create({export interface XDSDropdownMenuItemProps {/** Icon to display before the label. */- icon?: XDSIconType;+ icon?: ReactNode | XDSIconType;/** Primary label text. */label: ReactNode;/** Secondary description text displayed below the label. */@@ -145,7 +145,7 @@ export function XDSDropdownMenuItem({className,style,)}>- {icon && <XDSIcon icon={icon} size="sm" color="secondary" />}+ {icon && renderIconSlot(icon, {size: 'sm', color: 'secondary'})}<span {...stylex.props(styles.content)}>{typeof label === 'string' ? (<XDSText type="body" maxLines={1}>diff --git a/packages/core/src/Field/XDSField.tsx b/packages/core/src/Field/XDSField.tsxindex 17daec3d43..716ac4db40 100644--- a/packages/core/src/Field/XDSField.tsx+++ b/packages/core/src/Field/XDSField.tsx@@ -18,9 +18,7 @@ import * as stylex from '@stylexjs/stylex';import type {StyleXStyles} from '@stylexjs/stylex';import {XDSFieldLabel} from './XDSFieldLabel';import {XDSFieldStatus} from './XDSFieldStatus';-import {- spacingVars,-} from '../theme/tokens.stylex';+import {spacingVars} from '../theme/tokens.stylex';import type {XDSIconType} from '../Icon';import {xdsClassName, mergeProps} from '../utils';@@ -101,7 +99,7 @@ export interface XDSFieldProps extends Omit</*** Icon to display before the label text.*/- labelIcon?: XDSIconType;+ labelIcon?: ReactNode | XDSIconType;/*** Status indicator for the field.* When set with a message, displays a colored message box below the input.diff --git a/packages/core/src/Field/XDSFieldLabel.tsx b/packages/core/src/Field/XDSFieldLabel.tsxindex 216f15495b..9b31585483 100644--- a/packages/core/src/Field/XDSFieldLabel.tsx+++ b/packages/core/src/Field/XDSFieldLabel.tsx@@ -20,7 +20,7 @@ import {typographyVars,typeScaleVars,} from '../theme/tokens.stylex';-import {XDSIcon, type XDSIconType} from '../Icon';+import {XDSIcon, renderIconSlot, type XDSIconType} from '../Icon';import {XDSTooltip} from '../Tooltip';const styles = stylex.create({@@ -103,7 +103,7 @@ export interface XDSFieldLabelProps {/*** Icon to display before the label text.*/- labelIcon?: XDSIconType;+ labelIcon?: ReactNode | XDSIconType;/*** Tooltip text to display in an info icon at the end of the label.*/@@ -160,7 +160,7 @@ export function XDSFieldLabel({isLabelHidden && styles.srOnly,),)}>- {labelIcon && <XDSIcon icon={labelIcon} size="sm" color="inherit" />}+ {labelIcon && renderIconSlot(labelIcon, {size: 'sm', color: 'inherit'})}{label}{statusText && (<span {...stylex.props(styles.optionalRequired)}>@@ -177,10 +177,7 @@ export function XDSFieldLabel({{description && (<spanid={descriptionID}- {...stylex.props(- styles.description,- isLabelHidden && styles.srOnly,- )}>+ {...stylex.props(styles.description, isLabelHidden && styles.srOnly)}>{description}</span>)}diff --git a/packages/core/src/Icon/XDSIcon.tsx b/packages/core/src/Icon/XDSIcon.tsxindex bbe247b0e1..603bf8a8dc 100644--- a/packages/core/src/Icon/XDSIcon.tsx+++ b/packages/core/src/Icon/XDSIcon.tsx@@ -19,7 +19,7 @@* - /apps/storybook/stories/Icon.stories.tsx (storybook stories)*/-import {type ComponentType, type SVGProps} from 'react';+import React, {type ComponentType, type SVGProps} from 'react';import * as stylex from '@stylexjs/stylex';import {colorVars} from '../theme/tokens.stylex';import {getIcon} from './globalIconRegistry';@@ -277,3 +277,21 @@ function IconFromRegistry({</span>);}++/**+ * Renders an icon slot value. Handles both ReactNode and component types:+ * - If the value is a component (function or forwardRef object), wraps it in XDSIcon.+ * - Otherwise, renders the ReactNode directly.+ */+export function renderIconSlot(+ icon: React.ReactNode | XDSIconType,+ props?: {size?: XDSIconSize; color?: XDSIconColor},+): React.ReactNode {+ if (+ typeof icon === 'function' ||+ (typeof icon === 'object' && icon !== null && 'render' in icon)+ ) {+ return <XDSIcon icon={icon as unknown as XDSIconType} {...props} />;+ }+ return icon;+}diff --git a/packages/core/src/Icon/index.ts b/packages/core/src/Icon/index.tsindex 58a1a0965c..2053569906 100644--- a/packages/core/src/Icon/index.ts+++ b/packages/core/src/Icon/index.ts@@ -9,7 +9,7 @@* SYNC: When modified, update this header and /packages/core/src/Icon/Icon.doc.mjs*/-export {XDSIcon} from './XDSIcon';+export {XDSIcon, renderIconSlot} from './XDSIcon';export type {XDSIconProps,XDSIconColor,diff --git a/packages/core/src/NavMenu/XDSNavMenuItem.tsx b/packages/core/src/NavMenu/XDSNavMenuItem.tsxindex 9b8cc611de..4b4fceaf28 100644--- a/packages/core/src/NavMenu/XDSNavMenuItem.tsx+++ b/packages/core/src/NavMenu/XDSNavMenuItem.tsx@@ -14,7 +14,7 @@ import {useCallback, type ReactNode} from 'react';import * as stylex from '@stylexjs/stylex';import type {StyleXStyles} from '@stylexjs/stylex';import {XDSIcon} from '../Icon';-import type {XDSIconType} from '../Icon';+import {renderIconSlot, type XDSIconType} from '../Icon';import {XDSText} from '../Text';import {colorVars,@@ -63,7 +63,7 @@ const styles = stylex.create({export interface XDSNavMenuItemProps {/** Icon to display before the label. */- icon?: XDSIconType;+ icon?: ReactNode | XDSIconType;/** Primary label text. */label: ReactNode;/** Secondary description text displayed below the label. */@@ -131,15 +131,11 @@ export function XDSNavMenuItem({onClick={handleClick}{...mergeProps(xdsClassName('nav-menu-item'),- stylex.props(- styles.root,- isDisabled && styles.disabled,- xstyle,- ),+ stylex.props(styles.root, isDisabled && styles.disabled, xstyle),className,style,)}>- {icon && <XDSIcon icon={icon} size="sm" color="secondary" />}+ {icon && renderIconSlot(icon, {size: 'sm', color: 'secondary'})}<span {...stylex.props(styles.content)}>{typeof label === 'string' ? (<XDSText type="body" maxLines={1}>diff --git a/packages/core/src/NumberInput/XDSNumberInput.tsx b/packages/core/src/NumberInput/XDSNumberInput.tsxindex 681a6655ed..9dafb2410e 100644--- a/packages/core/src/NumberInput/XDSNumberInput.tsx+++ b/packages/core/src/NumberInput/XDSNumberInput.tsx@@ -21,6 +21,7 @@ import {useRef,type FocusEvent,type KeyboardEvent,+ type ReactNode,} from 'react';import * as stylex from '@stylexjs/stylex';import type {XDSIconName} from '../Icon';@@ -41,7 +42,7 @@ import {inputStatusHoverShadowStyles,inputStatusFocusWithinStyles,} from '../Field';-import {XDSIcon, type XDSIconType} from '../Icon';+import {XDSIcon, renderIconSlot, type XDSIconType} from '../Icon';import {useXDSSize} from '../SizeContext/XDSSizeContext';const styles = stylex.create({@@ -159,13 +160,13 @@ interface XDSNumberInputPropsBase extends Omit<isDisabled?: boolean;/*** Icon to display at the start of the input.- * Pass an SVG icon component (e.g. from heroicons, lucide, etc.).+ * Accepts a ReactNode (e.g. `<XDSIcon icon={SearchIcon} />`) or an SVG icon component directly.*/- startIcon?: XDSIconType;+ startIcon?: ReactNode | XDSIconType;/*** Icon to display before the label text.*/- labelIcon?: XDSIconType;+ labelIcon?: ReactNode | XDSIconType;/*** Status indicator for the input.* When set, displays a colored border and status icon.@@ -543,7 +544,7 @@ export function XDSNumberInput({className,style,)}>- {startIcon && <XDSIcon icon={startIcon} size="sm" color="primary" />}+ {startIcon && renderIconSlot(startIcon, {size: 'sm', color: 'primary'})}<input{...rest}ref={setRefs}diff --git a/packages/core/src/PowerSearch/XDSPowerSearch.tsx b/packages/core/src/PowerSearch/XDSPowerSearch.tsxindex 3973c8aa15..567b2a2db4 100644--- a/packages/core/src/PowerSearch/XDSPowerSearch.tsx+++ b/packages/core/src/PowerSearch/XDSPowerSearch.tsx@@ -17,6 +17,7 @@ import React, {useMemo,useRef,useState,+ type ReactNode,} from 'react';import * as stylex from '@stylexjs/stylex';import type {StyleXStyles} from '@stylexjs/stylex';@@ -340,9 +341,9 @@ export interface XDSPowerSearchProps {isDisabled?: boolean;/*** Icon to display at the start of the input.- * Pass an SVG icon component (e.g. from heroicons, lucide, etc.).+ * Accepts a ReactNode (e.g. `<XDSIcon icon={SearchIcon} />`) or an SVG icon component directly.*/- startIcon?: XDSIconType;+ startIcon?: ReactNode | XDSIconType;/** Focus callback. */onFocus?: () => void;/** Blur callback. */diff --git a/packages/core/src/Selector/XDSSelectorOption.tsx b/packages/core/src/Selector/XDSSelectorOption.tsxindex 1c60ca6b81..74950626bf 100644--- a/packages/core/src/Selector/XDSSelectorOption.tsx+++ b/packages/core/src/Selector/XDSSelectorOption.tsx@@ -8,7 +8,7 @@ import type {ReactNode} from 'react';import * as stylex from '@stylexjs/stylex';import type {StyleXStyles} from '@stylexjs/stylex';import {XDSIcon} from '../Icon';-import type {XDSIconType} from '../Icon';+import {renderIconSlot, type XDSIconType} from '../Icon';import {XDSText} from '../Text';import {spacingVars} from '../theme/tokens.stylex';import {xdsClassName, mergeProps} from '../utils';@@ -33,7 +33,7 @@ export interface XDSSelectorOptionProps {/*** Icon to display before the label.*/- icon?: XDSIconType;+ icon?: ReactNode | XDSIconType;/*** Primary label text.@@ -113,7 +113,7 @@ export function XDSSelectorOption({className,style,)}>- {icon && <XDSIcon icon={icon} size="sm" color="secondary" />}+ {icon && renderIconSlot(icon, {size: 'sm', color: 'secondary'})}<span {...stylex.props(styles.content)}>{typeof label === 'string' ? (<XDSText type="body" maxLines={1}>diff --git a/packages/core/src/Selector/types.ts b/packages/core/src/Selector/types.tsindex 2043857da6..d405f16673 100644--- a/packages/core/src/Selector/types.ts+++ b/packages/core/src/Selector/types.ts@@ -4,6 +4,7 @@* @position Type definitions; used by XDSSelector.tsx*/+import type {ReactNode} from 'react';import type {XDSIconType} from '../Icon';/**@@ -13,7 +14,7 @@ export type XDSSelectorOptionData = {value: string;label?: string;disabled?: boolean;- icon?: XDSIconType;+ icon?: ReactNode | XDSIconType;};/**diff --git a/packages/core/src/SideNav/XDSSideNavItem.tsx b/packages/core/src/SideNav/XDSSideNavItem.tsxindex 98c5d0f1f8..60e606c260 100644--- a/packages/core/src/SideNav/XDSSideNavItem.tsx+++ b/packages/core/src/SideNav/XDSSideNavItem.tsx@@ -29,7 +29,7 @@ import {radiusVars,} from '../theme/tokens.stylex';import {XDSIcon} from '../Icon';-import type {XDSIconType} from '../Icon';+import {renderIconSlot, type XDSIconType} from '../Icon';import {useXDSLinkComponent} from '../Link/useXDSLinkComponent';import type {XDSLinkComponentType} from '../Link/types';import {useXDSPopover} from '../Popover/useXDSPopover';@@ -249,11 +249,11 @@ export interface XDSSideNavItemProps {/*** Icon (outline variant).*/- icon?: XDSIconType;+ icon?: ReactNode | XDSIconType;/*** Icon when selected (filled variant).*/- selectedIcon?: XDSIconType;+ selectedIcon?: ReactNode | XDSIconType;/*** Current page indicator.* @default false@@ -392,7 +392,8 @@ export function XDSSideNavItem({// toggle are independent: clicking the label navigates/fires onClick,// clicking the chevron expands/collapses children.const hasPrimaryAction = !!href || !!onClick;- const hasIndependentToggle = isItemCollapsible && hasPrimaryAction && !isCollapsed;+ const hasIndependentToggle =+ isItemCollapsible && hasPrimaryAction && !isCollapsed;const handleClick = (e: React.MouseEvent) => {if (isDisabled) {@@ -463,13 +464,12 @@ export function XDSSideNavItem({// Collapsed mode — icon-only items, popover for items with children// =========================================================================if (isCollapsed) {- const collapsedIcon = displayIcon && (- <XDSIcon- icon={displayIcon}- size="sm"- color={isSelected ? 'primary' : isDisabled ? 'disabled' : 'secondary'}- />- );+ const collapsedIcon =+ displayIcon &&+ renderIconSlot(displayIcon, {+ size: 'sm',+ color: isSelected ? 'primary' : isDisabled ? 'disabled' : 'secondary',+ });// Shared collapsed item styles — used by trigger, link, and buttonconst collapsedItemStyles = mergeProps(@@ -560,13 +560,11 @@ export function XDSSideNavItem({const itemContent = (<>- {displayIcon && (- <XDSIcon- icon={displayIcon}- size="sm"- color={isSelected ? 'primary' : isDisabled ? 'disabled' : 'secondary'}- />- )}+ {displayIcon &&+ renderIconSlot(displayIcon, {+ size: 'sm',+ color: isSelected ? 'primary' : isDisabled ? 'disabled' : 'secondary',+ })}{!isCollapsed && <span {...stylex.props(styles.label)}>{label}</span>}{!isCollapsed && endContent && (<span {...stylex.props(styles.endContent)}>{endContent}</span>diff --git a/packages/core/src/Switch/XDSSwitch.tsx b/packages/core/src/Switch/XDSSwitch.tsxindex 36ee229097..6db2b44c4f 100644--- a/packages/core/src/Switch/XDSSwitch.tsx+++ b/packages/core/src/Switch/XDSSwitch.tsx@@ -19,6 +19,7 @@ import {useTransition,type ChangeEvent,type FocusEvent,+ type ReactNode,} from 'react';import * as stylex from '@stylexjs/stylex';import {@@ -251,7 +252,7 @@ export interface XDSSwitchProps extends Omit<XDSBaseProps, 'onChange'> {/*** Icon to display before the label text.*/- labelIcon?: XDSIconType;+ labelIcon?: ReactNode | XDSIconType;/*** Tooltip text to display in an info icon at the end of the label.*/diff --git a/packages/core/src/TabList/XDSTabMenu.tsx b/packages/core/src/TabList/XDSTabMenu.tsxindex 91d4783b20..cb119d1d4f 100644--- a/packages/core/src/TabList/XDSTabMenu.tsx+++ b/packages/core/src/TabList/XDSTabMenu.tsx@@ -12,10 +12,10 @@* - /packages/core/src/TabList/XDSTabList.test.tsx*/-import React, {useCallback, useId} from 'react';+import React, {useCallback, useId, type ReactNode} from 'react';import * as stylex from '@stylexjs/stylex';import {XDSIcon} from '../Icon';-import type {XDSIconType} from '../Icon';+import {renderIconSlot, type XDSIconType} from '../Icon';import {colorVars,spacingVars,@@ -39,7 +39,7 @@ export interface XDSTabMenuOption {/*** Icon to display before the label.*/- icon?: XDSIconType;+ icon?: ReactNode | XDSIconType;}export interface XDSTabMenuProps {@@ -360,9 +360,11 @@ export function XDSTabMenu({label, options}: XDSTabMenuProps) {),)}><span {...stylex.props(styles.menuItemContent)}>- {option.icon && (- <XDSIcon icon={option.icon} size="sm" color="secondary" />- )}+ {option.icon &&+ renderIconSlot(option.icon, {+ size: 'sm',+ color: 'secondary',+ })}{option.label}</span>{isSelected && (diff --git a/packages/core/src/TextArea/XDSTextArea.tsx b/packages/core/src/TextArea/XDSTextArea.tsxindex 4a3528508d..7f8f56e34e 100644--- a/packages/core/src/TextArea/XDSTextArea.tsx+++ b/packages/core/src/TextArea/XDSTextArea.tsx@@ -20,6 +20,7 @@ import {type ChangeEvent,type ClipboardEvent,type FocusEvent,+ type ReactNode,} from 'react';import * as stylex from '@stylexjs/stylex';import type {XDSIconName} from '../Icon';@@ -36,7 +37,7 @@ import {inputStatusHoverShadowStyles,inputStatusFocusWithinStyles,} from '../Field';-import {XDSIcon, type XDSIconType} from '../Icon';+import {XDSIcon, renderIconSlot, type XDSIconType} from '../Icon';import {XDSSpinner} from '../Spinner';import {xdsClassName, mergeProps} from '../utils';import type {XDSBaseProps} from '../XDSBaseProps';@@ -192,9 +193,9 @@ export interface XDSTextAreaProps extends Omit<labelTooltip?: string;/*** Icon to display at the start of the textarea.- * Pass an SVG icon component (e.g. from heroicons, lucide, etc.).+ * Accepts a ReactNode (e.g. `<XDSIcon icon={SearchIcon} />`) or an SVG icon component directly.*/- startIcon?: XDSIconType;+ startIcon?: ReactNode | XDSIconType;/*** Whether to enable browser spell checking.* @default true@@ -350,7 +351,7 @@ export function XDSTextArea({className,style,)}>- {startIcon && <XDSIcon icon={startIcon} size="sm" color="primary" />}+ {startIcon && renderIconSlot(startIcon, {size: 'sm', color: 'primary'})}<textarea{...rest}ref={ref}diff --git a/packages/core/src/TextInput/XDSTextInput.tsx b/packages/core/src/TextInput/XDSTextInput.tsxindex d69b91c772..332ded49be 100644--- a/packages/core/src/TextInput/XDSTextInput.tsx+++ b/packages/core/src/TextInput/XDSTextInput.tsx@@ -21,6 +21,7 @@ import {useRef,type ChangeEvent,type KeyboardEvent,+ type ReactNode,} from 'react';import * as stylex from '@stylexjs/stylex';import type {XDSIconName} from '../Icon';@@ -41,7 +42,7 @@ import {inputStatusHoverShadowStyles,inputStatusFocusWithinStyles,} from '../Field';-import {XDSIcon, type XDSIconType} from '../Icon';+import {XDSIcon, renderIconSlot, type XDSIconType} from '../Icon';import {XDSSpinner} from '../Spinner';const styles = stylex.create({@@ -157,9 +158,9 @@ export interface XDSTextInputProps extends Omit<isDisabled?: boolean;/*** Icon to display at the start of the input.- * Pass an SVG icon component (e.g. from heroicons, lucide, etc.).+ * Accepts a ReactNode (e.g. `<XDSIcon icon={SearchIcon} />`) or an SVG icon component directly.*/- startIcon?: XDSIconType;+ startIcon?: ReactNode | XDSIconType;/*** Status indicator for the input.* When set, displays a colored border and status icon.@@ -359,7 +360,7 @@ export function XDSTextInput({className,style,)}>- {startIcon && <XDSIcon icon={startIcon} size="sm" color="primary" />}+ {startIcon && renderIconSlot(startIcon, {size: 'sm', color: 'primary'})}<input{...rest}ref={setRefs}diff --git a/packages/core/src/Tokenizer/XDSTokenizer.tsx b/packages/core/src/Tokenizer/XDSTokenizer.tsxindex a3697280af..7a6af619bf 100644--- a/packages/core/src/Tokenizer/XDSTokenizer.tsx+++ b/packages/core/src/Tokenizer/XDSTokenizer.tsx@@ -35,7 +35,7 @@ import {} from '../Field';import {XDSToken} from '../Token';import {XDSIcon} from '../Icon';-import type {XDSIconType} from '../Icon';+import {renderIconSlot, type XDSIconType} from '../Icon';import {XDSOverflowList} from '../OverflowList';import {useXDSLayer} from '../Layer/useXDSLayer';import {@@ -105,9 +105,9 @@ export interface XDSTokenizerProps<T extends XDSSearchableItem> {status?: XDSInputStatus;/*** Icon to display at the start of the input.- * Pass an SVG icon component (e.g. from heroicons, lucide, etc.).+ * Accepts a ReactNode (e.g. `<XDSIcon icon={SearchIcon} />`) or an SVG icon component directly.*/- startIcon?: XDSIconType;+ startIcon?: ReactNode | XDSIconType;/** Label tooltip. */labelTooltip?: string;/** Search source providing items. */@@ -668,9 +668,8 @@ export function XDSTokenizer<T extends XDSSearchableItem>({status && inputStatusFocusWithinStyles[status.type],),)}>- {startIcon && (- <XDSIcon icon={startIcon} size="sm" color="primary" />- )}+ {startIcon &&+ renderIconSlot(startIcon, {size: 'sm', color: 'primary'})}{isTruncated ? (<XDSOverflowListgap={1}@@ -768,9 +767,8 @@ export function XDSTokenizer<T extends XDSSearchableItem>({)}>{isTruncated && (<>- {startIcon && (- <XDSIcon icon={startIcon} size="sm" color="primary" />- )}+ {startIcon &&+ renderIconSlot(startIcon, {size: 'sm', color: 'primary'})}<XDSOverflowListgap={1}behavior="observeParent"diff --git a/packages/core/src/Typeahead/XDSTypeahead.tsx b/packages/core/src/Typeahead/XDSTypeahead.tsxindex 258a3c8424..f3d60a1d6b 100644--- a/packages/core/src/Typeahead/XDSTypeahead.tsx+++ b/packages/core/src/Typeahead/XDSTypeahead.tsx@@ -16,7 +16,13 @@* - /apps/storybook/stories/Typeahead.stories.tsx*/-import React, {useCallback, useId, useRef, useState} from 'react';+import React, {+ useCallback,+ useId,+ useRef,+ useState,+ type ReactNode,+} from 'react';import * as stylex from '@stylexjs/stylex';import type {StyleXStyles} from '@stylexjs/stylex';import {XDSBaseTypeahead} from './XDSBaseTypeahead';@@ -31,7 +37,7 @@ import {} from '../Field';import {XDSToken} from '../Token';import {XDSIcon} from '../Icon';-import type {XDSIconType} from '../Icon';+import {renderIconSlot, type XDSIconType} from '../Icon';import {colorVars,spacingVars,@@ -40,7 +46,6 @@ import {} from '../theme/tokens.stylex';import {xdsClassName, mergeProps} from '../utils';import type {XDSSearchableItem, XDSSearchSource} from './types';-import type {ReactNode} from 'react';export type {XDSInputStatus as XDSTypeaheadStatus,@@ -64,9 +69,9 @@ export interface XDSTypeaheadProps<T extends XDSSearchableItem> {status?: XDSInputStatus;/*** Icon to display at the start of the input.- * Pass an SVG icon component (e.g. from heroicons, lucide, etc.).+ * Accepts a ReactNode (e.g. `<XDSIcon icon={SearchIcon} />`) or an SVG icon component directly.*/- startIcon?: XDSIconType;+ startIcon?: ReactNode | XDSIconType;/** Label tooltip. */labelTooltip?: string;/** Search source providing items. */@@ -391,7 +396,7 @@ export function XDSTypeahead<T extends XDSSearchableItem>({isDisabled && inputWrapperStyles.disabled,),)}>- {startIcon && <XDSIcon icon={startIcon} size="sm" color="primary" />}+ {startIcon && renderIconSlot(startIcon, {size: 'sm', color: 'primary'})}{showToken && (<XDSTokenref={tokenRef}