Gathering detailed insights and metrics for usefocuswithin
Gathering detailed insights and metrics for usefocuswithin
Gathering detailed insights and metrics for usefocuswithin
Gathering detailed insights and metrics for usefocuswithin
React Hook to detect if an element or its descendent element has focus.
npm install usefocuswithin
Typescript
Module System
Node Version
NPM Version
60.3
Supply Chain
73.6
Quality
74.8
Maintenance
100
Vulnerability
100
License
JavaScript (63.29%)
HTML (30.27%)
CSS (6.44%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
4 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Aug 23, 2024
Latest Version
1.0.1
Package Id
usefocuswithin@1.0.1
Unpacked Size
4.28 kB
Size
1.79 kB
File Count
4
NPM Version
6.14.11
Node Version
14.15.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
React Hook to detect if an element or its descendent element has focus. Similar to css :focus-within
pseudo-class behaviour.
Currently, only change of focus with mouse 'click' event is processed. If focus is changed with Tab
or any other means then the isFocusWithin
will not update.
npm install usefocuswithin
yarn add usefocuswithin
1import React from "react"; 2import { usefocuswithin } from "usefocuswithin"; 3 4function App() { 5 const targetRef = React.useRef(null); 6 const isFocusWithin = usefocuswithin(targetRef); 7 8 return ( 9 <div 10 ref={targetRef} 11 style={{ border: `1px solid ${isFocusWithin ? "green" : "red"}` }} 12 > 13 <input></input> 14 </div> 15 ); 16}
Argument | Type | Required? | Description |
---|---|---|---|
target | React.RefObject | Yes | A React ref created by useRef() or an HTML element |
options | Object | Yes | Configuration options for the hook. See Options below. |
boolean
This hook returns true
if the element in ref
or any of its descendent element is focused, otherwise false
.
Property | Type | Description |
---|---|---|
mouse | boolean | Detects change of focus due to mouse click event. |
keyboard | boolean | Detects change of focus due to Tab keypress on keyboard. |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/4 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
94 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More