ScrollProgressDock

ScrollProgressDock

HkScrollProgressDock floats a small pill over a scrolling list naming the rows the reader can see — "Rows 11 → 20 of 340" — and turns that pill into a jump control. It is default-on and standalone: it sits between the scroll region and the list, senses the region, and describes whichever registered list is on screen without that list having to know the dock exists.

  • For the scroll region under the list, use HkScrollContainer; a list that wants the pill just renders inside the dock's subtree.
  • To pin a toolbar against the same viewport, use HkScrollPin — it is a different affordance, not a second version of the pill.
  • To say that more content hides past an edge, that is HkEdgeGlow.

Import

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

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

Where the pill lives

HkScrollContainer provides its viewport and its host element unconditionally, so a dock inside a container senses that viewport and teleports its pill onto the host — absolute, bottom-centre, never scrolling away with the content. Standalone, outside any container, the dock has nothing to sense and stays lazy until it is handed a viewport: a non-null element wins over the provided one, and an omitted or explicit null defers to whatever container is above. The dock's own scope has no box at all, so a standalone consumer positions the pill itself — the examples below therefore put a dock inside a container, where the teleport lands on a relative host.

The pill appears only when three preconditions hold: something registered with the dock, the viewport actually overflows vertically, and the active list has at least one row. The band is the visible row range with partial rows counted; the denominator is the registered total, or the live DOM row count whenever the declared total is missing, not finite, below one, or smaller than the rows actually present — so a list that loaded more rows than it declared can never show a band past its own end.

TSX

Row one.

Row two.

Row three.

Row four.

Row five.

Row six.

Row seven.

Row eight.

The pill of that example stays hidden on a first render: a pill needs a registered list, and a bare slot registers nothing. It also starts hidden even when a list is registered, and lights up only while the scroll offset is changing, fading out over the idle window afterwards — it is still hoverable when idle, so the jump surface is reachable without a prior scroll.

The example below therefore describes its rows through the dock's selector instead: any list component ships richer wiring — it injects the registrar the dock provides and hands over a handle with its root element and an authoritative total — which is exactly what HkTable does. A bare slot has no such infrastructure, but the selector grammar is enough for a hand-rolled roster.

Rows, totals and the selector

Two knobs decide what a row is. selector (default tbody tr) picks the descendants that count for the band and for the fallback total; the default deliberately matches body rows only, because a plain tr would count the header row as row one and skew every index. A list that owns its row grammar hands the dock a handle with getRows() instead, which wins over the selector and accepts undefined to fall back to it — that is how a table whose section bands are body <tr>s, but not data rows, stays honest. Registration and unregistration also take effect immediately, so a list mounting into an overflowing viewport becomes describable without waiting for a scroll.

TSX
Card 1 of 340
Card 2 of 340
Card 3 of 340
Card 4 of 340
Card 5 of 340
Card 6 of 340
Card 7 of 340
Card 8 of 340

selector is the whole opt-in for a bare slot: point it at the element that is one row, and the dock counts, bands and jumps over those elements — the pill still appears only once a list registers, so pair this with a registering list component, or with a handle of your own.

The dock also stands down rather than competing with another one: disabled turns it off, a shell that closed the allowed switch turns every dock in the face off, and a nested dock under an enabled one renders its slot as a bare fragment, providing nothing and installing no listener. Of a chain of docks the outermost enabled one serves the subtree, so exactly one pill can exist — and a hand-rolled composition keeps one dock per subtree for the same reason.

The jump surface

The pill is a real control, not decoration: it carries role="button", a localized accessible name and the popover wiring. A hover-capable pointer opens the panel on hover with no delay; a click or tap opens it pinned, so it survives the pointer leaving. Esc, an outside click, a second pill press or a committed jump dismisses it. On mobile viewports the same surface rises from the bottom edge as a sheet instead of anchoring above the pill.

The panel shows the current band, a scrub slider whose every tick jumps live, and a row field with a Go button. A jump puts row N at the top of the viewport band. It is clamped to the loaded rows — a declared total larger than the delivered rows cannot be scrolled to until its rows exist — and it is instant rather than smooth, because the scrub emits on every tick and smooth scrolling would lag behind the gesture.

TSX

Rows of page 1 scroll under the pill.

Row two.

Row three.

Row four.

Row five.

Row six.

Row seven.

Row eight.

Row nine.

Row ten.

API

Vue

Props

NameTypeDefaultRequired
disabledBooleanfalse—
viewport<code>Object as PropType<HTMLElement | null></code>undefined—
idleNumber900—
selectorString"tbody tr"—

Accessibility

  • The band digits are decorative spans inside the pill: the accessible name of the trigger is the localized "Jump to row" label, not the numbers, so a screen reader announces a button rather than a string of digits.
  • The pill is a focusable button: Enter and Space toggle the panel from the keyboard, and Esc closes it. The panel reports its own state through aria-haspopup and aria-expanded on the trigger.
  • The jump panel reports the current band through a polite live region, so a scrub or a jump reads out the new range instead of leaving the user guessing where they landed.
  • The slider carries its own accessible label, and the numeric field carries a field label, so both controls of the panel are named.
  • The pill's jump moves the scroll offset without moving focus, so a keyboard user who jumps keeps the control they were operating.

Related components

  • HkScrollContainer — provides the viewport and host the dock senses and teleports onto.
  • HkScrollPin — sticky content at the same viewport edge, when the content should stay instead of being described.
  • HkTable — a list large-component that registers its own row grammar with the dock.