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

@gnireeg/float-bar

v0.1.5

Published

Floating bar web component with automatic positioning and sticky behavior

Readme

@gnireeg/float-bar

Floating bar web component that automatically hides when scrolling down and reveals when scrolling up.

Features

  • ✨ Smooth animations using requestAnimationFrame
  • 📍 Auto-hide on scroll down, auto-show on scroll up
  • 🎯 Works with both window scroll and container scroll
  • ⚙️ Configurable offset to account for sticky elements
  • 📦 Zero dependencies
  • 🎯 TypeScript support
  • 💨 Lightweight and performant

Installation

npm install @gnireeg/float-bar

Usage

Basic Usage

<script type="module">
  import '@gnireeg/float-bar';
</script>

<float-bar class="bg-slate-800 text-white px-6 py-4">
  <nav>Your navigation content</nav>
</float-bar>

With Offset

Use the offset attribute to account for sticky elements above the float bar:

<float-bar offset="80" class="bg-white shadow-md">
  <nav>Your navigation content</nav>
</float-bar>

With Offset Element

Automatically use another element's height as offset:

<header id="top-header" style="height: 60px;">Fixed header</header>

<float-bar offset-element="#top-header" class="bg-white shadow-md">
  <nav>Your navigation content</nav>
</float-bar>

In Scrollable Container

The float bar automatically detects its scroll container:

<div style="position: relative; overflow: auto; height: 500px;">
  <float-bar class="bg-white shadow-md">
    <nav>Your navigation content</nav>
  </float-bar>
  <div>Scrollable content...</div>
</div>

Disabled (Static)

Disable the auto-hide behavior:

<float-bar disabled class="bg-white shadow-md">
  <nav>Static navigation</nav>
</float-bar>

API

Attributes

| Attribute | Type | Default | Description | |-----------|------|---------|-------------| | offset | number | 0 | Offset in pixels from the top | | offset-element | string | - | CSS selector for an element whose height will be used as offset | | disabled | boolean | false | Disables auto-hide behavior |

Styling

The float bar uses CSS transforms for smooth animations. You can style it like any other element:

float-bar {
  background: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 1rem;
}

Sticky State Class

The float bar automatically adds an is-sticky class when it reaches the sticky position (top of viewport or container):

/* Style the bar when it's sticky */
float-bar.is-sticky {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

This is useful for adding effects like shadows or background changes when the bar becomes sticky.

How it Works

The float bar:

  1. Automatically detects its scroll container (window or parent element)
  2. Monitors scroll direction
  3. Hides when scrolling down (using translateY transform)
  4. Shows when scrolling up
  5. Uses requestAnimationFrame for smooth 60fps animations

Browser Support

Works in all modern browsers that support:

  • Custom Elements v1
  • Shadow DOM v1
  • ES Modules

License

MIT

Author

Joel Geering