
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
react-sticky-spy
Advanced tools
Super minimal `400 byte` css and dependencies free react component that detects and add a custom attribute to a `position: sticky` element when it is stuck inside the scrolling container.
Super minimal 400 byte css and dependencies free react component that detects and add a custom attribute to a position: sticky element when it is stuck inside the scrolling container.
Install the package with your favourite package manager:
npm i react-sticky-spy
# or
pnpm i react-sticky-spy
# or
yarn add react-sticky-spy
Import the component and wrap your sticky element. This component doesn't add any wrapper so your markup and style is safe (well, it adds just a empty spy element before but...Hey 👉😎👉, it's free)
The StickySpy component add a custom attribute to the wrapped element so you can control the style using CSS. Additionally, by using the onStickyChange callback you can do your js stuff when the element is stuck or not.
import { StickySpy } from 'react-sticky-spy'
const MyPage = () => (
<div style={{ overflow: 'auto' }}>
<StickySpy>
<h1 style={{ position: 'sticky', top: 0 }}>Position sticky title</h1>
</StickySpy>
...
<div>
)
h1[data-react-is-sticky="true"] {
border-bottom: 1px solid gray;
}
Warning The
CSSfor the sticky position is not included. Add your own style to the wrapped element.
export type StickySpyProps = PropsWithChildren<{
/**
* Set a custom name for the attribute
* @default "data-react-is-sticky"
*/
attribute?: string;
/**
* Callback function that is called when the sticky element changes
* @param isSticky Current state of the sticky element
*/
onStickyChange?: (isSticky: boolean) => void;
}>
FAQs
Super minimal `400 byte` css and dependencies free react component that detects and add a custom attribute to a `position: sticky` element when it is stuck inside the scrolling container.
We found that react-sticky-spy 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.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.