npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-scroll-sense-header

v1.0.8

Published

A React component that provides intelligent header behavior based on scroll position. The header can hide/show on scroll, stay fixed, or remain at the top of the document.

Readme

React ScrollSenseHeader

A React component that provides intelligent header behavior based on scroll position. The header can hide/show on scroll, stay fixed, or remain at the top of the document.

Features

  • Hide on Scroll: Header disappears when scrolling down, reappears when scrolling up
  • Always Fixed: Header stays fixed at the top of the viewport
  • Always Top: Header stays at the top of the document
  • Customizable Thresholds: Control when the header becomes sticky or hides
  • Box Shadow Presets: Choose from light, medium, heavy, or none
  • Smooth Transitions: Adjustable transition duration (set to 0 for instant changes)
  • Custom Styling: Full control over colors, z-index, and CSS classes
  • TypeScript Support: Full TypeScript definitions included
  • Ref Support: Access component methods and state via ref

Installation

npm install react-scroll-sense-header

Demo

See the component in action: Live Demo

CSS Import

You need to import the CSS styles in your application:

import 'react-scroll-sense-header/dist/styles.css';

Usage

import { ScrollSenseHeader, ScrollSenseHeaderRef } from 'react-scroll-sense-header';
import 'react-scroll-sense-header/dist/styles.css';

function App() {
  return (
    <ScrollSenseHeader>
      <header>
        Your header content...
      </header>
    </ScrollSenseHeader>
  );
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | behavior | 'hide-on-scroll' \| 'always-fixed' \| 'always-top' | 'hide-on-scroll' | Header behavior mode | | hideThreshold | number | 100 | Pixels to scroll before hiding (hide-on-scroll only) | | showThreshold | number | 3 | Pixels to scroll up before showing (hide-on-scroll only) | | boxShadow | 'none' \| 'light' \| 'medium' \| 'heavy' | 'light' | Box shadow preset | | transitionDuration | number | 300 | Transition duration in milliseconds (0 for instant) | | zIndex | number | 1000 | CSS z-index value | | backgroundColor | string | 'transparent' | Background color | | className | string | '' | Additional CSS classes | | style | React.CSSProperties | {} | Additional inline styles | | dataAttribute | string | 'data-scroll-sense-header' | Data attribute for the header element | | onScrollStateChange | (isSticky: boolean, isHidden: boolean) => void | undefined | Callback when scroll state changes |

Ref Methods

Access these methods through the ref:

const headerRef = useRef<ScrollSenseHeaderRef>(null);

// Get current scroll state
const scrollState = headerRef.current?.getScrollState();
// Returns: { isSticky: boolean, isHidden: boolean, isTransitioning: boolean }

// Reset header to initial state
headerRef.current?.reset();

Behavior Modes

Hide on Scroll

  • Header becomes sticky when scrolling down past hideThreshold
  • Header hides when continuing to scroll down
  • Header shows when scrolling up past showThreshold

Always Fixed

  • Header stays fixed at the top of the viewport
  • No hiding/showing behavior

Always Top

  • Header stays at the top of the document
  • Scrolls with the page content

Styling

The component includes built-in CSS classes:

.scroll-sense-header {
  /* Base styles */
}

.scroll-sense-header--sticky {
  /* Applied when header becomes sticky */
}

.scroll-sense-header--hidden {
  /* Applied when header is hidden */
}

.scroll-sense-header--sticky-transition {
  /* Applied during transitions */
}

.scroll-sense-header--box-shadow-light {
  /* Light box shadow */
}

.scroll-sense-header--box-shadow-medium {
  /* Medium box shadow */
}

.scroll-sense-header--box-shadow-heavy {
  /* Heavy box shadow */
}

Custom Styling

You can customize the appearance using:

  1. CSS Classes: Add your own classes via the className prop
  2. Inline Styles: Use the style prop for dynamic styling
<ScrollSenseHeader
  className="my-custom-header"
  style={{
    background: 'linear-gradient(45deg, #667eea, #764ba2)',
    color: 'white'
  }}
>
  {/* Header content */}
</ScrollSenseHeader>

TypeScript

The package includes full TypeScript definitions:

import { 
  ScrollSenseHeader, 
  ScrollSenseHeaderRef, 
  ScrollSenseHeaderProps,
  BoxShadowPreset 
} from 'react-scroll-sense-header';

Browser Support

  • Modern browsers with ES6+ support
  • React 16.8+ (hooks support required)

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.