Content
useFocus
A hook that returns a ref and a boolean indicating whether the element is currently focused.
useFocus
Usage
API
useFocus
Returns a ref and boolean indicating whether the element is currently focused.
Parameters
Name | Type | Description |
---|---|---|
callback? | UseFocusCallback | Optional callback to run in focus and blur HTML element mode. The callback is called with a boolean indicating whether the element is currently focused. |
T | HTMLElement | The type of the HTML element to focus. |
Returns
Name | Type | Description |
---|---|---|
ref | RefObject<T> | A ref object that can be used to access the HTML element. |
isFocused | boolean | A boolean indicating whether the element is currently focused. |