ScrollPin

ScrollPin

HkScrollPin is sticky content with a whitespace contract: the slot rides one edge of the nearest marked scroll host and never scrolls away, and the host's padding travels with it, so a pinned toolbar or step header keeps its breathing room instead of sitting flush against the header above. It is a plain position: sticky wrapper — that is all it renders, plus the contract that decides where the whitespace comes from.

  • For the scroll region itself, use HkScrollContainer; this component is the thing you put inside it.
  • To float a pill or a dock over a scrolling list, that is HkScrollProgressDock, not a pin.
  • For a header that belongs to a card rather than to a scroll region, the card's own header slot is the right place.

Import

tsx
1
import { HkScrollPin } from "@celestia-island/hikari";

This page documents the Vue implementation only: packages/components/src ships no Rust scroll pin, so every example below is TSX.

Sides

side is the edge of the scroll host to pin against: top (the default), bottom, left or right. A vertical scroller pins top and bottom, a horizontal one left and right; a side that contradicts the host's declared axis draws a development warning rather than a runtime error, so a mismatch stays visible while it is being built.

The pin has to sit inside the host's scroll flow — not inside a position: absolute or position: fixed ancestor, and not behind an overflow: hidden ancestor between it and the host, which would break stickiness. Stacking is handled for you: the pin floats above the scroll content, and a host can retune the layer through --hk-scroll-pin-z or the z prop.

TSX
Inbox

Line one.

Line two.

Line three.

Line four.

Line five.

5 threads

Strategies

strategy decides who owns the whitespace the host reserves for the content:

  • auto (the default) reads the host: a host that paints its gutters itself (it carries a data-pad-cover attribute and declares the matching --hk-scroll-pad-* value) resolves to offset; every other host resolves to bleed.
  • offset stops at the host's declared gutter line and lets the host paint the zone above or below the pin, so scrolled content vanishes under the whitespace instead of showing through a gap.
  • bleed absorbs the host's in-flow padding into the pin itself (padding plus a negative margin), so the pin's own background paints over the padding zone and the whitespace travels with the pinned content. That is only safe for a boundary pin — a top bleed pin must be the first element of the scroll content, a bottom bleed pin the last — because the negative margin would otherwise overlap a preceding sibling.
  • none is a plain sticky element flush at the edge, for a host with no declared padding or a consumer that opts out of the contract.

The resolved strategy is written onto the root as data-strategy, so the stylesheet has one switch to key on. Resolution runs once, at mount: a pin that changes host has to be re-keyed by the consumer.

TSX
Filters

Line one.

Line two.

Line three.

Line four.

Line five.

Summary

Both pins above sit at a boundary of the scroll content, which is what makes bleed — the strategy auto resolves to on a host that paints no gutter of its own — legitimate for them. A toolbar in the middle of the flow should be given strategy="none".

API

Vue

Props

NameTypeDefaultRequired
sideString as PropType<ScrollPinSide>"top"—
strategyString as PropType<ScrollPinStrategy>"auto"—
zNumberundefined—

Accessibility

  • The pin adds no role, no name and no tab stop of its own: it is a wrapper. Whatever lands inside keeps its own semantics, so a toolbar in a pin is still a toolbar, and the pinned content is still reachable in reading order.
  • Sticky content stays where the layout puts it, so the DOM order is the reading order: a pin that is the first child of the scroll content precedes everything it floats over, in the accessibility tree as well as on screen.
  • A pinned row that covers content when it sticks is only a visual overlay; below it the actual content is still present in the tree, so a screen-reader user reads the full list without having to scroll.
  • The component warns in development when the host is unmarked or the side contradicts the host's axis. Both warnings point at a real usability failure — a pin without a whitespace contract sits flush, and a horizontal pin on a vertical scroller never sticks.
  • Nothing here holds a listener, so unmount needs no teardown and the pin leaves no state behind.

Related components

  • HkScrollContainer — the marked scroll host whose viewport this pin sticks inside.
  • HkScrollProgressDock — the row-band pill docked at the viewport edge.
  • HkEdgeGlow — the painted edge band, for content that hides rather than sticks.
  • HkCard — the card whose own header is a fixed row above a scrollable body.