useFocusable
function useFocusable(options?): UseFocusableResult;Hook to make any element focusable with keyboard support.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options | UseFocusableOptions |
Returns
Section titled “Returns”Example
Section titled “Example”function CustomPicker({ onSelect }) { const { ref, isFocused, focus } = useFocusable({ onKeyPress: (key) => { if (key.name === "return") { onSelect(); return true; } return false; }, });
return ( <Box ref={ref} focusable style={{ border: "round", borderColor: isFocused ? "cyan" : "gray" }} > <Text>Custom Picker</Text> </Box> );}