useFocusVisible

useFocusVisible manages focus interactions on the page and determines whether a focus ring should be shown. When using the useFocusVisible hook, if a user interacts with a mouse or by touch, then the focus indicator is not visible. When the user interacts with the keyboard however, the focus indicator will be visible.

References:

Example

Using useFocusVisible(): Focus ring is only visible when using keyboard
Not using useFocusVisible(): Focus ring is always visible