Affix

Pins an element to the viewport once the page scrolls past it, and puts a placeholder of the same size in its place so nothing below jumps.

Basic

Wrap an element in Affix to pin it once its scroll container passes it, and set offsetTop to leave a gap above it.

Pin to the bottom

Set offsetBottom to hold the Accept button at the bottom edge of the terms, and use onChange to enable it once the reader scrolls to the end.

Both offsets

Set offsetTop and offsetBottom together and the child pins to the bottom edge before you reach it and to the top edge once you scroll past it.

Scrolling container

Pass target a function that returns the scrolling element when the Affix sits in a panel, drawer or modal instead of the page.

Pinned state

onChange receives true when the child pins and false when it returns, here to make the Share button solid only while it is pinned.

Child that changes size

Call updatePosition() on the ref after the pinned child changes size, so the space it holds in the page grows or shrinks with it.

API Reference

Affix
Affix's props. Rows marked antuikit in the Version column are added by the kit.