react-stickyish
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

react-stickyish

npm version npm bundle size

React Hook that allows for headers to be stickyish, so they disappear when scrolling down but reappear when scrolling up.

Check out the demo!

Install

npm install --save react-stickyish

Usage

The hook takes in one param for the ref of the element that should be made stickyish. The hook returns an object with the { top, position } CSS properties for the navbar that should be stickyish. You can extract these items out, or pass them into your HTML element directly.

import React, { useRef } from "react";
import { useStickyish } from "react-stickyish";
 
function Navbar() {
  const ref = useRef();
  const stickyish = useStickyish(ref);
  return (
    <nav ref={ref} style={stickyish}>
      ...
    </nav>
  );
}

Readme

Keywords

Package Sidebar

Install

npm i react-stickyish

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

14.3 kB

Total Files

11

Last publish

Collaborators

  • stevenla