--- title: "Combobox" slug: combobox category: component type: examples version: 20.0.0 tokens: 1769 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-combobox--examples.txt --- # Combobox ## Default ```tsx ``` ## Clearable ```tsx ``` ## Disabled ```tsx ``` ## Readonly ```tsx ``` ## Group ```tsx ``` ## Invalid ```tsx ``` ## Controlled ```tsx { const [value, setValue] = useState(['dog']); return ( <> setValue(details.value) } value={ value }>
Selected value: { value[0] ?? 'None' }
); } ``` ## Highlight ```tsx ``` ## Custom Options ```tsx { type MyData = { color?: string; info?: string; }; const items = [ { label: 'Apple', value: 'apple', customRendererData: { color: 'red', info: 'Fruit' }}, { label: 'Banana', value: 'banana', customRendererData: { color: 'yellow', info: 'Fruit' }}, { label: 'Carrot', value: 'carrot', customRendererData: { color: 'orange', info: 'Vegetable' }}, { label: 'Broccoli', value: 'broccoli', customRendererData: { color: 'green', info: 'Vegetable' }}, { label: 'Blueberry', value: 'blueberry', customRendererData: { color: 'blue', info: 'Fruit' }}, ]; function customOptionRenderer(item: ComboboxItem) { return ( { item.label } { item.customRendererData?.info && ({ item.customRendererData.info }) } ); } return ( ); } ``` ## Custom Filter ```tsx { const reversedLabel = label.split('').reverse().join(''); return new RegExp(`^${inputValue}`, 'i').test(reversedLabel); }} items={[ { label: 'Dog', value: 'dog' }, { label: 'Cat', value: 'cat' }, { label: 'Hamster', value: 'hamster' }, { label: 'Parrot', value: 'parrot' }, { label: 'Spider', value: 'spider' }, { label: 'Goldfish', value: 'goldfish' }, ]}> ``` ## Empty ```tsx ``` ## Multiple ```tsx ``` ## In Form Field ```tsx Combobox ``` ## Accessibility Form Field ```tsx Favorite pet: ``` ## Accessibility I18n ```tsx Favorite pet: ```