use-headroom
Create headers that are hidden after user scrolls past given distance
Source
Docs
Package
Usage
The use-headroom hook creates headers that are hidden after the user scrolls past a given distance in pixels.
It returns { pinned, scrollProgress } where pinned is true when the element is at least partially
visible and scrollProgress is a number between 0 (fully hidden) and 1 (fully visible).
scrollProgress
Use scrollProgress to create a scroll-linked reveal animation instead of an instant
show/hide toggle. The value transitions from 1 (fully visible) to 0 (fully hidden)
as the user scrolls down past fixedAt, and back to 1 as the user scrolls up.
Direction changes mid-scroll are handled correctly — the progress continues from
wherever it was when the direction changed. Set scrollDistance to control how many
pixels of scrolling are needed to fully reveal or hide the element.
Callbacks
The hook supports onPin, onRelease, and onFix callbacks:
onPinis called when the header becomes visible (user scrolls up)onReleaseis called when the header is hidden (user scrolls down)onFixis called when the scroll position enters the fixed zone (scroll position ≤fixedAt)
Scroll to see callback events
Definition
Exported types
The UseHeadroomOptions type is exported from @mantine/hooks;