Skip to content

hunghg255/reactjs-s4y

Repository files navigation

logo

A library sticky element for ReactJS

NPM Version NPM Downloads Minizip Contributors License

To install the latest stable version:

npm install --save reactjs-s4y

Basic usage:

import Sticky from "reactjs-s4y";

const Page = () => (
  <div className="row">
    <Sticky offsetTop={20} offsetBottom={20}>
      <div>Sidebar</div>
    </Sticky>
    <div>Content</div>
  </div>
);

Or via the useSticky hook

import {useSticky} from "reactjs-s4y";

const Page = () => {
  const stickyRef = useSticky({offsetTop: 20, offsetBottom: 20})
  <div className="row">
    <aside ref={stickyRef}>
      <div>Sidebar</div>
    </aside>
    <div>Content</div>
  </div>
};