Skip to content

useFocus ​

Category
Browser

Hook that allows you to focus on a specific element

typescript
import { useFocus } from '@siberiacancode/reactuse';

Usage ​

typescript
const { focus, blur, focused } = useFocus(target);

Demo ​

Api ​

Parameters

NameTypeDefaultNote
targetTarget-The target element to focus
options.initialFocus?booleanfalseThe initial focus state of the target

Parameters

NameTypeDefaultNote
options.initialFocus?booleanfalseThe initial focus state of the target

Contributors ​

Source • Demo