- Add the registry
- Add hide-on-scroll
Usage
HideOnScroll sticks to an edge of the nearest container that scrolls, or of the page, and
slides away once you've read down hideAfter pixels without stopping. It takes a longer scroll
up, revealAfter pixels, or a quick flick to bring it back, so the small corrections people make
while reading don't drop it over the text. It's always shown near the top, and comes back at the
end of the content too, where there's nothing left to read.
A bar at the top is clear until content scrolls beneath it, and data-at-top marks that. Set
edge="bottom" for a tab bar, and render it last in the scrolling region. data-hidden marks it
while it's away. Like Sticky Header, it takes the corners of the edge
it sticks to from its parent.
Tabbing into a hidden bar brings it back without the page jumping, and keeps it shown while
keyboard focus is inside. Clicking a button in it doesn't, so a tab bar still hides once you read
on. Set pinned to keep it shown yourself, such as while a menu in it is open.
With reduced motion, it still hides, but without sliding.
Props
The tables leave out className, style and render. Parts built on Base UI take them as its styling and composition guides describe.
HideOnScroll
useHideOnScroll
HideOnScroll decides when to hide with the use-hide-on-scroll hook, which comes with it. Use
it to hide another element, such as a Sticky Header. It takes the
same options and returns whether to hide the element and whether the container is scrolled to the
top.