
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
use-spotlight
Advanced tools
A react hook that generates an animated 'spotlight' follows the active target.
https://github.com/9am/use-spotlight/assets/1435457/5b570780-abb7-4df9-9e19-7454eafecce4
| Description | Live demo |
|---|---|
| Basic | |
| Auto-updated resize | |
| Auto-updated DOM change | |
| Throttle | |
| Custom light style | |
| Pseudo light |
[!NOTE]
- An animated active indicator for a component like
<ToggleButton>,<Tabs>.- A highlight effect for a self-controlled focused system, like the result list of a
<SearchBar>.- ...
npm install use-spotlight
+import { useSpotlight } from 'use-spotlight'
() => {
const [active, setActive] = useState(-1)
// init hook
+ const { stage, actor, style } = useSpotlight()
return (
// set ref for 'stage'
<ul
+ ref={stage}
>
{list.map(({ val }) => (
<li
onClick={() => setActive(val)}
// set ref for 'actor'
+ ref={val === active ? actor : null}
>
{val}
</li>
))}
// set 'style' to the light
+ <i style={style} />
</ul>
)
}
useSpotlight( SpotlightOptions? )SpotlightOptionsthrottleWait: The number of milliseconds to throttle invocations to. default: 0stageBorderEdge: With default setting, the 'light' will be positioned relative to the padding edge of the 'stage', which will cause an offset if 'stage' has borders. Set to true, if want to use the border edge, which will hurt performance but be more accurate on the position. default: falsestageMutation: Enable watching 'stage' childlist subtree DOM mutation. default: falselightPseudo: ::before or ::after to enable pseudo element as 'light'. In this mode, there's no need to insert a 'light' element explicitly. It's useful for case that no extra element wanted under the 'stage'. default: nullSpotlightstage: The RefCallback which will be assigned to node as container.actor: The RefCallback which will be assigned to node as target to follow.style: The CSSProperties for the node 'light'.size: The offset [x, y, width, height] between 'actor' and 'stage'.[!IMPORTANT]
stageBorderEdge=trueusesgetComputedStyle()to calculate thebordersize of 'stage', but it's bad for performance, there're other alternatives to achieve this:
- Use
outlineinstead ofborder.- Override the style of 'light':
top: -1 * var(--border-top-size-stage),left: -1 * var(--border-left-size-stage)stageMutation=trueadd an extraMutationObserverto the 'stage', consider using the default setting unless it can not cover some of the cases.
FAQs
A react hook that generates an animated 'spotlight' follows the active target.
The npm package use-spotlight receives a total of 3 weekly downloads. As such, use-spotlight popularity was classified as not popular.
We found that use-spotlight demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.