Select grid
Using Combobox with ComboboxPopover rendered with the grid role to create a bidimensional list of selectable items.
Position
Top Left
Top Center
Top Right
Center Left
Center
Center Right
Bottom Left
Bottom Center
Bottom Right
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768import * as Ariakit from "@ariakit/react";import { useState } from "react";import Square from "./square.tsx";import "./style.css";export default function Example() {const [value, setValue] = useState("Center");});const renderItem = (value: string) => (role="gridcell"className="select-item"// When the mouse leaves the item, we don't want to unset the active// item.if (event.type === "mouseleave") return false;// By default, hovering over an item doesn't focus it, nor does it set// the value. So we need to manually "move" to the item so it gets// focused and the value is set.combobox.move(event.currentTarget.id);return true;}}>);return (<div className="wrapper">><Square value={value} />{value}{renderItem("Top Left")}{renderItem("Top Center")}{renderItem("Top Right")}{renderItem("Center Left")}{renderItem("Center")}{renderItem("Center Right")}{renderItem("Bottom Left")}{renderItem("Bottom Center")}{renderItem("Bottom Right")}</div>);}import * as Ariakit from "@ariakit/react";import { useState } from "react";import Square from "./square.tsx";import "./style.css";export default function Example() {const [value, setValue] = useState("Center");});const renderItem = (value: string) => (role="gridcell"className="select-item"// When the mouse leaves the item, we don't want to unset the active// item.if (event.type === "mouseleave") return false;// By default, hovering over an item doesn't focus it, nor does it set// the value. So we need to manually "move" to the item so it gets// focused and the value is set.combobox.move(event.currentTarget.id);return true;}}>);return (<div className="wrapper">><Square value={value} />{value}{renderItem("Top Left")}{renderItem("Top Center")}{renderItem("Top Right")}{renderItem("Center Left")}{renderItem("Center")}{renderItem("Center Right")}{renderItem("Bottom Left")}{renderItem("Bottom Center")}{renderItem("Bottom Right")}</div>);}