diff --git a/src/pages/components/combobox.mdx b/src/pages/components/combobox.mdx index 67d730e3f..02e4ba687 100644 --- a/src/pages/components/combobox.mdx +++ b/src/pages/components/combobox.mdx @@ -239,11 +239,63 @@ The Combobox component follows this structure: + {/* etc. */} ``` +Use `Array.map` to iterate over options. + +```jsx +const OPTIONS = [ + { value: 'Sunflower' }, + { + label: 'More flowers', + options: [ + { value: 'Violet' }, + { value: 'Daisy' }, + ] + } +] + + + {OPTIONS.map(option => + option.options ? ( + + {option.options.map(groupOption => ( + + ) : ( + +``` + +Match `Option` and `OptGroup` prop signatures when using wrapper components. + +```jsx +const OptionComponent = forwardRef((props, ref) => ( + +)) + + + + + + + + +``` + ### Combobox diff --git a/src/pages/components/menu.mdx b/src/pages/components/menu.mdx index 4a1308839..f1e0c598b 100644 --- a/src/pages/components/menu.mdx +++ b/src/pages/components/menu.mdx @@ -171,10 +171,62 @@ The Menu component follows this structure: + + + {/* etc. */} ``` +Use `Array.map` to iterate over items. + +```jsx +const ITEMS = [ + { value: 'Sunflower' }, + { + legend: 'More flowers', + items: [ + { value: 'Violet' }, + { value: 'Daisy' }, + ] + } +] + + + {ITEMS.map(item => + item.items ? ( + + {item.items.map(groupItem => ( + + ))} + + ) : ( + + ) + )} + +``` + +Match `Item` and `ItemGroup` prop signatures when using wrapper components. + +```jsx +const ItemComponent = forwardRef((props, ref) => ( + +)) + +const ItemGroupComponent = forwardRef((props, ref) => ( + +)) + + + + + + + + +``` + ### Menu