Combo box without autocomplete
A Combo box which does not autocomplete.
If no onSearch
method is provided the list of options is static and aria-autcomplete
is set to none
.
import { useState } from 'react';
import { ComboBox } from '@citizensadvice/react-combo-boxes';
const options = ['Apple', 'Banana', 'Cherry', 'Mango', 'Ugli fruit'];
export function Example() {
const [value, setValue] = useState(null);
return (
<>
<label
id="select-label"
htmlFor="select"
>
Select
</label>
<ComboBox
id="select"
aria-labelledby="select-label"
value={value}
onValue={setValue}
options={options}
/>
<label htmlFor="output">Current value</label>
<output
htmlFor="select"
id="output"
>
{JSON.stringify(value, undefined, ' ')}
</output>
</>
);
}