JSPM

  • Created
  • Published
  • Downloads 131030
  • Score
    100M100P100Q161404F
  • License ISC

Boxes that behave nicely while scrolling

Package Exports

  • react-sticky-box

Readme

Version Downloads/Week Minified Bundlesize Minified Gzipped Bundlesize

React Sticky Box

Sticky Boxes with sensible behaviour if the content is bigger than the viewport.

Use as a Component

import StickyBox from "react-sticky-box";

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

Or via the useStickyBox hook

import {useStickyBox} from "react-sticky-box";

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

Check out the docs for more deatils and live demos

react-sticky-box.codecks.io


Changelog