You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/app/(docs)/react/components/combobox/page.mdx
+21-2Lines changed: 21 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,8 +73,27 @@ import { Combobox } from '@base-ui/react/combobox';
73
73
74
74
## TypeScript
75
75
76
-
Combobox infers the item type from the `defaultValue` or `value` props passed to `<Combobox.Root>`.
77
-
The type of items held in the `items` array must also match the `value` prop type passed to `<Combobox.Item>`.
76
+
Combobox infers the selected value type from `defaultValue`, `value`, or the return value of `itemToValue`.
77
+
Source items and explicitly specified `<Combobox.Item value>` props can have different types. Use `itemToValue` to derive selection values automatically when rendering a collection: filtering and collection children receive source items, while change callbacks and equality checks receive mapped values.
78
+
Mapped values must be defined and unique. An explicit item `value` takes precedence over `itemToValue`.
79
+
80
+
For example, the source items can be user objects while selection uses only their IDs. Their `label` fields are used automatically for display and filtering:
81
+
82
+
```tsx title="Mapping source items to selection values"
0 commit comments