Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(selector): rename option renderer prop (#2821)

Cindy Zhangdc12e46efa53
diff --git a/.changeset/selector-render-option.md b/.changeset/selector-render-option.md
new file mode 100644
index 0000000000..a52dcfb5c4
--- /dev/null
+++ b/.changeset/selector-render-option.md
@@ -0,0 +1,8 @@
+---
+'@xds/core': minor
+'@xds/cli': patch
+---
+
+`XDSSelector` and `XDSMultiSelector` now use the `renderOption` prop for custom option rendering. The previous function-as-children option renderer has been removed while the package is still prerelease.
+
+`xds upgrade` includes `migrate-selector-children-to-render-option`, which moves `<XDSSelector>{option => ...}</XDSSelector>`, `<XDSMultiSelector>{option => ...}</XDSMultiSelector>`, and explicit `children={...}` option renderers to `renderOption={...}`.
diff --git a/apps/storybook/stories/Selector.stories.tsx b/apps/storybook/stories/Selector.stories.tsx
index 1f573e3e78..8217b53120 100644
--- a/apps/storybook/stories/Selector.stories.tsx
+++ b/apps/storybook/stories/Selector.stories.tsx
@@ -68,10 +68,10 @@ const meta: Meta<typeof XDSSelector> = {
control: 'boolean',
description: 'Whether the field is required',
},
- children: {
+ renderOption: {
description: 'Optional render function for custom option rendering',
table: {
- type: {summary: '(item: XDSSelectorOptionData) => ReactNode'},
+ type: {summary: '(option: XDSSelectorOptionData) => ReactNode'},
},
},
'data-testid': {
@@ -292,15 +292,15 @@ export const CustomRender: Story = {
options={users}
value={value}
onChange={v => setValue(v)}
- placeholder="Select a user...">
- {user => (
+ placeholder="Select a user..."
+ renderOption={user => (
<XDSSelectorOption
icon={UserIcon}
label={user.label}
description={(user as (typeof users)[number]).email}
/>
)}
- </XDSSelector>
+ />
);
},
};
diff --git a/internal/vibe-tests/selector-naming-test/prompts.json b/internal/vibe-tests/selector-naming-test/prompts.json
index c547111c29..d542ab802b 100644
--- a/internal/vibe-tests/selector-naming-test/prompts.json
+++ b/internal/vibe-tests/selector-naming-test/prompts.json
@@ -1,10 +1,7 @@
{
"name": "selector-naming",
"description": "Vibe test comparing 'items' vs 'options' naming for XDSSelector child elements",
- "variants": [
- "items",
- "options"
- ],
+ "variants": ["items", "options"],
"prompts": [
{
"id": "sel-1",
@@ -18,7 +15,7 @@
"category": "form-select",
"prompt": "Create a shipping method selector for a checkout page. Show three options: Standard (free, 5-7 days), Express ($9.99, 2-3 days), and Overnight ($24.99, next day). Each should show the name, price, and delivery time.",
"tests": "Rich items/options with descriptions, custom rendering",
- "notes": "Tests custom render pattern \u2014 does the LLM use the children render prop correctly?"
+ "notes": "Tests custom render pattern \u2014 does the LLM use the renderOption prop correctly?"
},
{
"id": "sel-3",
@@ -60,7 +57,7 @@
"category": "form-select",
"prompt": "Create a font picker dropdown that shows font names rendered in their actual font. Group fonts into categories: Sans-serif (Inter, Roboto, Open Sans), Serif (Georgia, Merriweather, Playfair Display), and Monospace (Fira Code, JetBrains Mono, Source Code Pro).",
"tests": "Custom rendering with sections, rich visual content",
- "notes": "Tests custom children render prop with sections \u2014 complex composition"
+ "notes": "Tests custom renderOption prop with sections \u2014 complex composition"
}
]
-}
\ No newline at end of file
+}
diff --git a/internal/vibe-tests/selector-naming-test/variant-a-items.md b/internal/vibe-tests/selector-naming-test/variant-a-items.md
index 116c145486..9c56fe141a 100644
--- a/internal/vibe-tests/selector-naming-test/variant-a-items.md
+++ b/internal/vibe-tests/selector-naming-test/variant-a-items.md
@@ -58,15 +58,15 @@ import {XDSSelector, XDSSelectorItem} from '@xds/core';
label="User"
items={users.map(u => ({value: u.id, label: u.name, icon: 'user'}))}
value={selectedUser}
- onChange={setSelectedUser}>
- {item => (
+ onChange={setSelectedUser}
+ renderOption={item => (
<XDSSelectorItem
icon={item.icon}
label={item.label}
description={item.email}
/>
)}
-</XDSSelector>
+/>
```
## Props
@@ -88,7 +88,7 @@ import {XDSSelector, XDSSelectorItem} from '@xds/core';
| isOptional | boolean | false | Show optional indicator |
| isRequired | boolean | false | Show required indicator |
| status | { type: 'warning' \| 'error' \| 'success', message?: string } | — | Validation status |
-| children | (item: ItemData) => ReactNode | — | Custom item renderer |
+| renderOption | (item: ItemData) => ReactNode | — | Custom item renderer |
### XDSSelectorItem (for custom rendering)
diff --git a/internal/vibe-tests/selector-naming-test/variant-b-options.md b/internal/vibe-tests/selector-naming-test/variant-b-options.md
index c08939b452..d5b202212c 100644
--- a/internal/vibe-tests/selector-naming-test/variant-b-options.md
+++ b/internal/vibe-tests/selector-naming-test/variant-b-options.md
@@ -58,15 +58,15 @@ import {XDSSelector, XDSSelectorOption} from '@xds/core';
label="User"
options={users.map(u => ({value: u.id, label: u.name, icon: 'user'}))}
value={selectedUser}
- onChange={setSelectedUser}>
- {option => (
+ onChange={setSelectedUser}
+ renderOption={option => (
<XDSSelectorOption
icon={option.icon}
label={option.label}
description={option.email}
/>
)}
-</XDSSelector>
+/>
```
## Props
@@ -88,7 +88,7 @@ import {XDSSelector, XDSSelectorOption} from '@xds/core';
| isOptional | boolean | false | Show optional indicator |
| isRequired | boolean | false | Show required indicator |
| status | { type: 'warning' \| 'error' \| 'success', message?: string } | — | Validation status |
-| children | (option: OptionData) => ReactNode | — | Custom option renderer |
+| renderOption | (option: OptionData) => ReactNode | — | Custom option renderer |
### XDSSelectorOption (for custom rendering)
diff --git a/packages/cli/src/codemods/__tests__/registry.test.mjs b/packages/cli/src/codemods/__tests__/registry.test.mjs
index e887685296..b0bfd1648f 100644
--- a/packages/cli/src/codemods/__tests__/registry.test.mjs
+++ b/packages/cli/src/codemods/__tests__/registry.test.mjs
@@ -6,23 +6,29 @@ import {versions, getTransformsBetween} from '../registry.mjs';
describe('registry', () => {
describe('versions', () => {
test('are sorted in ascending semver order across digit boundaries', () => {
- expect(versions).toEqual(['0.0.2', '0.0.6', '0.0.7', '0.0.8', '0.0.10', '0.0.12', '0.0.13', '0.0.14', '0.0.15']);
+ expect(versions).toEqual([
+ '0.0.2',
+ '0.0.6',
+ '0.0.7',
+ '0.0.8',
+ '0.0.10',
+ '0.0.12',
+ '0.0.13',
+ '0.0.14',
+ '0.0.15',
+ ]);
});
});
describe('getTransformsBetween', () => {
test('returns v0.0.10 transforms for range 0.0.9 to 0.0.10', async () => {
const results = await getTransformsBetween('0.0.9', '0.0.10');
- expect(results.map((r) => r.version)).toEqual(['0.0.10']);
+ expect(results.map(r => r.version)).toEqual(['0.0.10']);
});
test('returns v0.0.6, v0.0.7, v0.0.8 for range 0.0.2 to 0.0.8', async () => {
const results = await getTransformsBetween('0.0.2', '0.0.8');
- expect(results.map((r) => r.version)).toEqual([
- '0.0.6',
- '0.0.7',
- '0.0.8',
- ]);
+ expect(results.map(r => r.version)).toEqual(['0.0.6', '0.0.7', '0.0.8']);
});
test('returns empty array when from equals to', async () => {
@@ -36,13 +42,19 @@ describe('registry', () => {
});
test('handles prerelease suffixes in --to (canary versions)', async () => {
- const results = await getTransformsBetween('0.0.12', '0.0.13-canary.21d98fa');
- expect(results.map((r) => r.version)).toEqual(['0.0.13']);
+ const results = await getTransformsBetween(
+ '0.0.12',
+ '0.0.13-canary.21d98fa',
+ );
+ expect(results.map(r => r.version)).toEqual(['0.0.13']);
});
test('handles prerelease suffixes in --from', async () => {
- const results = await getTransformsBetween('0.0.12-canary.abc1234', '0.0.13');
- expect(results.map((r) => r.version)).toEqual(['0.0.13']);
+ const results = await getTransformsBetween(
+ '0.0.12-canary.abc1234',
+ '0.0.13',
+ );
+ expect(results.map(r => r.version)).toEqual(['0.0.13']);
});
});
});
diff --git a/packages/cli/src/codemods/registry.mjs b/packages/cli/src/codemods/registry.mjs
index 01e0284789..a2af3a98c9 100644
--- a/packages/cli/src/codemods/registry.mjs
+++ b/packages/cli/src/codemods/registry.mjs
@@ -43,7 +43,7 @@ export const latestVersion = versions[versions.length - 1];
*/
export async function getTransformsBetween(from, to) {
const applicable = versions.filter(
- (v) => semverCompare(v, from) > 0 && semverCompare(v, to) <= 0,
+ v => semverCompare(v, from) > 0 && semverCompare(v, to) <= 0,
);
const results = [];
diff --git a/packages/cli/src/codemods/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs b/packages/cli/src/codemods/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs
new file mode 100644
index 0000000000..0872d70a02
--- /dev/null
+++ b/packages/cli/src/codemods/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs
@@ -0,0 +1,109 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, it, expect} from 'vitest';
+
+async function applyTransform(source) {
+ const {default: transform} =
+ await import('../migrate-selector-children-to-render-option.mjs');
+ const jscodeshift = (await import('jscodeshift')).default;
+ const j = jscodeshift.withParser('tsx');
+ const api = {jscodeshift: j, stats: () => {}, report: () => {}};
+ const file = {source, path: 'test.tsx'};
+ const result = transform(file, api);
+ return result ?? source;
+}
+
+describe('migrate-selector-children-to-render-option', () => {
+ it('moves XDSSelector function children to renderOption', async () => {
+ const input = `import {XDSSelector} from '@xds/core/Selector';
+<XDSSelector label="Role" options={options} value={value} onChange={setValue}>
+ {option => <XDSSelectorOption label={option.label} />}
+</XDSSelector>`;
+ const output = await applyTransform(input);
+ expect(output).toContain(
+ 'renderOption={option => <XDSSelectorOption label={option.label} />}',
+ );
+ expect(output).not.toContain('</XDSSelector>');
+ });
+
+ it('moves XDSMultiSelector function children to renderOption', async () => {
+ const input = `import {XDSMultiSelector} from '@xds/core/MultiSelector';
+<XDSMultiSelector label="Tags" options={options} value={value} onChange={setValue}>
+ {option => <span>{option.label}</span>}
+</XDSMultiSelector>`;
+ const output = await applyTransform(input);
+ expect(output).toContain(
+ 'renderOption={option => <span>{option.label}</span>}',
+ );
+ expect(output).not.toContain('</XDSMultiSelector>');
+ });
+
+ it('moves function-reference children to renderOption', async () => {
+ const input = `import {XDSSelector} from '@xds/core';
+<XDSSelector label="Queue" options={options} value={value} onChange={setValue}>
+ {renderOption}
+</XDSSelector>`;
+ const output = await applyTransform(input);
+ expect(output).toContain('renderOption={renderOption}');
+ expect(output).not.toContain('</XDSSelector>');
+ });
+
+ it('renames explicit children prop to renderOption', async () => {
+ const input = `import {XDSSelector} from '@xds/core/Selector';
+<XDSSelector label="Queue" options={options} value={value} onChange={setValue} children={renderOption} />`;
+ const output = await applyTransform(input);
+ expect(output).toContain('renderOption={renderOption}');
+ expect(output).not.toContain('children=');
+ });
+
+ it('handles aliased imports', async () => {
+ const input = `import {XDSSelector as Selector} from '@xds/core/Selector';
+<Selector label="Role" options={options} value={value} onChange={setValue}>
+ {option => <span>{option.label}</span>}
+</Selector>`;
+ const output = await applyTransform(input);
+ expect(output).toContain(
+ 'renderOption={option => <span>{option.label}</span>}',
+ );
+ expect(output).not.toContain('</Selector>');
+ });
+
+ it('handles namespace imports', async () => {
+ const input = `import * as XDS from '@xds/core';
+<XDS.XDSSelector label="Role" options={options} value={value} onChange={setValue}>
+ {option => <span>{option.label}</span>}
+</XDS.XDSSelector>`;
+ const output = await applyTransform(input);
+ expect(output).toContain(
+ 'renderOption={option => <span>{option.label}</span>}',
+ );
+ expect(output).not.toContain('</XDS.XDSSelector>');
+ });
+
+ it('skips selectors that already use renderOption', async () => {
+ const input = `import {XDSSelector} from '@xds/core/Selector';
+<XDSSelector label="Role" options={options} value={value} onChange={setValue} renderOption={renderOption}>
+ {oldRenderOption}
+</XDSSelector>`;
+ const output = await applyTransform(input);
+ expect(output).toBe(input);
+ });
+
+ it('does not touch legacy @xds/core selector item children', async () => {
+ const input = `import {XDSSelector, XDSSelectorItem} from '@xds/core';
+<XDSSelector label="Role" value={value} onChange={setValue}>
+ <XDSSelectorItem label="Admin" value="admin" />
+</XDSSelector>`;
+ const output = await applyTransform(input);
+ expect(output).toBe(input);
+ });
+
+ it('does not convert direct JSX children into renderOption', async () => {
+ const input = `import {XDSSelector} from '@xds/core/Selector';
+<XDSSelector label="Role" options={options} value={value} onChange={setValue}>
+ <XDSSelectorOption label="Admin" />
+</XDSSelector>`;
+ const output = await applyTransform(input);
+ expect(output).toBe(input);
+ });
+});
diff --git a/packages/cli/src/codemods/transforms/v0.0.15/index.mjs b/packages/cli/src/codemods/transforms/v0.0.15/index.mjs
index a306468f96..d791bdb68c 100644
--- a/packages/cli/src/codemods/transforms/v0.0.15/index.mjs
+++ b/packages/cli/src/codemods/transforms/v0.0.15/index.mjs
@@ -30,6 +30,10 @@ import migrateThemeSelectorsToDataAttrs, {
meta as migrateThemeSelectorsToDataAttrsMeta,
} from './migrate-theme-selectors-to-data-attrs.mjs';
+import migrateSelectorChildrenToRenderOption, {
+ meta as migrateSelectorChildrenToRenderOptionMeta,
+} from './migrate-selector-children-to-render-option.mjs';
+
export default [
{
name: 'rename-date-picker-to-input',
@@ -62,4 +66,9 @@ export default [
meta: migrateThemeSelectorsToDataAttrsMeta,
optional: true,
},
+ {
+ name: 'migrate-selector-children-to-render-option',
+ transform: migrateSelectorChildrenToRenderOption,
+ meta: migrateSelectorChildrenToRenderOptionMeta,
+ },
];
diff --git a/packages/cli/src/codemods/transforms/v0.0.15/migrate-selector-children-to-render-option.mjs b/packages/cli/src/codemods/transforms/v0.0.15/migrate-selector-children-to-render-option.mjs
new file mode 100644
index 0000000000..75f650d840
--- /dev/null
+++ b/packages/cli/src/codemods/transforms/v0.0.15/migrate-selector-children-to-render-option.mjs
@@ -0,0 +1,189 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file Codemod: Migrate Selector render-prop children → renderOption
+ *
+ * XDSSelector and XDSMultiSelector previously used function-as-children for
+ * custom option rendering. The named renderOption prop is clearer and avoids
+ * confusion with JSX child content.
+ *
+ * Handles:
+ * 1. <XDSSelector>{option => ...}</XDSSelector>
+ * → <XDSSelector renderOption={option => ...} />
+ * 2. <XDSMultiSelector>{renderOption}</XDSMultiSelector>
+ * → <XDSMultiSelector renderOption={renderOption} />
+ * 3. Explicit children prop → renderOption prop
+ *
+ * The transform is import-aware and only touches components imported from
+ * @xds/core or @xds/core/{Selector,MultiSelector}. It intentionally skips
+ * legacy @xds/core selectors, where JSX children are selector items.
+ */
+
+export const meta = {
+ title: 'Migrate selector children → renderOption',
+ description:
+ 'Moves custom option renderers on `XDSSelector` and `XDSMultiSelector` from function-as-children to the `renderOption` prop.',
+};
+
+const COMPONENTS = new Set(['XDSSelector', 'XDSMultiSelector']);
+
+function isXDSCoreSource(source) {
+ return (
+ source === '@xds/core' ||
+ source === '@xds/core/Selector' ||
+ source === '@xds/core/MultiSelector'
+ );
+}
+
+function sourceCanImport(source, importedName) {
+ if (source === '@xds/core') {
+ return COMPONENTS.has(importedName);
+ }
+ if (source === '@xds/core/Selector') {
+ return importedName === 'XDSSelector';
+ }
+ if (source === '@xds/core/MultiSelector') {
+ return importedName === 'XDSMultiSelector';
+ }
+ return false;
+}
+
+function collectSelectorNames(root, j) {
+ const localNames = new Map();
+ const namespaceNames = new Set();
+
+ root.find(j.ImportDeclaration).forEach(path => {
+ const source = path.node.source.value;
+ if (typeof source !== 'string' || !isXDSCoreSource(source)) {
+ return;
+ }
+
+ for (const spec of path.node.specifiers ?? []) {
+ if (
+ spec.type === 'ImportSpecifier' &&
+ spec.imported.type === 'Identifier' &&
+ spec.local?.type === 'Identifier' &&
+ sourceCanImport(source, spec.imported.name)
+ ) {
+ localNames.set(spec.local.name, spec.imported.name);
+ }
+
+ if (
+ spec.type === 'ImportNamespaceSpecifier' &&
+ spec.local.type === 'Identifier'
+ ) {
+ namespaceNames.add(spec.local.name);
+ }
+ }
+ });
+
+ return {localNames, namespaceNames};
+}
+
+function getComponentName(name, localNames, namespaceNames) {
+ if (name.type === 'JSXIdentifier') {
+ return localNames.get(name.name) ?? null;
+ }
+
+ if (
+ name.type === 'JSXMemberExpression' &&
+ name.object.type === 'JSXIdentifier' &&
+ name.property.type === 'JSXIdentifier' &&
+ namespaceNames.has(name.object.name) &&
+ COMPONENTS.has(name.property.name)
+ ) {
+ return name.property.name;
+ }
+
+ return null;
+}
+
+function isWhitespaceText(node) {
+ return node.type === 'JSXText' && node.value.trim() === '';
+}
+
+function isEmptyExpression(node) {
+ return (
+ node.type === 'JSXExpressionContainer' &&
+ node.expression.type === 'JSXEmptyExpression'
+ );
+}
+
+function getMeaningfulChildren(children) {
+ return children.filter(
+ child => !isWhitespaceText(child) && !isEmptyExpression(child),
+ );
+}
+
+function isRenderableExpression(expression) {
+ return (
+ expression.type === 'ArrowFunctionExpression' ||
+ expression.type === 'FunctionExpression' ||
+ expression.type === 'Identifier' ||
+ expression.type === 'MemberExpression'
+ );
+}
+
+function getJSXAttribute(openingElement, name) {
+ return openingElement.attributes.find(
+ attr => attr.type === 'JSXAttribute' && attr.name.name === name,
+ );
+}
+
+export default function transformer(file, api) {
+ const j = api.jscodeshift;
+ const root = j(file.source);
+ const {localNames, namespaceNames} = collectSelectorNames(root, j);
+ let hasChanges = false;
+
+ if (localNames.size === 0 && namespaceNames.size === 0) {
+ return undefined;
+ }
+
+ root.find(j.JSXElement).forEach(path => {
+ const componentName = getComponentName(
+ path.node.openingElement.name,
+ localNames,
+ namespaceNames,
+ );
+ if (componentName == null) {
+ return;
+ }
+
+ const {openingElement} = path.node;
+ const renderOptionAttr = getJSXAttribute(openingElement, 'renderOption');
+ if (renderOptionAttr != null) {
+ return;
+ }
+
+ const childrenAttr = getJSXAttribute(openingElement, 'children');
+ if (childrenAttr != null) {
+ childrenAttr.name.name = 'renderOption';
+ hasChanges = true;
+ return;
+ }
+
+ const meaningfulChildren = getMeaningfulChildren(path.node.children ?? []);
+ if (meaningfulChildren.length !== 1) {
+ return;
+ }
+
+ const child = meaningfulChildren[0];
+ if (
+ child.type !== 'JSXExpressionContainer' ||
+ !isRenderableExpression(child.expression)
+ ) {
+ return;
+ }
+
+ openingElement.attributes.push(
+ j.jsxAttribute(j.jsxIdentifier('renderOption'), child),
+ );
+ openingElement.selfClosing = true;
+ path.node.children = [];
+ path.node.closingElement = null;
+ hasChanges = true;
+ });
+
+ return hasChanges ? root.toSource() : undefined;
+}
diff --git a/packages/cli/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx b/packages/cli/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx
index 74305d508d..f0e40c2255 100644
--- a/packages/cli/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx
+++ b/packages/cli/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx
@@ -30,14 +30,14 @@ export default function SelectorOptionShowcase() {
options={roles}
value={value}
onChange={setValue}
- placeholder="Assign a role...">
- {option => (
+ placeholder="Assign a role..."
+ renderOption={option => (
<XDSSelectorOption
icon={UserIcon}
label={option.label}
description={descriptions[option.value]}
/>
)}
- </XDSSelector>
+ />
);
}
diff --git a/packages/core/src/MultiSelector/MultiSelector.doc.mjs b/packages/core/src/MultiSelector/MultiSelector.doc.mjs
index c7c105b90f..473a07574d 100644
--- a/packages/core/src/MultiSelector/MultiSelector.doc.mjs
+++ b/packages/core/src/MultiSelector/MultiSelector.doc.mjs
@@ -7,7 +7,17 @@ export const docs = {
displayName: 'Multi Selector',
group: 'Selector',
category: 'Data Input',
- keywords: ['multiselect', 'checkbox', 'dropdown', 'multi', 'picker', 'checklist', 'facet', 'filter', 'select'],
+ keywords: [
+ 'multiselect',
+ 'checkbox',
+ 'dropdown',
+ 'multi',
+ 'picker',
+ 'checklist',
+ 'facet',
+ 'filter',
+ 'select',
+ ],
theming: {
targets: [
{className: 'xds-multi-selector', visualProps: ['size', 'status']},
@@ -133,9 +143,10 @@ export const docs = {
description: 'Validation status with an optional message.',
},
{
- name: 'children',
+ name: 'renderOption',
type: '(option: XDSMultiSelectorOptionData) => ReactNode',
- description: 'Custom render function for each option in the dropdown.',
+ description:
+ 'Custom render function for each selectable option in the dropdown. Not called for dividers, sections, or the select-all row.',
},
{
name: 'xstyle',
@@ -143,17 +154,41 @@ export const docs = {
description:
'StyleX styles for layout customization. Must be a stylex.create() value.',
},
- ], },
+ ],
+ },
],
usage: {
description:
'A checkbox dropdown for selecting multiple values from a list. Selected items can display as a count, labels, or badges. Use it for filtering or when presenting a finite set of options where multiple choices are needed.',
bestPractices: [
- { guidance: true, description: 'Use for a moderate, finite set of options where multiple choices are needed.' },
- { guidance: true, description: 'Enable search filtering when the list exceeds ~15 options.' },
- { guidance: true, description: 'Enable select-all when most users will want all or nearly all options selected.' },
- { guidance: false, description: 'Use for single-value selection; use Selector instead.' },
- { guidance: false, description: 'Show more than ~20 options without enabling search.' },
+ {
+ guidance: true,
+ description:
+ 'Use for a moderate, finite set of options where multiple choices are needed.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Enable search filtering when the list exceeds ~15 options.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use renderOption for custom option rows; the checkbox affordance remains owned by XDSMultiSelector.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Enable select-all when most users will want all or nearly all options selected.',
+ },
+ {
+ guidance: false,
+ description: 'Use for single-value selection; use Selector instead.',
+ },
+ {
+ guidance: false,
+ description: 'Show more than ~20 options without enabling search.',
+ },
],
},
};
@@ -167,14 +202,16 @@ export const docsZh = {
description: '带复选框的多选下拉框,用于从列表中选择多项。',
propDescriptions: {
label: '无障碍标签文本。',
- options: '项目数组——字符串、带 value/label/icon/disabled 的对象、分隔线或分组。',
+ options:
+ '项目数组——字符串、带 value/label/icon/disabled 的对象、分隔线或分组。',
value: '当前选中的值。',
onChange: '选择变化时触发的回调。',
changeAction: '变化时的异步操作,在 onChange 之后触发。',
placeholder: '未选择值时显示的占位文本。',
size: '选择器的尺寸变体。',
triggerDisplay: '在触发器中显示选中项的方式。',
- maxBadges: '显示"+N"之前的最大徽章数。仅适用于 triggerDisplay="badges"。',
+ maxBadges:
+ '显示"+N"之前的最大徽章数。仅适用于 triggerDisplay="badges"。',
hasSelectAll: '是否显示全选复选框。',
selectAllLabel: '全选复选框的标签。',
hasSearch: '是否显示用于过滤选项的搜索输入。',
@@ -186,7 +223,8 @@ export const docsZh = {
isRequired: '将字段标记为必填。',
isLoading: '在触发器中显示加载旋转器。',
status: '带可选消息的验证状态。',
- children: '每个选项的自定义渲染函数。',
+ renderOption:
+ '每个可选选项的自定义渲染函数。不会用于分隔线、分组或全选行。',
xstyle: '布局自定义的 StyleX 样式,必须是 stylex.create() 值。',
},
},
@@ -195,27 +233,64 @@ export const docsZh = {
description:
'A checkbox dropdown for selecting multiple values from a list. Selected items can display as a count, labels, or badges. Use it for filtering or when presenting a finite set of options where multiple choices are needed.',
bestPractices: [
- { guidance: true, description: 'Use for a moderate, finite set of options where multiple choices are needed.' },
- { guidance: true, description: 'Enable search filtering when the list exceeds ~15 options.' },
- { guidance: true, description: 'Enable select-all when most users will want all or nearly all options selected.' },
- { guidance: false, description: 'Use for single-value selection; use Selector instead.' },
- { guidance: false, description: 'Show more than ~20 options without enabling search.' },
+ {
+ guidance: true,
+ description:
+ 'Use for a moderate, finite set of options where multiple choices are needed.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Enable search filtering when the list exceeds ~15 options.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Enable select-all when most users will want all or nearly all options selected.',
+ },
+ {
+ guidance: false,
+ description: 'Use for single-value selection; use Selector instead.',
+ },
+ {
+ guidance: false,
+ description: 'Show more than ~20 options without enabling search.',
+ },
],
},
};
/** @type {import('../docs-types').TranslationDoc} */
export const docsDense = {
- description: 'checkbox multi-select dropdown for finite sets like column toggles or filter facets',
+ description:
+ 'checkbox multi-select dropdown for finite sets like column toggles or filter facets',
usage: {
description:
'A checkbox dropdown for selecting multiple values from a list. Selected items can display as a count, labels, or badges. Use it for filtering or when presenting a finite set of options where multiple choices are needed.',
bestPractices: [
- { guidance: true, description: 'Use for a moderate, finite set of options where multiple choices are needed.' },
- { guidance: true, description: 'Enable search filtering when the list exceeds ~15 options.' },
- { guidance: true, description: 'Enable select-all when most users will want all or nearly all options selected.' },
- { guidance: false, description: 'Use for single-value selection; use Selector instead.' },
- { guidance: false, description: 'Show more than ~20 options without enabling search.' },
+ {
+ guidance: true,
+ description:
+ 'Use for a moderate, finite set of options where multiple choices are needed.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Enable search filtering when the list exceeds ~15 options.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Enable select-all when most users will want all or nearly all options selected.',
+ },
+ {
+ guidance: false,
+ description: 'Use for single-value selection; use Selector instead.',
+ },
+ {
+ guidance: false,
+ description: 'Show more than ~20 options without enabling search.',
+ },
],
},
components: [
@@ -225,7 +300,8 @@ export const docsDense = {
description: 'checkbox multi-select dropdown',
propDescriptions: {
label: 'a11y label',
- options: 'items: strings, objects w/ value/label/icon/disabled, dividers, sections',
+ options:
+ 'items: strings, objects w/ value/label/icon/disabled, dividers, sections',
value: 'selected values',
onChange: 'callback on selection change',
changeAction: 'async; fires after onChange',
@@ -244,7 +320,8 @@ export const docsDense = {
isRequired: 'marks required',
isLoading: 'spinner in trigger',
status: 'validation status w/ optional message',
- children: 'custom render fn per option',
+ renderOption:
+ 'custom render fn per selectable option; not dividers/sections/select-all',
xstyle: 'StyleX layout styles; stylex.create() only',
},
},
diff --git a/packages/core/src/MultiSelector/XDSMultiSelector.test.tsx b/packages/core/src/MultiSelector/XDSMultiSelector.test.tsx
index a7c7c53357..e712f4b652 100644
--- a/packages/core/src/MultiSelector/XDSMultiSelector.test.tsx
+++ b/packages/core/src/MultiSelector/XDSMultiSelector.test.tsx
@@ -59,6 +59,23 @@ describe('XDSMultiSelector', () => {
expect(screen.getByLabelText('Fruit')).toBeInTheDocument();
});
+ it('renders custom option content with renderOption', async () => {
+ const user = userEvent.setup();
+ render(
+ <XDSMultiSelector
+ label="Fruit"
+ options={[{value: 'apple', label: 'Apple'}]}
+ value={[]}
+ onChange={() => {}}
+ renderOption={option => (
+ <span data-testid="custom-option">{option.label}</span>
+ )}
+ />,
+ );
+
+ await user.click(screen.getByRole('combobox'));
+ expect(screen.getByTestId('custom-option')).toHaveTextContent('Apple');
+ });
it('renders placeholder when no value selected', () => {
render(
<XDSMultiSelector
diff --git a/packages/core/src/MultiSelector/XDSMultiSelector.tsx b/packages/core/src/MultiSelector/XDSMultiSelector.tsx
index 26e7be4a3f..c86e24bff2 100644
--- a/packages/core/src/MultiSelector/XDSMultiSelector.tsx
+++ b/packages/core/src/MultiSelector/XDSMultiSelector.tsx
@@ -499,9 +499,9 @@ export interface XDSMultiSelectorProps<
/**
* Custom render function for options.
- * Only called for selectable options (not dividers/sections).
+ * Only called for selectable options (not dividers/sections or the select-all row).
*/
- children?: (option: XDSMultiSelectorOptionData) => ReactNode;
+ renderOption?: (option: XDSMultiSelectorOptionData) => ReactNode;
/**
* Whether the dropdown starts open on mount.
@@ -555,7 +555,7 @@ export function XDSMultiSelector<T extends XDSMultiSelectorOptionType>({
searchPlaceholder = 'Search...',
triggerDisplay = 'count',
maxBadges = 3,
- children,
+ renderOption,
isDefaultOpen = false,
'data-testid': testId,
xstyle,
@@ -969,8 +969,8 @@ export function XDSMultiSelector<T extends XDSMultiSelectorOptionType>({
size={size === 'lg' ? 'md' : size}
/>
</div>
- {children && !isSelectAll ? (
- children(item)
+ {renderOption && !isSelectAll ? (
+ renderOption(item)
) : (
<span
{...stylex.props(
@@ -984,7 +984,7 @@ export function XDSMultiSelector<T extends XDSMultiSelectorOptionType>({
);
},
[
- children,
+ renderOption,
highlightedIndex,
optimisticValue,
allEnabledSelected,
diff --git a/packages/core/src/Selector/Selector.doc.mjs b/packages/core/src/Selector/Selector.doc.mjs
index 1420cf1135..9629b8f81c 100644
--- a/packages/core/src/Selector/Selector.doc.mjs
+++ b/packages/core/src/Selector/Selector.doc.mjs
@@ -7,7 +7,18 @@ export const docs = {
displayName: 'Selector',
group: 'Selector',
category: 'Data Input',
- keywords: ["selector","select","dropdown","combobox","picker","listbox","chooser","autocomplete","option","selectmenu"],
+ keywords: [
+ 'selector',
+ 'select',
+ 'dropdown',
+ 'combobox',
+ 'picker',
+ 'listbox',
+ 'chooser',
+ 'autocomplete',
+ 'option',
+ 'selectmenu',
+ ],
theming: {
targets: [
{className: 'xds-selector', visualProps: ['size', 'status']},
@@ -41,7 +52,8 @@ export const docs = {
{
name: 'hasClear',
type: 'boolean',
- description: 'Shows a clear (×) button when a value is selected. When true, onChange also accepts null to signal the user cleared the selection.',
+ description:
+ 'Shows a clear (×) button when a value is selected. When true, onChange also accepts null to signal the user cleared the selection.',
default: 'false',
},
{
@@ -99,9 +111,10 @@ export const docs = {
description: 'Validation status with an optional message.',
},
{
- name: 'children',
- type: '(item: XDSSelectorOptionData) => ReactNode',
- description: 'Custom render function for each item in the dropdown.',
+ name: 'renderOption',
+ type: '(option: XDSSelectorOptionData) => ReactNode',
+ description:
+ 'Custom render function for each selectable option in the dropdown. Use this instead of JSX children; dividers and sections are rendered by the selector.',
},
{
name: 'xstyle',
@@ -109,29 +122,88 @@ export const docs = {
description: 'StyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value: not an inline style object like style={{}}.',
},
],
- components: [
- {name: 'XDSSelectorOption'},
- ],
+ components: [{name: 'XDSSelectorOption'}],
usage: {
description:
'A dropdown selector for choosing a single value from a list of options. Supports labels, validation, descriptions, and required/optional states. Use it in forms and settings when presenting a moderate number of options.',
bestPractices: [
- {guidance: true, description: 'Provide a visible label so users understand what they are selecting.'},
- {guidance: true, description: 'Use sections and dividers to organize options when the list exceeds ~8 items.'},
- {guidance: true, description: 'Set a meaningful placeholder that hints at the expected selection (e.g. "Choose a country" not "Select...").'},
- {guidance: false, description: 'Use for action menus; use Dropdown Menu for triggering commands or navigation.'},
- {guidance: false, description: 'Use when there are only two options; use a SegmentedControl or radio buttons instead.'},
- {guidance: false, description: 'Use Selector for navigation; links should be links, not dropdown options.'},
- {guidance: false, description: 'Use for yes/no or on/off choices; use Switch or CheckboxInput instead.'},
- {guidance: false, description: 'Put more than ~20 options without sections; consider Typeahead for large lists.'},
+ {
+ guidance: true,
+ description:
+ 'Provide a visible label so users understand what they are selecting.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use sections and dividers to organize options when the list exceeds ~8 items.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use renderOption for custom option rows. Do not pass XDSSelectorOption directly as JSX children.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Set a meaningful placeholder that hints at the expected selection (e.g. "Choose a country" not "Select...").',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use for action menus; use Dropdown Menu for triggering commands or navigation.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use when there are only two options; use a SegmentedControl or radio buttons instead.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use Selector for navigation; links should be links, not dropdown options.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use for yes/no or on/off choices; use Switch or CheckboxInput instead.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Put more than ~20 options without sections; consider Typeahead for large lists.',
+ },
],
anatomy: [
- {name: 'Label', required: false, description: 'Text label displayed above the selector.'},
- {name: 'Placeholder', required: false, description: 'Hint text shown when no value is selected.'},
- {name: 'Description', required: false, description: 'Helper text providing additional context.'},
- {name: 'Left Icon', required: false, description: 'Icon displayed to the left of the selected value.'},
- {name: 'Value', required: true, description: 'The currently selected item displayed in the selector.'},
- {name: 'List', required: true, description: 'The dropdown list of selectable options.'},
+ {
+ name: 'Label',
+ required: false,
+ description: 'Text label displayed above the selector.',
+ },
+ {
+ name: 'Placeholder',
+ required: false,
+ description: 'Hint text shown when no value is selected.',
+ },
+ {
+ name: 'Description',
+ required: false,
+ description: 'Helper text providing additional context.',
+ },
+ {
+ name: 'Left Icon',
+ required: false,
+ description: 'Icon displayed to the left of the selected value.',
+ },
+ {
+ name: 'Value',
+ required: true,
+ description: 'The currently selected item displayed in the selector.',
+ },
+ {
+ name: 'List',
+ required: true,
+ description: 'The dropdown list of selectable options.',
+ },
],
},
};
@@ -142,22 +214,78 @@ export const docsZh = {
description:
'A dropdown selector for choosing a single value from a list of options. Supports labels, validation, descriptions, and required/optional states. Use it in forms and settings when presenting a moderate number of options.',
bestPractices: [
- {guidance: true, description: 'Provide a visible label so users understand what they are selecting.'},
- {guidance: true, description: 'Use sections and dividers to organize options when the list exceeds ~8 items.'},
- {guidance: true, description: 'Set a meaningful placeholder that hints at the expected selection (e.g. "Choose a country" not "Select...").'},
- {guidance: false, description: 'Use for action menus; use Dropdown Menu for triggering commands or navigation.'},
- {guidance: false, description: 'Use when there are only two options; use a SegmentedControl or radio buttons instead.'},
- {guidance: false, description: 'Use Selector for navigation; links should be links, not dropdown options.'},
- {guidance: false, description: 'Use for yes/no or on/off choices; use Switch or CheckboxInput instead.'},
- {guidance: false, description: 'Put more than ~20 options without sections; consider Typeahead for large lists.'},
+ {
+ guidance: true,
+ description:
+ 'Provide a visible label so users understand what they are selecting.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use sections and dividers to organize options when the list exceeds ~8 items.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Set a meaningful placeholder that hints at the expected selection (e.g. "Choose a country" not "Select...").',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use for action menus; use Dropdown Menu for triggering commands or navigation.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use when there are only two options; use a SegmentedControl or radio buttons instead.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use Selector for navigation; links should be links, not dropdown options.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use for yes/no or on/off choices; use Switch or CheckboxInput instead.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Put more than ~20 options without sections; consider Typeahead for large lists.',
+ },
],
anatomy: [
- {name: 'Label', required: false, description: 'Text label displayed above the selector.'},
- {name: 'Placeholder', required: false, description: 'Hint text shown when no value is selected.'},
- {name: 'Description', required: false, description: 'Helper text providing additional context.'},
- {name: 'Left Icon', required: false, description: 'Icon displayed to the left of the selected value.'},
- {name: 'Value', required: true, description: 'The currently selected item displayed in the selector.'},
- {name: 'List', required: true, description: 'The dropdown list of selectable options.'},
+ {
+ name: 'Label',
+ required: false,
+ description: 'Text label displayed above the selector.',
+ },
+ {
+ name: 'Placeholder',
+ required: false,
+ description: 'Hint text shown when no value is selected.',
+ },
+ {
+ name: 'Description',
+ required: false,
+ description: 'Helper text providing additional context.',
+ },
+ {
+ name: 'Left Icon',
+ required: false,
+ description: 'Icon displayed to the left of the selected value.',
+ },
+ {
+ name: 'Value',
+ required: true,
+ description: 'The currently selected item displayed in the selector.',
+ },
+ {
+ name: 'List',
+ required: true,
+ description: 'The dropdown list of selectable options.',
+ },
],
},
};
@@ -168,22 +296,78 @@ export const docsDense = {
description:
'A dropdown selector for choosing a single value from a list of options. Supports labels, validation, descriptions, and required/optional states. Use it in forms and settings when presenting a moderate number of options.',
bestPractices: [
- {guidance: true, description: 'Provide a visible label so users understand what they are selecting.'},
- {guidance: true, description: 'Use sections and dividers to organize options when the list exceeds ~8 items.'},
- {guidance: true, description: 'Set a meaningful placeholder that hints at the expected selection (e.g. "Choose a country" not "Select...").'},
- {guidance: false, description: 'Use for action menus; use Dropdown Menu for triggering commands or navigation.'},
- {guidance: false, description: 'Use when there are only two options; use a SegmentedControl or radio buttons instead.'},
- {guidance: false, description: 'Use Selector for navigation; links should be links, not dropdown options.'},
- {guidance: false, description: 'Use for yes/no or on/off choices; use Switch or CheckboxInput instead.'},
- {guidance: false, description: 'Put more than ~20 options without sections; consider Typeahead for large lists.'},
+ {
+ guidance: true,
+ description:
+ 'Provide a visible label so users understand what they are selecting.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use sections and dividers to organize options when the list exceeds ~8 items.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Set a meaningful placeholder that hints at the expected selection (e.g. "Choose a country" not "Select...").',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use for action menus; use Dropdown Menu for triggering commands or navigation.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use when there are only two options; use a SegmentedControl or radio buttons instead.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use Selector for navigation; links should be links, not dropdown options.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use for yes/no or on/off choices; use Switch or CheckboxInput instead.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Put more than ~20 options without sections; consider Typeahead for large lists.',
+ },
],
anatomy: [
- {name: 'Label', required: false, description: 'Text label displayed above the selector.'},
- {name: 'Placeholder', required: false, description: 'Hint text shown when no value is selected.'},
- {name: 'Description', required: false, description: 'Helper text providing additional context.'},
- {name: 'Left Icon', required: false, description: 'Icon displayed to the left of the selected value.'},
- {name: 'Value', required: true, description: 'The currently selected item displayed in the selector.'},
- {name: 'List', required: true, description: 'The dropdown list of selectable options.'},
+ {
+ name: 'Label',
+ required: false,
+ description: 'Text label displayed above the selector.',
+ },
+ {
+ name: 'Placeholder',
+ required: false,
+ description: 'Hint text shown when no value is selected.',
+ },
+ {
+ name: 'Description',
+ required: false,
+ description: 'Helper text providing additional context.',
+ },
+ {
+ name: 'Left Icon',
+ required: false,
+ description: 'Icon displayed to the left of the selected value.',
+ },
+ {
+ name: 'Value',
+ required: true,
+ description: 'The currently selected item displayed in the selector.',
+ },
+ {
+ name: 'List',
+ required: true,
+ description: 'The dropdown list of selectable options.',
+ },
],
},
};
diff --git a/packages/core/src/Selector/SelectorOption.doc.mjs b/packages/core/src/Selector/SelectorOption.doc.mjs
index 5ae4411b69..a9cf1f3ea4 100644
--- a/packages/core/src/Selector/SelectorOption.doc.mjs
+++ b/packages/core/src/Selector/SelectorOption.doc.mjs
@@ -7,7 +7,8 @@ export const docs = {
subComponentOf: 'Selector',
displayName: 'Selector Option',
isHiddenFromOverview: true,
- description: 'Helper component for custom item rendering inside an XDSSelector children render prop.',
+ description:
+ 'Helper component for custom item rendering inside an XDSSelector renderOption prop.',
props: [
{
name: 'label',
@@ -18,7 +19,8 @@ export const docs = {
{
name: 'icon',
type: 'XDSIconType',
- description: 'Icon displayed before the label. See `npx xds docs icons` for valid semantic names.',
+ description:
+ 'Icon displayed before the label. See `npx xds docs icons` for valid semantic names.',
},
{
name: 'description',
@@ -28,7 +30,8 @@ export const docs = {
{
name: 'endContent',
type: 'ReactNode',
- description: 'Additional content rendered after the label and description.',
+ description:
+ 'Additional content rendered after the label and description.',
},
],
};
@@ -37,7 +40,8 @@ export const docsZh = {
name: 'SelectorOption',
isHiddenFromOverview: true,
displayName: 'Selector Option',
- description: '用于在 XDSSelector 的 children 渲染函数中自定义选项渲染的辅助组件。',
+ description:
+ '用于在 XDSSelector 的 renderOption 渲染函数中自定义选项渲染的辅助组件。',
props: [
{
name: 'label',
@@ -67,7 +71,8 @@ export const docsDense = {
name: 'SelectorOption',
isHiddenFromOverview: true,
displayName: 'Selector Option',
- description: 'Helper component for custom item rendering inside XDSSelector children render prop.',
+ description:
+ 'Helper component for custom item rendering inside XDSSelector renderOption prop.',
propDescriptions: {
label: 'Primary label text for item.',
icon: 'Icon displayed before label.',
diff --git a/packages/core/src/Selector/XDSSelector.test.tsx b/packages/core/src/Selector/XDSSelector.test.tsx
index 46bc511286..aefeacecd6 100644
--- a/packages/core/src/Selector/XDSSelector.test.tsx
+++ b/packages/core/src/Selector/XDSSelector.test.tsx
@@ -133,14 +133,14 @@ describe('XDSSelector', () => {
label="Role"
options={[{value: 'admin', label: 'Admin'}]}
value={undefined}
- onChange={() => {}}>
- {option => (
+ onChange={() => {}}
+ renderOption={option => (
<XDSSelectorOption
label={option.label}
endContent={<span data-testid="option-badge">Owner</span>}
/>
)}
- </XDSSelector>,
+ />,
);
await user.click(screen.getByRole('combobox'));
diff --git a/packages/core/src/Selector/XDSSelector.tsx b/packages/core/src/Selector/XDSSelector.tsx
index ea491a5031..cfa26956a3 100644
--- a/packages/core/src/Selector/XDSSelector.tsx
+++ b/packages/core/src/Selector/XDSSelector.tsx
@@ -418,7 +418,7 @@ interface XDSSelectorPropsBase<
* Custom render function for options.
* Only called for selectable options (not dividers/sections).
*/
- children?: (option: XDSSelectorOptionData) => ReactNode;
+ renderOption?: (option: XDSSelectorOptionData) => ReactNode;
/**
* Whether to show a search input for filtering options.
@@ -533,7 +533,7 @@ export function XDSSelector<T extends XDSSelectorOptionType>(
status,
labelTooltip,
startIcon,
- children,
+ renderOption,
hasSearch = false,
searchPlaceholder = 'Search...',
placement,
@@ -763,14 +763,18 @@ export function XDSSelector<T extends XDSSelectorOptionType>(
item.disabled && styles.itemDisabled,
)}>
<span {...stylex.props(styles.itemContent)}>
- {children ? children(item) : <DefaultOption option={item} />}
+ {renderOption ? (
+ renderOption(item)
+ ) : (
+ <DefaultOption option={item} />
+ )}
</span>
{isSelected && <XDSIcon icon="check" size="sm" color="accent" />}
</div>
);
},
[
- children,
+ renderOption,
highlightedIndex,
size,
normalizedValue,
diff --git a/packages/core/src/Selector/XDSSelectorOption.tsx b/packages/core/src/Selector/XDSSelectorOption.tsx
index 634f584d66..db4d1ac491 100644
--- a/packages/core/src/Selector/XDSSelectorOption.tsx
+++ b/packages/core/src/Selector/XDSSelectorOption.tsx
@@ -71,7 +71,7 @@ export interface XDSSelectorOptionProps {
/**
* A helper component for rendering custom selector options with consistent styling.
*
- * Use this inside the `children` render prop of XDSSelector to create
+ * Use this inside the `renderOption` prop of XDSSelector to create
* custom option layouts while maintaining design system consistency.
*
* @example
@@ -80,15 +80,15 @@ export interface XDSSelectorOptionProps {
* label="User"
* options={users}
* value={value}
- * onChange={setValue}>
- * {option => (
+ * onChange={setValue}
+ * renderOption={option => (
* <XDSSelectorOption
* icon={UserIcon}
* label={option.label}
* description={option.email}
* />
* )}
- * </XDSSelector>
+ * />
* ```
*/
export function XDSSelectorOption({