CogniPrep's long entry pages are long. A provider hub or an employer guide runs thousands of pixels, and the primary action sits near the top. On a phone, somebody who reads to the end has nothing to tap without scrolling back.

The fix is the oldest pattern on mobile web: a bar pinned to the bottom with the action in it. The interesting part is that almost every decision in the 133 lines is a decision not to do the obvious thing.

It shows between two points, not from a threshold

The bar is not "appears after 400px". It shows after the page's own early call to action has scrolled up under the header, and hides again once the page's closing call to action or the footer comes into view. So it never doubles up with a button already on screen, and it is gone before the footer, which is what stops it covering anything.

Both ends are elements, not offsets. The start is an id passed in as a prop. The end is any element carrying a data attribute, or the footer:

const ends = Array.from(document.querySelectorAll(`[${STICKY_CTA_END_ATTR}], footer`)); 

Why not IntersectionObserver

This is the part I want to defend, because an observer is the right default and this is the case where it is wrong. The component's own comment states it:

 * Both points are read from element positions on scroll (once per frame), not * from IntersectionObserver: a jump straight past the early button, from a fast * fling or an in-page link, never intersects it, so an observer would not fire. 

An IntersectionObserver reports crossings. If a frame never renders with the element partially in view, there is no crossing to report. Two things on a long page do exactly that: a hard fling on iOS, where the compositor can jump hundreds of pixels between frames, and an in-page anchor link, which teleports past everything in between. In both cases the observer stays silent and the bar never appears, which is the one failure mode a reader notices.

So it reads positions instead, and it reads them as state rather than as events:

const update = () => { frame = 0; setPastAnchor(anchor.getBoundingClientRect().bottom <= HEADER_HEIGHT_PX); setAtEnd(ends.some((end) => end.getBoundingClientRect().top < window.innerHeight)); }; const schedule = () => { if (!frame) frame = requestAnimationFrame(update); }; update(); window.addEventListener('scroll', schedule, { passive: true }); window.addEventListener('resize', schedule); 

Three things keep that cheap. The listener is passive, so it cannot block scrolling. The work is coalesced to one requestAnimationFrame per frame no matter how many scroll events arrive. And update() is called once immediately, so a page restored mid-scroll by the browser is correct before the first scroll event rather than after it.

HEADER_HEIGHT_PX is 56, the height of the fixed header, so "scrolled away" means scrolled under the header rather than off the top of the viewport.

The end test is top < window.innerHeight, not a two-sided intersection check. An element above the viewport has a negative top, so "in view or already past it" collapses into one comparison. The bar never comes back once you have reached the end of the page.

The portal, and the one-word reason it is needed

The bar renders through createPortal into document.body. Not for convenience:

 * Rendered into document.body through a portal, so it can be mounted anywhere: * `main` carries `contain: paint` (app/globals.css), which would otherwise make * it the bar's containing block and pin the bar to the bottom of the page * instead of the bottom of the screen. 

The stylesheet has this, for unrelated reasons:

@layer base { main { min-height: calc(100dvh - 3.5rem); contain: layout style paint; } } 

contain: paint makes the element a containing block for fixed-position descendants. So position: fixed; bottom: 0 inside main is fixed to the bottom of main, which is thousands of pixels down. The bar would work in isolation and fail in place, and the failure would look like "the bar does not show" rather than "the bar is at the wrong offset", because you would have to scroll to the bottom of the document to see it.

A census of this repository in early November counted zero createPortal call sites. There are two now, and this is the one with a written reason.

Four details that cost four lines each

Client-only without a hydration flicker. The bar is invisible until the reader scrolls, so rendering nothing on the server changes nothing on screen:

const isClient = useSyncExternalStore(noSubscribe, () => true, () => false); 

A no-op subscribe and a false server snapshot. Static HTML ships without the bar, and the portal arrives after hydration. The practical upshot: the bar is in no page's HTML. You cannot find it by viewing source.

Scroll padding from the bar's real height. While the bar shows, it sets scroll-padding-bottom on the document to its own measured height, so keyboard focus and in-page jumps land above it instead of under it. Measured, not a constant, with the reason given inline: the label can wrap to two lines on a narrow phone.

Hidden properly, not just invisibly. When it is not showing it keeps pointer-events-none translate-y-full opacity-0 and also carries aria-hidden and inert. Opacity zero alone leaves a focusable link in the tab order that nobody can see.

A 48px target and the safe area. The button is min-h-12, and the bar's bottom padding is pb-[max(0.75rem,env(safe-area-inset-bottom))], so the home-bar gesture area on a modern iPhone does not eat the tap. The label is set to wrap rather than truncate, with a comment explaining why: a cut-off label could lose the word "free".

Where it runs, counted from the live site

Five page shells mount it, which puts it on 736 of the 1,093 public URLs:

Surface Pages with the bar
Per-test pages 409
Employer guides 201
Provider hubs 69
Company interview pages 42
Test format pages 15

Each shell names its own anchor id: test-cta, employer-cta, hub-cta, interview-cta, format-cta. Four different names for the same role, which is the kind of thing five parallel edits produce.

The employer number is the one worth noting. There are 214 employer guides, and 201 carry the anchor. The other 13 are guides where no test vendor is evidenced at medium confidence or better, which is a deliberate rule stated in the module that supplies the association: those pages get sibling links but no provider hub link, "because there is no hub that honestly matches the page". Both the early call to action and the bar read the same value, so where there is nothing honest to offer, neither renders. One condition, two surfaces, no special case.

The one loose end

STICKY_CTA_END_ATTR is exported so callers cannot typo the attribute name. All 69 provider hubs write the string by hand instead:

<div data-sticky-cta-end className="..."> 

A typo there is silent. The bar would simply stay up until the footer, which still looks fine, which is why nothing would catch it. The constant is doing no work until someone imports it.

See it

This one needs a narrow viewport, because the bar is md:hidden and it is not in any page's HTML.

Open the SHL provider hub and set your window to 375px wide, or open it on a phone. View source first and search for pointer-events-none translate-y-full: nothing, because the bar is portalled in after hydration.

Now scroll slowly. The bar arrives the moment the hub's own early button passes under the header, and it leaves again when the closing block at the bottom of the page comes into view. Search the source for data-sticky-cta-end and you are looking at the element that dismisses it.

Then try the hard case. Scroll back to the top, and flick as hard as you can straight to the bottom. The bar never appears, which is correct, because the end block is already in view. Now flick to the middle instead. It is there, having never been given a crossing to observe.

Finally, compare with an employer guide at the same width, where the anchor id is employer-cta instead, and with a per-test page, where it is test-cta. Same 133 lines, three different anchors.