useFocusWithin

Tags:

A React Hook that returns a boolean value indicating whether the component is focused or any of its children are focused.

Demo

Source
Focused Within Amber Box:
false

Usage

See API for more details.

Source

Click links below to view source on GitHub.

API

const isFocusWithin = useFocusWithin(elementTarget)

ElementTarget

ElementTarget is a union type that represents various kinds of elements that can be targeted.

See ElementTarget or ElementTarget Types for more details.

Returns

A boolean value indicating whether it's focused within the target.