1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import {
Combobox,
ComboboxItem,
ComboboxList,
useComboboxState,
} from "ariakit/combobox";
import {
Menu,
MenuArrow,
MenuButton,
MenuButtonArrow,
useMenuState,
} from "ariakit/menu";
import defaultList from "./list";
import "./style.css";
export default function Example() {
const combobox = useComboboxState({ defaultList });
const menu = useMenuState(combobox);
if (!menu.mounted && combobox.value) {
combobox.setValue("");
}
return (
<>
<MenuButton state={menu} className="button">
Add block
<MenuButtonArrow />
</MenuButton>
<Menu state={menu} composite={false} className="menu">
<MenuArrow />
<Combobox
state={combobox}
autoSelect
placeholder="Search..."
className="combobox"
/>
<ComboboxList state={combobox} className="combobox-list">
{combobox.matches.map((value, i) => (
<ComboboxItem
key={value + i}
value={value}
focusOnHover
setValueOnClick={false}
className="menu-item"
/>
))}
</ComboboxList>
</Menu>
</>
);
}