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

sticky-polite

v1.2.1

Published

Position sticky when you need it, out of the way when you dont

Readme

sticky-polite

npm package minimized gzipped size Zero Dependencies Static Badge Static Badge Static Badge

stick-polite-animation

A robust, zero-dependency headless utility for 'polite' sticky positioning. Imagine if position: sticky could understand when your user wants it out of the way and politely excuses itself from the viewport.

Keep important page elements highly available, while keeping the screen clear of distractions.

Code Sandbox

Live Preview

Key Features:

  • nearly-zero setup: Apply the class name sticky-polite and an edge offset to an element, and you are done.
  • Compatible with React/Vue/Svelte: Performance-optimized observers manage sticky-polite element lifecycles.
  • axis and direction agnostic: Elements can stick to the top, bottom, left or right.
  • Supports nested scrolling containers: Elements within a scroll container will respect the boundaries of its parent.
  • No animations/transitions: Interactions feel buttery and smooth, like native browser behavior - because most of it is!

Limitations:

  • Mobile footer: Mobile browsers manipulate the viewport size when scrolling in a ways that are difficult to predict/adapt to. Footers whose scrolling-parent are the body/document cannot always transition smoothly between 'hidden' and 'visible'. So it goes.
  • single edge: While position: sticky supports all four edges simultaneously, sticky-polite supports one. This feels like the appropriate balance between package size/complexity and core-use coverage.

Installation

npm install sticky-polite

Usage

Import the package.

// main.js or index.js
import "sticky-polite";

or

<script src="https://unpkg.com/sticky-polite/dist/index.cjs"></script>

Add the class and an edge offset to an element:

// inline edge offset
<header class="sticky-polite" style="top: 1rem">Header</header>

- or -

// via stylesheet
<style>
  header.sticky-polite { top: 20px }
</style>

Important Notes:

  • defined edge: sticky-polite elements must have one edge offset defined. Elements with more than one, or less than one edge will be ignored.
  • nested containers: elements with an edge offset greater than zero, which are nested within a scrolling container may never be able to return to their static/natural position. This reflects the browser's native 'position: sticky' behavior, but is something to be aware of. You may find it useful to set the edge to '0px' and apply a padding value to the parent instead.

Advanced Usage

You can optionally style the element based on the state it's in.

  • static - The default state, where the element is resting in it's natural position
  • intersect - The element was off-screen, and you have begun scrolling towards it. It enters this state as it begins to reveal itself
  • sticky - The element is stuck to the view port edge (e.g. The element is fully revealed, and you are scrolling toward its natural position)
.sticky-polite[data-polite-state="static"] {
  outline: none;
}

.sticky-polite[data-polite-state="intersect"] {
  outline: 3px solid green;
}

.sticky-polite[data-polite-state="sticky"] {
  outline: 3px solid blue;
}

Important Notes:

  • foot guns: you can pretty easily shoot yourself in the foot by applying CSS which changes the element's dimensions or position. The utility will do what it can to adapt, but apply these state styles with caution, and test extensively.

Development

This repo uses tsup for bundling and live-server for a parallel-watch playground.

# Run the test harness (Builds source + Serves /playground)
npm run dev

# Build for production (Generates ESM, CJS, and Types)
npm run build

License

MIT